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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.