|
Header("Content-type: image/gif");
$fp = fopen("zzm.txt", "r");
$str1 = fgets($fp,10);
$str1++;
fclose($fp);
$fp = fopen("zzm.txt", "w");
fputs($fp, $str1);
fclose($fp);
/*
以下是把访问人数格式化输出,如果访问人数位数不够9位,例如时5000(4位),
则把访问人数变换成000005000的形式输出。方法是计算访问人数的位数,并且
把它和000000000的位数(9位)比较,得到相差的位数,然后在数字前面不上相
应个0。例如5000,和000000000两者的长度相差5,因此要在5000前面补5个0。
*/
$len1 = strlen($str1);
$str2 = "000000000";
$len2 = strlen($str);
$dif = $len2 - $len1;
$rest = substr($str2, 0, $dif);
$string = $rest.$str1;
$font = 4;
$im = imagecreate(88,31);
$black = ImageColorAllocate($im, 0,172,236);
$white = ImageColorAllocate($im, 255,255,255);
imagefill($im, 0,0,$black);
$px = (imagesx($im)-8.3*strlen($string))/2;
ImageString($im,3,$px,2,"k666-Counter",$white);
imageline($im, 1, 14, 85, 14, $white);
ImageString($im,$font,$px,15.5,$string,$white);
ImageGif($im);
ImageDestroy($im);
?> |