Hit Counter
Posted: Tue Feb 24, 2004 6:04 pm
Hi,
i have made a hit counter in flash and it uses php to work. i got everything to work but now im trying to make it better so that it logs the users visited and i a trying to make it so that it doesnt log my ip address and and a few more addresses. here is my code so far:
i have made a hit counter in flash and it uses php to work. i got everything to work but now im trying to make it better so that it logs the users visited and i a trying to make it so that it doesnt log my ip address and and a few more addresses. here is my code so far:
Code: Select all
<?php
$count = file_get_contents("count.txt");
$count = explode("=", $count);
$count[1] = $count[1]+1;
$ipad1 = 127.0.0.0;
$ipad2 = 192.168.1.1;
$ipad3 = localhost;
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("n-j-Y, g:i:sa");
if ($ip == "$ipad[]"){
echo "";
} else {
$file = fopen("count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
$filename = 'logs/weblog.html';
$fp = fopen($filename, "a");
$string = "
<tr>
<td bgcolor=white><font face=arial size=1 color=black>
<center>$date</td>
<td bgcolor=white><font face=arial size=1 color=black>
<center>$ip</td>
</tr>";
$write = fputs($fp, $string);
fclose($fp);
print "count=".$count[1];
}
?>
it should save the log to weblog.html.
Dave
?>