Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Sun Oct 29, 2006 11:01 pm Reply with quote

I'm trying to debug someone's site, and I'm really getting stuck. The code is standard Patched (7.8 to be exact) and it is just not working correctly.

It is the "adding modules" code in admin/modules/modules.php
admin.php?op=modules

Specifically,
Code:


      $handle = opendir('modules');
      $modlist = "";
       while ($file = readdir($handle)) {
           echo "* : " . $file . "<br />";
         if ( (!ereg("[.]",$file)) ) {
            $modlist .= "$file ";
         }
       }


Now I've added the echo to see whether $file is being outputted. It isn't.
This code works fine outside this file. It will read the appropriate modules directory and output the files.

I've started commenting out lines to figure out the problem. Here is where I am stuck:

admin.php
calls the function GraphicAdmin() {

Which runs this code
Code:


      $linksdir = dir("admin/links");
      $menulist = "";
      while($func = $linksdir->read()) {
         if(substr($func, 0, 6) == "links.") {
            $menulist .= "$func ";
         }
      }
      closedir($linksdir->handle);


There doesn't seem to be a problem directly with this code. But when I comment it out, the above modules.php code works fine.

I cannot replicate this situation on my system. I was thinking it could be a path problem. But I've tried replicating it with the second code running in

/test.php
and including the first code in
/admin/modules/test.php

That seems to work fine. Anyone know of restrictions placed on opendir and dir that would prevent them to work? I just don't think its either of them, because I can copy this code into a seperate .php file and execute it fine.

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Mon Oct 30, 2006 2:13 am Reply with quote

Is $handle returning a valid pointer in $handle = opendir('modules');?
Have you turned errors on and checked your error log?
 
View user's profile Send private message
technocrat
Life Cycles Becoming CPU Cycles



Joined: Jul 07, 2005
Posts: 511

PostPosted: Mon Oct 30, 2006 10:16 am Reply with quote

Try:
Code:
//Inspired by phoenix-cms at website-portals.net

//Absolute Nuke directory
define_once('NUKE_BASE_DIR', dirname(__FILE__) . '/');
//Absolute Nuke directory + includes
define('NUKE_BLOCKS_DIR', NUKE_BASE_DIR . 'blocks/');
define('NUKE_IMAGES_DIR', NUKE_BASE_DIR . 'images/');
define('NUKE_INCLUDE_DIR', NUKE_BASE_DIR . 'includes/');
define('NUKE_LANGUAGE_DIR', NUKE_BASE_DIR . 'language/');
define('NUKE_MODULES_DIR', NUKE_BASE_DIR . 'modules/');
define('NUKE_THEMES_DIR', NUKE_BASE_DIR . 'themes/');
define('NUKE_ADMIN_DIR', NUKE_BASE_DIR . 'admin/');
define('NUKE_DB_DIR', NUKE_INCLUDE_DIR . 'db/');
define('NUKE_ADMIN_MODULE_DIR', NUKE_ADMIN_DIR . 'modules/');
define('NUKE_FORUMS_DIR', (defined("IN_ADMIN") ? './../' : 'modules/Forums/'));

      $handle = opendir(NUKE_MODULES_DIR);
      $modlist = "";
       while ($file = readdir($handle)) {
           echo "* : " . $file . "<br />";
         if ( (!ereg("[.]",$file)) ) {
            $modlist .= "$file ";
         }
       }

_________________
Nuke-Evolution
phpBB-Evolution / phpBB-Evolution Blog 
View user's profile Send private message
evaders99







PostPosted: Mon Oct 30, 2006 11:35 am Reply with quote

Yes, nothing is giving an error message that I could use to debug.

I know I could do as technocrat's code and hard-code the paths.

It wouldn't explain why this code works just fine on many other systems and just stopped working for this specific one.
 
Raven







PostPosted: Mon Oct 30, 2006 11:45 am Reply with quote

Is this account on the same server where the other one(s) work? If not, I suspect it's a php.ini issue.
 
technocrat







PostPosted: Mon Oct 30, 2006 12:28 pm Reply with quote

Maybe a file or another path is conflicting.
 
evaders99







PostPosted: Mon Oct 30, 2006 1:55 pm Reply with quote

I think in the end, I may just have to reinstall anyway. But I will try a clean phpNuke install and let you know
 
Dauthus
Worker
Worker



Joined: Oct 07, 2003
Posts: 211

PostPosted: Mon Oct 30, 2006 1:55 pm Reply with quote

Don't know if this will help or not, but sometimes you can suppress the error and the code will execute. Just put an "@" sign in front of the opendir like so:

Code:
$handle = @opendir('modules');


and perchance would one site be running safe mode and the other not?

_________________
Image
Vivere disce, cogita mori 
View user's profile Send private message Visit poster's website
gregexp
The Mouse Is Extension Of Arm



Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Mon Oct 30, 2006 7:21 pm Reply with quote

Took this right off php.net so no credit to me, but perhaps this will help evaders, I guess it Just basically handles $file in a more specific direction, Hope this works for you.

while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
[ Only registered users can see links on this board! Get registered or login! ]

Thats the link so you can see why I thought it pertenant to do this this way.


Dauthus, the @ symbol simply surpresses or holds back the error, if one is to be seen.

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Dauthus







PostPosted: Mon Oct 30, 2006 8:27 pm Reply with quote

isn't that what i said???
 
evaders99







PostPosted: Tue Oct 31, 2006 12:13 am Reply with quote

Yea I saw that on php.net too. Wish it would fix it

If an error isn't being generated, how could be surpressed? Smile
 
Dauthus







PostPosted: Tue Oct 31, 2006 7:25 am Reply with quote

evaders99, sorry but I must have misunderstood the issue. I made the assumption that since the code wasn't working properly you were getting some type of error. My bad.
 
evaders99







PostPosted: Tue Oct 31, 2006 8:53 am Reply with quote

It's funny because I use getcwd() and it returns the same working directory Smile

This is one of those I'm going to file under "mystified"
 
technocrat







PostPosted: Tue Oct 31, 2006 10:25 am Reply with quote

What version of PHP maybe there was a bug in their build
 
gregexp







PostPosted: Tue Oct 31, 2006 1:49 pm Reply with quote

Evaders, what directory is being returned? The root?

My thinking is perhaps an addon or something is changing directories on you.

Another thing I was thinking was perhaps the buffer was getting full.
I have a few ideas but Im sure youll get it.
 
evaders99







PostPosted: Tue Oct 31, 2006 2:42 pm Reply with quote

Yes the Nuke root. I was thinking something was changing their current directory. But it isn't

So oh well. They're trying to rebuild.
 
evaders99







PostPosted: Wed Nov 01, 2006 9:11 am Reply with quote

I reinstalled a clean version of phpNuke files (that I know work), and it is doing the same thing. Thought it was maybe the database, so I loaded up a new clean database. Same thing.

I'm at a loss
 
gregexp







PostPosted: Wed Nov 01, 2006 9:46 pm Reply with quote

Have you tried modules/?

Just really weird to me as well.

Ive takin all the code, and tried it myself.

Id really like to see the full code, what version of nuke is it?
 
evaders99







PostPosted: Wed Nov 01, 2006 11:15 pm Reply with quote

It's something with this server. But I'm not going to start going to compare every PHP setting. It is apparent that this server crashed at some point. So waiting on it to be reset and restarted.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©