<div align="center">
<?php
/**********************************************************
Flat File Hit Counter
By ElectricStorm, PrintedExistence[dot]com
this script is free, opensource and provided as is.
***********************************************************/
$file = "hits.txt"; //the path to an empty text file where the number of hits is stored.
$usegraphics = 1; //change to 0 if you want your counter numbers to be plain text.
//try to get txt file:
if (!is_file($file)) { echo("Error getting hits file!"); }
else {
//read number currently stored on hits file:
$read = file_get_contents($file);
//add a new hit:
$newhits = $read +1; //define $newhits by adding 1 to existing number
$open = fopen($file, "w"); //open the file for writing (overwrites previous value)
flock($open, LOCK_EX); //lock so that noone else can edit this file while we are
fwrite($open, $newhits); //write the new number in
flock($open, LOCK_UN); //release lock
fclose($open);
//display the counter:
if ($usegraphics == 1) {
//display the counter numbers as graphics:
$numbers = preg_split('//', $newhits, -1, PREG_SPLIT_NO_EMPTY); //split into single chars
foreach($numbers as $number) { //for each number...
echo("<img src=\"grafix/".$number.".gif\">"); //show it's graphic
}
} else {
//display the counter numbers as plain text:
echo($newhits);
}
} //end else (got hits file ok)
?>
<br>Hits since December 18th 2006
</div>