$formatnumber = true; // add thousands separator? false disables it. // ONLY EDIT BELOW IF YOU WANT THE HIT COUNTER RENDERED AS AN IMAGE $showimage = true; // change to true to enable image render $font = 5; // font style, 1-5. These are built in php fonts! $fontcolour = "black"; // black or white font? $bgcolor = "transparent"; // transparent or black background? $counterfile = $_GET['counterfile']; // added by RBH 12-07-2010 // DO NOT EDIT BELOW THIS LINE - DO THE CUSTOMISING IN THE PAGE YOU INCLUDE ON! // $path = __FILE__; $path = preg_replace( "'\\\pageVisits\.php'", "", $path); $path = preg_replace( "'/pageVisits\.php'", "", $path); $counter = $path."/".$counterfile.".dat"; // modified by RBH 12-07-2010 if(file_exists($counter)) { $fp = fopen($counter, "r+"); flock($fp, 1); $count = fgets($fp, 4096); $count += 1; fseek($fp,0); fputs($fp, $count); flock($fp, 3); fclose($fp); } else { print "
Error, could not find ".$counterfile.".dat in ".$path.", please check it!
"; } if($formatnumber) { $count_new = number_format($count, 2, ",", ","); $count_new = substr($count_new, 0 , -3); $count = $count_new; } if($showimage) { $width = imagefontwidth($font) * strlen($count); $height = imagefontheight($font); $im = @imagecreate($width, $height); if(trim($bgcolor) == "black") $background_color = imagecolorallocate($im, 0, 0, 0); // black background else { $background_color = imagecolorallocate($im, 255, 255, 255); //white background imagecolortransparent($im, $background_color); } if(trim($fontcolour) == "black") $text_color = imagecolorallocate($im, 0, 0, 0); // black text else $text_color = imagecolorallocate($im, 255, 250, 205); // white text or colour you want (#fffacd=255,250,205) imagestring($im, $font, 0, 0, $count, $text_color); header("Content-type: image/gif"); imagegif($im); imagedestroy($im); } else { print $count; } ?>