This counter can customize any number of digits and display a simple advertisement for free.
During running, you need to create a datas directory under the counter directory where the nobody account has the permission to rewrite.
The actual running example is shown 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 the original Count value
Else $ c = "0"; // new user
$ L = strlen ($ c); // calculate the actual value Length
$ Cnt = "";
For ($ I = 0; $ I <$ bit-$ l; $ I ++) $ cnt. = "0"; // Add "0" before to fill in the specified number of digits
$ Cnt. = $ c; $ c1 = intval ($ c); $ c1 ++;
$ F = fopen ($ fn, "w"); fputs ($ f, $ c1); fclose ($ f); // write back
$ Font = 20;
If ($ c1 % 10 = 9) & ($ user! = "Test") {$ cnt = "www.hnpts.ha.cn"; $ font = 16 ;}
// Display 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 );
$ White = ImageColorAllocate ($ im, 255,255,255 );
If ($ font = 20) {$ green = ImageColorAllocate ($ im, 0,255, 0 );
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 );
?>