Thursday, May 31, 2012

simple counter php




simple counter php


Make a folder named as "digits" in your web root in side the digit folder make another folder named as "1". Then you have to design images for numbers(0-9) by using image processing software as follows.


Name above images as 1,gif,2gif...............9.gif and incert into folder "1 " you created.Next you have to make empty text file called hits where visitors number of hits are storing.

Create below php file and run you can see the count of visitors hit.

<?PHP

$counterstyle = "images";  
$imagetype = "1";          

$hitslog = "hits.txt";    
$imagefolder = "digits";   

$hits = file($hitslog);
$hits = $hits[0] + 1;


$fp = fopen($hitslog, "w");
fwrite($fp, $hits);


if ($counterstyle == "text") { print $hits; }


if ($counterstyle == "images") {
 $digit = strval($hits);
 for ($i = 0; $i < strlen($hits); $i++) {
print "<img src=\"$imagefolder/$imagetype/$digit[$i].gif\">";
                }
        }

?>

No comments:

Post a Comment