Saturday, October 16, 2010

A simple PHP program to log your IP



<?php

$ip = getenv ('REMOTE_ADDR');

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$date=date("j F, Y, g:i a");;
$fp = fopen('iplog.html', 'a');

fwrite($fp, "IP logged: ".$ip.",  ".$hostname);
fwrite($fp, ", Date ".$date."\n");

fclose($fp);
?>
<?
$file = fopen('iplog.html',"r") or die ("Can't read this file");

while (! feof($file)) {
        $line = fgets($file,256);

        print $line.'<br>';
        }
fclose ($file);

?>
Click here for demo to log your IP!! 

No comments:

Post a Comment