471,602 Members | 1,350 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,602 software developers and data experts.

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
Aug 23 '05 #1
4 3191
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.

Aug 23 '05 #2
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.*********@gmail.com wrote:
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.


Aug 23 '05 #3
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() ?

Aug 23 '05 #4
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" <ze********@gmail.com>
wrote:
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() ?


Aug 29 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Andrew DeFaria | last post: by
1 post views Thread by Bob Gervais | last post: by
5 posts views Thread by Markus Pitha | last post: by
6 posts views Thread by dmcglynn | last post: by
3 posts views Thread by Chris Mellon | last post: by
6 posts views Thread by MK | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.