Version: 1.2
Type: Full Script
Category: HTTP
License: GNU General Public License
Description: This counter can do:
-count how many visits you got 🙂
-ignoring reloads(if the new ip is the same or older than “Wait”)
as the last one accessed !
-show the date on which the counter started (in a unix timestamp
See at the end for formating)
-show the last visited date/time(in a unix timestamp
See at the end for formating)
-show the ip of the last visitor
-show pictures (named 1.jpg, 2.jpg …0.jpg)
If ya like this or got better ideas drop me a line: [email protected]
www.simma-online.at
<?php /* This counter creates a file that lists all ip addresses that have visited the site. If a new ip address visits the counter increases bye one and adds the ip address to its list. A cookie is put on the computer also to speed up to process for old users... a long list of ip address can take a while to search. The addresses are not in order. 1-Check for cookie that says been to page 2-If cookie then do nothing (no code required) 3-If no cookie then check for ip adress in database 4-If ip adress found create new cookie 5-If ip adress not found then create new cookie, add 1 to the count and add ip adress to list 6-display count */ //check for ipaddress function findip($ip, $filename){ $file = fopen($filename, "r"); $contents = fread($file, filesize($filename)); fclose($file); //get data $tok = strtok($contents,"n"); $count=$tok; for ($i = 0; $i < $count; $i++){ if ($ip == strtok("n")){ return 1; } } return 0; } $filename = "count.txt"; //check if file exists if (!file_exists($filename)){ $file = fopen($filename , "w"); fwrite($file, "0"); fclose($file); } //find count - number of ip addresses $file = fopen($filename,"r"); $count = fgets($file); //get number of visiting ips fclose($file); //look for cookie and ipaddress //decide if person has visited before if ($visited == NULL){ setcookie("visited","1",time()+2592000); if (!findip($REMOTE_ADDR, $filename)){ $count = $count + 1; $file = fopen($filename, "r+"); fwrite($file, "$count"); fclose($file); $file = fopen($filename, "a+"); fwrite($file, "$REMOTE_ADDRn"); fclose($file); } } ?> <html> <head> </head> <body> <?php //display count of visited ip addresses for ($i=0; $i < strlen($count); $i++) { $sign = substr($count, $i, 1); print("<img src="$sign.jpg" border="0" alt="$sign">"); } ?> </body> </html>