Connecting Tech Pros Worldwide Help | Site Map

opendir and current path problem ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 23rd, 2005, 02:35 PM
gnah@gnaw.com
Guest
 
Posts: n/a
Default opendir and current path problem ?

Greetings,

I hope my problem is easy to fix, I'm pretty new with php - but I am
getting weird results with the opendir() function. It may just be a
path problem, but I don't see which variable to change.

here are some tests I did to see what was wrong:

$blah = opendir("blocks");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}

$blah = opendir("modules");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}

$blah = opendir("images");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}


In the 1st and 3rd while()'s, it correctly picks the "blocks" and
"images" directories of my doc_root path (which is the path I get when
I try a getcwd()). However, the second while() lists me the files
contained in the "modules" directory of my server root (apache's
modules directory) instead of picking the "modules" directory in the
current dir. (both apache and the doc_root contain a 'modules'
directory). I know I could probably get around the problem using full
paths, but this is from phpnuke, so I'd like to keep the original code
intact and would prefer changing a config somewhere if possible.

Note that the very same server configuration on a win2k or on a winxp
do not give this problem, so I'm guessing it's a NT-related problem.
It's as if it's checking a list of directories in a path instead of
the current directory and the server_root happens to come before
doc_root.

Bug or feature ? Configuration problem ?


Thanks

FP



  #2  
Old August 23rd, 2005, 03:15 PM
r.m.johnson@gmail.com
Guest
 
Posts: n/a
Default Re: opendir and current path problem ?

Just a thought, try renameing that directory to something more random
and see if you still get the same result... it may be the choice of
"modules" as a directory name that is confusing it.

  #3  
Old August 23rd, 2005, 03:35 PM
gnah@gnaw.com
Guest
 
Posts: n/a
Default Re: opendir and current path problem ?

I already tried creating a "images" directory in apache's root
directory (same place where the 'modules' directory is) and put some
random files in it - I reloaded the page and this time it listed the
newly created "images" directory instead of phpnuke's. So it's a
question of identical directory names and paths, not just for the name
"modules".

Thanks anyway ;)


On 23 Aug 2005 08:10:09 -0700, r.m.johnson@gmail.com wrote:
[color=blue]
>Just a thought, try renameing that directory to something more random
>and see if you still get the same result... it may be the choice of
>"modules" as a directory name that is confusing it.[/color]

  #4  
Old August 23rd, 2005, 05:15 PM
ZeldorBlat
Guest
 
Posts: n/a
Default Re: opendir and current path problem ?

Take a look at your include path in php.ini. It may be looking in ./,
then ../, then elsewhere. What happens when you specify the complete
path to the directory in your call to opendir() ?

  #5  
Old August 29th, 2005, 02:45 PM
comehere@truc.brol
Guest
 
Posts: n/a
Default Re: opendir and current path problem ?

Hi, sorry for the delay...

Putting the full paths work, as I expected.
My php.ini include path is:
include_path = ".;C:\apachefriends\xampp\php\pear\"

The . is the current directory I think, though logically that would be
apache\bin rather than apache\. However, as I said, this very same
configuration does not give me the problem on a Win2k/XP machine. So
I figure it's WinNT that's being weird here.

For now I think I will simply move the site on a different server
rather than waste time modifiying code - it's just a few lines to fix,
but who knows what other surprises this kind of problem might give me
later...

Anyway, if anyone sees where the bug is, feel free to join in..

later,

Fp


On 23 Aug 2005 10:11:05 -0700, "ZeldorBlat" <zeldorblat@gmail.com>
wrote:
[color=blue]
>Take a look at your include path in php.ini. It may be looking in ./,
>then ../, then elsewhere. What happens when you specify the complete
>path to the directory in your call to opendir() ?[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.