July 27th, 2006, 04:37 PM
Hey there, I've been reading up on PHP for a while now and I've decided to take a look at some free ware scripts when I came across this Hit counter, below is the code.
$tipa = "0";//Include Text AND IP address? 1= Yes 0=No
/*If you set $tipa to 1 (Yes) You may edit the Text to be shown, below */
$text1 = "You are visitor number";//DO NOT REMOVE "Quotation Marks"
$text2 = "Your IP address is";//DO NOT REMOVE "Quotation Marks"
$file = "count.dat"; //data file *** CHMOD 0777 *** MUST !!!
$fp = fopen($file,"r");
$count = fgets($fp,1024);
$new_cnt = $count+1;
$visits = "";
$ipa = $_SERVER["REMOTE_ADDR"];
$c1 = "$text1 $new_cnt<br />\n";
$c2 = "\t$text2 $ipa\n";
if($tipa == "0"):
$visits = $new_cnt;
elseif($tipa == "1"):
$visits = "$c1 $c2";
Now I understand most of it but I was wondering, is there any way to make it so that it will only register a hit once per IP adress? Thanks.