Here’s a simple script I’ve written for logging IP’s that stumble upon my main webserver.
/* start code */
$ip = $_SERVER[’REMOTE_ADDR’];
$dte = date(”l jS F Y, g:i A”);
echo “Your IP address is: $ip”;
echo date(”l jS F Y, g:i A”);
/* then give them a warning that they had been logged */
echo (”Your visit on my site was logged!”);
/* end of code */
Sample output:
Your IP address is: xxx.xxx.x.xxx
Saturday 15th October 2005, 1:02 AM
Your visit on my site was logged!
This little script is pretty cool when coupled with the free program called IPnetinfo a small utility that allows you to easily find all available information about an IP address. This utility can also be very useful for forensics after an attack has occured (that is if the attacker is lame enough to leave the *cough* log files uncleaned).
This is the script to save every hit to a file called ‘myLog.txt’.
/* start of code */
$fileopen = fopen(”myLog.txt”, “a”);
fwrite ($fileopen, $dte.” - “.$ip.”\n”);
fclose ($fileopen);
/* end of code */
That’s it!
No comments:
Post a Comment