/*
##############################################################
# Cyber Count v-1.0
#
# Script Made By: Night Walker
# Writen: 08/29/2002
#
# Features: creates a file and logs unique cookie based users
# visits to the site.
# easy installation
#
# Instructions: modify the site parametrs to reflect your site.
# make sure you give the write attribute to the
# file you set as your counter.
# call this file at the begining of your script
# include "cyber_count.inc"
# echo the $hits results in your page
##############################################################
*/
// -- Site parameters -- //
$dir = "images";//images directory
$f_name = "cyber.txt";//counter file name
$alt = 'alt="Cyber Counter"';//alternative text for image
$c_name="cyber_count";//cookie name
// -- Check For counter.txt -- //
if(!file_exists($f_name)){
$fp=fopen($f_name,"w");
fputs($fp,"0");
fclose($fp);
}
// -- Visitor already came : the cookie is here -- //
if (isset($$c_name) && ($$c_name=="1")){
$fp=fopen($f_name,"r+");
$hits=fgets($fp,10);
}
else{// -- A new visitor is coming: creation of a cookie -- //
setcookie($c_name,"1","time()+900");//setting up the cookie - default 15 min(900 seconds)
$fp=fopen($f_name,"r+");
$hits=fgets($fp,10);
$hits++;//increment counter
fseek($fp,0);
fputs($fp,$hits);//write new counter
fclose($fp);
$count++;//number of times the user has done a refresh
}
//replace the numbers with their images
for($i=0;$i<10;$i++) $hits = str_replace("$i","
","$hits");
$hits = str_replace('alt=""','alt="" border="0" height="12" width="10"',$hits);
?>