Tag Archives: tutorials

Adding an IP log code to PHP files

A lot of people want to keep track of who visit their site. There are several ways to collect user data and the most easiest method would be to collect data using a third party company that logs IPs, page visited and other information such as web browser, data, time, etc. Then then data can be modify to create data on demographics and Internet service providers by extrapolating the IP addresses. However, what is fun of having a third party do your code for you? The fun part comes win when we can make our own code such as the one posted below:

<!--ip log-->
<?php
$v_ip = $_SERVER['REMOTE_ADDR'];
$v_date = date("l d F H:i:s");
$v_page = $_SERVER['REQUEST_URI'];
$u_ref = $_SERVER['HTTP_REFERER'];
$fp = fopen("sanuja.com-ip_log.php", "a");
if ($v_ip != "192.168.1.1") {
fputs($fp, "<strong>IP: $v_ip - </strong><strong>PAGE:</strong> $v_page - <strong>DATE:</strong> $v_date - <strong>REFERER:</strong> $u_refn
");
}
fclose($fp);
?>

Continue reading Adding an IP log code to PHP files