Jump to content

[SOLVED] Can't Read IIS logfile / Permissions?


65bit

Recommended Posts

Hi,

 

I'm a longtime programmer, but new to PHP and the forums.  I wondered if I should post this in the IIS area, but talked myself into this being the right place, so my apologies if that's incorrect.

 

My environment is PHP 5, IIS 6 and MySQL 5.  We just added ftp to our site and I want to put a script together to interrogate the log file as the visitor is coming out of the "transfer page". 

 

Unfortunately, while I can go to Windows Explorer and open the file, my script doesn't seem to be able to do even a basic "count the lines".  I'm guessing it's a permission issue of some type, but like I said, I'm totally new.

 

<?
$date = date('ymd');
$todays_log = "C:\WINDOWS\system32\LogFiles\FTP\MSFTPSVC2016890665\ex" . $date . ".log";
$lines = count($todays_log);
print($lines);
?>

 

echos 1, even though there are hundreds of lines in the file.  If I change the value of $todays_log to a random text file located elsewhere in the file system, it shows the correct number of lines.

 

Trying to understand the permissions (I might be going in the wrong direction here ??), I've done this

 

<?
print($todays_log . "<br>");
print("directory permission ");
print substr(sprintf('%o', fileperms('"C:\WINDOWS\system32\LogFiles\FTP\MSFTPSVC2016890665')), -4); 
print("<br>");
print("file permission ");
print substr(sprintf('%o', fileperms($todays_log)), -4); 
print("<br>");
?>

 

which shows permission of 0 for both the directory and the file.  The "windows permissions" are the same for the folders for both the file I can read and the one I can't.  But, the permission shown with the above on the file I can read is "0777".  When I try to chmod() to 0777 for the logfile, it seems to have no effect.

 

On the other hand, it could be something altogether different.  You'd think accessing a logfile shouldn't be that hard  :) Any input is appreciated.

 

Thanks

I'm guessing the other "random text file" isn't in the windows system32 folder?  I know it seems like a long way around to the solution, but can you try copying the file to another spot on the drive (assumed to be not so protected), getting the count and then deleting the copy?

You're correct, the random file I mentioned that I could open was sitting in c:\

 

I've discovered error reporting since my post and have added this to my code

 

ini_set('display_errors', 1);
error_reporting(E_ALL);

 

It confirms a permission problem.  Unfortunately, such that it won't even let me copy the file. 

 

Warning: copy(C:\WINDOWS\system32\LogFiles\FTP\MSFTPSVC2016890665\ex090330.log) [function.copy]: failed to open stream: Permission denied in d:\inetpub\testsite.com\s\sftp.php on line 105

 

I'm going to ask that the log file be written elsewhere and see what that does for this process.  If that resolves my issue (it should??), I'll come back and mark it solved.

 

Thanks for the input

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.