This counter is capable of customizing any number of digits and can display a simple ad when provided free of charge.
When running, you need to create a nobody account in the counter directory that has permission to overwrite the directory datas.
Examples of actual operations in
Http://www.hnpts.ha.cn/freecount.htm
Header ("Content-type:image/png");
if ($user = = "") $user = "Test";
$FN = "datas/". $user. ". TXT ";
if ($bit = = "") $bit = 8; Take the default value
if (is_readable ($FN)) {$f =fopen ($FN, "R");
$c =fgets ($f, 255); fclose ($f);} read out the original count value
else $c = "0"; New user
$l =strlen ($c); Calculate actual value length
$cnt = "";
for ($i =0; $i < $bit-$l; $i + +) $cnt. = "0";//Front plus "0" to complement the specified number of digits
$cnt. = $c; $c 1=intval ($c); $c 1++;
$f =fopen ($FN, "w"); Fputs ($f, $c 1); fclose ($f); Write back
$f
if ($c 1%10==9) && ($user! = "Test") {$cnt = "www.hnpts.ha.cn"; $f
Show ads when conditions are met
$s =imagettfbbox ($font, 0, "Times.ttf", $cnt);
$x =abs ($s [4]) +8; $y =abs ($s [5]) +7;
$im = Imagecreate ($x, $y);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
if ($f
Imagerectangle ($im, $x-2, $y-2, $white);}
else $green = Imagecolorallocate ($im, 255,255,255);
Imagettftext ($im, $font, 0, 3, $y -5, $green, "Times.ttf", $cnt);
Imagepng ($im);
Imagedestroy ($im);
?>
The above describes a custom bit of PHP multi-user counter code, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.