• Notice regarding image hosts and attachments. See here.

PHP visitor count

Associate
Joined
12 May 2005
Posts
1,785
hello

This is what I've come up with to count the number of IP addresses.
Is there a way to do it more efficiently ?


$cip = $_SERVER['REMOTE_ADDR'];//store IP address
$file = fopen("uviews.txt","r+"); //open uviews.txt for reading
sscanf(fgets($file),"%d",$uviews);
$string3 = fgets($file);
while(! feof($file))
{
$string3 = $string3 . fgets($file);
}
if(!(strpos($string3,$cip)))
{
$uviews++;
$string3 = $uviews . "\r\n" . $string3 . "\r\n" . $cip;
fclose($file);
$file = fopen("uviews.txt","w+"); //open uviews.txt for writing
fwrite($file,$string3);
}
fclose($file);
 
Back
Top Bottom