Social Icons

Sunday, February 17, 2013

PHP IP Logging Script

IP Address Logs can be a very handy tool for analysis by webmasters. So here in this post I am going to give a simple PHP script which will log all the IP of visitors on your website with every impression. Log will be created in an ever expanding HTML file "ips.html", along with date of visit and page accessed.


<?php
$ip = $_SERVER['REMOTE_ADDR'];
$pagina = $_SERVER['REQUEST_URI'];
$datum = date("d-m-y / H:i:s");
$invoegen = $datum . " - " . $ip . " - " . $pagina . "<br />";
$fopen = fopen("ips.html", "a");
fwrite($fopen, $invoegen);
fclose($fopen);
?>

This code will also come very handy in detecting hacking attempts and DOS/DDOS attacks. The best use of it though is the ability to track your website users navigation with it.

No comments:

Post a Comment