473,698 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("module s");
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 3324
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.*********@gma il.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:\apachefri ends\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********@gma il.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2559
by: Andrew DeFaria | last post by:
I'm attempting to put my music collection on the web using PHP and I hit a problem. When I attempt an opendir of a directory that contains a "'" character the opendir fails. Here's the code snippet: function GetAlbumArt ($path) { if ($handle = opendir ("$path")) { while (false !== ($element = readdir ($handle))) { if (strpos ($element, "AlbumArt") == 0 && strpos ($element, "Large") != 0) { return $element;
1
6908
by: Bob Gervais | last post by:
Hi, I am writing a very simple script that should return all subdirectories on a given path (non recursively, so just first level). This is the sub that I have for doing this but it gives very strange results: sub FindFiles {
2
3210
by: Alex | last post by:
Greetings all, I'm trying to use the "opendir" command on Win32 in a CGI script. I'm using Apache 2.0.48 for Win32. The "openDir" command works from the CGI script when I try to open a folder located on my local system. When I try to "openDir" a network drive using the CGI script run through Apache, Apache gives me the error: Can't openDir... However, when I run the CGI script in a DOS window, the command works properly.
5
5075
by: Markus Pitha | last post by:
Hello, i'm using Gentoo Linux and like to open directories which i got from a text file i read of. I tried to open a directory as i wrote the directory name directly into "opendir()" and it worked. When i use this pointer on the array "input", which contains the actual directory, the program cannot read the directory. I already tested if "input" contains the directories at all, but it does. > if ((fp = fopen(fpath, "r")) ==...
6
1818
by: dmcglynn | last post by:
Hello all.. I have a strange issue. I am trying to do an opendir via a UNC path, from my windows server to another windows machine. As long as my remote machine is on a physically wired connection, it works great. However, if my remote machine is on a wireless network, I get the following error: Warning: opendir(\\10.51.50.79\plc$): failed to open dir: Invalid
3
3186
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it appears to be the base directory of the running script. For example, if you execute the file testme.py in your current working directory, '' is on sys.path. If you execute c:\Python25\Scripts\testme.py,...
7
8423
code green
by: code green | last post by:
I am trying to access files on a different drive but the same server to where the script is running. but I only get the error failed to open dir: Invalid argument in C:\apache\xampp\htdocs\path\to\scriptI have tried the following combinations if(opendir('S:/folder/')) echo 'found'; if(opendir('S:/folder)) echo 'found'; if(opendir('S:\folder\\')) echo 'found'; if(opendir('S:\folder)) echo 'found';
6
8791
by: MK | last post by:
I don't use c much but i've done lots of perl, perl/Tk, and shellcode on LINUX. I'm trying to do things with directory trees and i occasionally get back an errno from opendir "No such file or directory" while my program is working its way thru a tree. This always happens with the same directory (ie. it is not totally random) although there is nothing different or unusual about the ownership or permissions (ie. there actually is such a...
2
5119
by: kkhan5000 | last post by:
Hello, I would like to use an URL insttead of a local path in the following command, is it possible? $url = 'http://www.mysite.com/content/'; $dir = opendir($url); Thank you,
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.