Very Odd opendir problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Very Odd opendir problem.

Post by Owe Blomqvist »

Hi.
I´m currently writing a log parser for iis.
But i ran into a strange problem.
When i do:

Code: Select all

$log_path = opendir('C:\\WINNT\\system32\\LogFiles\\MSFTPSVC1');

while (false !== ($files = readdir($log_path))) 
{ 
       echo "$files<br>";
&#125;
I get: "Warning: OpenDir: Invalid argument (errno 22) in D:\WWWserver\___WWW_ROOT___\IIS_PARSER\TMP4vynw5mscg.php on line 4"

The directory exists allright, but when i do:

Code: Select all

$log_path = opendir('C:\\WINNT\\system32\\LogFiles');

while (false !== ($files = readdir($log_path))) 
&#123; 
       echo "$files<br>";
&#125;
It works fine.
I get the directory listed, which i wanted to open.
Anybody has any ideas?
I have checked file permissions. That´s not the problem.
/Owe Blomqvist
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

maybe the account php (and the webserver) is running on has no access permissions for this directory
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Post by Owe Blomqvist »

I can open all folders on the computer i have tried, except the actual log folder.
I don´t know how to work around this.
I have tried all kinds of various things but without luck.
The only thing i could do , (atleast as it seems) is to manualy copy the log files into another directory. But this is not what i want.
I hope somebody out there has a work around for this.
/Owe Blomqvist.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

even if

Code: Select all

is_readable($dirname) or die ('not readable');
//is_executable($dirname); doesn't work at all on win32
does not stop the script it is possible on php/win32 that the script has no access to the folder.
afaik Warning: OpenDir: Invalid argument (errno 22) always mean either not a local directory or access denied.
If you (as user) have access to this directory you may try your script with php-cli.exe
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Post by Owe Blomqvist »

Hmm...
Okeis. Thanks.
Where can i find this php-cli.exe?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

it's within the zip-package of php/win32 at http://www.php.net and is simply the command line version of php (in opposite to the normal cgi php.exe)
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Post by Owe Blomqvist »

Thank You very much for the help.
I´m Downloading php-cli.exe & searching for info on how to use it. :)
/Owe Blomqvist.
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Post by Owe Blomqvist »

One question...
How do i use it?
I´ve been reading the php installation file & all i see is:

Code: Select all

Please note that you cannot use php-cli.exe with your webserver, you need
    to use php.exe which can be found in the sapi directory of your PHP
    distribution.
Sorry for bugging you with this newbish questions.
Best regards,
Owe Blomqvist.
Owe Blomqvist
Forum Commoner
Posts: 33
Joined: Wed Oct 16, 2002 2:27 pm

Post by Owe Blomqvist »

I found the error.
If anybody is interested, it was a registry key that caused this.
I found by setting "Guest Access" to 1 it works fine.
I don´t know if it is a security risk enabling it though. :?

Code: Select all

&#1111;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSFTPSVC\Parameters]
"AllowGuestAccess"=dword:00000001
Post Reply