Re: php counter

From: Date: Wed, 07 Aug 2002 15:04:20 +0000
Subject: Re: php counter
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111516@lists.php.net to get a copy of this message
Ha ha! I just wrote the counter script yesterday and finish it all in 30 minutes. The only thing different is I did not use the images and I matched the text font code to match the background color of the webpages. That way, ordinary people won't see it but staff can by just dragging the mouse over and highlight the invisible counter. (You have to know where the counter is). Also, I include the addition feature so that when my company staff access the website, the counter won't be counted. All that left is the risk of possible duplicate count when the person browse the front page to other links on the same website and than back to the front page again. I decided to leave it that way because I don't believe it is worth it to keep adding list of files to ignore while the website is continuously being expanded. Because we would forget anyway. Here's the script I made! (This work well on window and sometime not on UNIX/LINUX because of file permission.) --clip-- flush(); $IP = $REMOTE_ADDR; if (strlen($IP) == 0) { $IP = $_SERVER['REMOTE_ADDR']; } $file = "counter.txt"; ////IP Address behind the firewall ////if (($IP >= "xx.xx.xx.xx") && ($IP <= "xx.xx.xx.xx")) { ////IP Address outside the firewall if ((!($IP >= "xx.xx.xx.xx")) && (!($IP <= "xx.xx.xx.xx"))) { $counter = @fopen($file, "r"); $count = @fread($counter, filesize($file)); @fclose($counter); $counter = fopen($file, "w+"); $count += 1; fwrite($counter, $count, strlen($count)); fclose($counter); } else { $counter = @fopen($file, "r"); $count = @fread($counter, filesize($file)); @fclose($counter); } echo "<center><span style='color:#39387B;font-size:6pt;'>* ".$count." *</span></center>"; --clip-- Cheers, FletchSOD "Anthony Ritter" <tony@gonefishingguideservice.com> wrote in message news:20020806200945.95880.qmail@pb1.pair.com... > Trying to test a counter using php / MS Windows 98 / Apache with three .jpg > files. > > They are named: > > 1.jpg > 2.jpg > 3.jpg > > and are stored in a folder called: > images > > which is in the same directory as Counter.txt > within > htdocs. > > I run the following script but the images do not appear. > Thanking all in advance. > Tony Ritter > ............................................................ > > <? > $counter_file="./Counter.txt"; > $image_dir="./images"; > if(!($fp=fopen($counter_file, "r")))die("Couldn't open the file"); > $counter=(int)fread($fp, 20); > fclose($fp); > > $counter++; > > for($i=0; $i<strlen($counter); $i++) > { > $image_scr=$image_dir."/".substr($counter, $i, 1).".jpg"; > $image_tag_str.="<IMG SCR=\"$image_src\" BORDER=\"0\">"; > } > > echo "You are visitor $image_tag_str"; > $fp=fopen($counter_file, "w"); > fwrite($fp,$counter); > fclose($fp); > ?> > > >

« previous php.general (#111516) next »