自己在http://202.103.176.81/brun/phpdev/上用的计数器就是这个了,不知怎么了,现在21POP.COM把GD库给弄没了,好难过不能用不了!
<?php $counterFile = "counter.txt";
function displayCounter($counterFile) {
if (!file_exists($counterFile)) { exec( "echo 0 > $counterFile"); } $fp = fopen($counterFile,"r"); $num = fgets($fp,5); $num += 1; fclose($fp);
Header("Content-type: image/gif"); $im = imagecreate(58,16); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); $Fcolor = ImageColorAllocate($im, 0,0,255); $tran= imagecolortransparent($im, $white); imagefill($im, 0, 0, $tran);
$fp = fopen($counterFile,"w"); fputs($fp, $num); fclose($fp);
for ($I=1; $I<6; $I++) {
if ($num < pow(10,$I)) $countnum="0".$countnum; }
$countnum = $countnum . $num; imagestring($im, 5, 1, 2,$countnum, $Fcolor); ImageGif($im); ImageDestroy($im); }
displayCounter($counterFile); ?>
|
|