Nevermind... Found a tutorial. Here's the code:
PHP Code:
<?php
$addr=$REMOTE_ADDR; // Assigns Remote address to $addr
$server=$SERVER_NAME; // Assigns Server Name to $server
$today=date("d/M/Y:H:i:s"); // Assigns the date details to $today
$timecorr="+0530"; // Provides Offset for time zone + or - from GMT :: +0530 for India
$method=$REQUEST_METHOD; // Assigns the Method to $method
$serprot=$SERVER_PROTOCOL; // Assigns the Protocol to $serprot
$browser=$HTTP_USER_AGENT; // Assigns Browser details to $browser
$space=" "; // Assigns space to $space
$apos='"'; // Assigns " to $apos
$fil=$SCRIPT_NAME; // Assigns the called file along with path to $fil
$name=basename($fil); // Uses basename() to get the file name from path with file name
$fsiz=filesize($name); // Uses filesize() to get size of file $name
$ref=$HTTP_REFERER; // Assigns the referring file to $ref
// All the special characters like - , [ ] ," and spaces to meet format needs are achieved below.
// when the string $webdet is created.
$webdet=$addr.$space.$server." - "."[".$today.$space.$timecorr."]".$space.$apos.$method.$space.$fil.$space.$serprot. $apos.$space."200".$space.$fsiz.$space.$apos.$ref.$apos.$space.$apos.$browser.$apos."\n";
// The string $webdet with all the parts is created using the string operator . to join the
// different individual elements, with a end of line "\n" at the end of the string
$filelog="ip.txt"; // Assigns file ip.txt to $filelog
$fweb=fopen($filelog,"a"); // Opens a file pointer $fweb
fputs($fweb,$webdet,250); // Appends the entire string up to 250 bytes length to the file
fclose($fweb); // Closes the file after writing
?>
Add ip.txt to the folder where this will be located and chmod it to 777, i would include() this in my index.php =)
Bookmarks