A user-defined multi-user counter

Source: Internet
Author: User
This counter can customize any number of digits and display a simple advertisement for free. Why? Header (Content-type: imagepng); if ($ user) $ userte counter

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" 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 = 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 );

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.