CochodioS
counter.hits #
Set Vars uptop to the file you want to make and your start date. #
-Updated so counter.hits only logs one instance of the same ip to keep filesize down #
######################################################################################
*/
/*
Core Variables
*/
$filename = "counter.hits" ;
$startdate = "December 2002" ;
$ip = getenv("REMOTE_ADDR") ;
$currentip = "$ip";
$file = file($filename);
$file = array_unique($file);
/*
This is the guts of the counter
*/
$file = "$filename";
$fd = fopen ($file, "r");
$fget= fread ($fd, filesize ($file));
fclose ($fd);
$totalips = htmlspecialchars($fget);
if (preg_match ("/$ip/i", "$totalips"))
{$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo "Visitors since,
";
echo "$startdate: 000$hits";}
else
{
$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename)) ;
fclose($fd) ;
$fd = fopen ($filename , "w");
$fcounted = $fstring.$currentip."n";
$fout= fwrite ($fd , $fcounted);
fclose($fd);
$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo "Visitors since,
";
echo "$startdate: 000$hits";
}
?>