PHP Multi-user counter code with a custom number of bits

Source: Internet
Author: User
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.

  • 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.