|
-
July 27th, 2006, 04:37 PM
#1
Junior Member
PHP help
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.
<?php
$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);
fclose($fp);
$fw=fopen($file,"w");
$new_cnt = $count+1;
fwrite($fw,$new_cnt);
fclose($fw);
$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";
endif;
?>
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|