一个自定义位数的php多用户计数器
时间:2007-02-17 来源:PHP爱好者
一个自定义位数的多用户计数器
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
关键词:PHP
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
此计数器能够自定义任意位数,而且在免费提供的时候能够显示一个简单的广告。
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
运行的时候需要在计数器目录下创建一个nobody帐户有权改写的目录datas.
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
实际运行的例子在
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
http://www.hnpts.ha.cn/freecount.htm
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
Header("Content-type: image/png");
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($user=="") $user="test";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$fn="datas/".$user.".txt";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($bit=="") $bit=8; //取默认值
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if (is_readable($fn)) {$f=fopen($fn,"r");
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$c=fgets($f,255);fclose($f);} //读出原来的计数值
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
else $c="0"; //新用户
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$l=strlen($c); //计算实际值长度
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$cnt="";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
for ($i=0;$i<$bit-$l;$i++) $cnt.="0";//前面加“0”补足指定的位数
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$cnt.=$c;$c1=intval($c);$c1++;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$f=fopen($fn,"w");fputs($f,$c1);fclose($f); //写回
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$font=20;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if (($c1%10==9)&&($user!="test")) {$cnt="www.hnpts.ha.cn";$font=16;}
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
//达到条件就显示广告
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$s=ImageTTFBBox($font,0,"times.ttf", $cnt);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$x=abs($s[4])+8;$y=abs($s[5])+7;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$im = imagecreate($x,$y);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$black = ImageColorAllocate($im, 0,0,0);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$white = ImageColorAllocate($im, 255,255,255);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($font==20) {$green = ImageColorAllocate($im, 0,255,0);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
imagerectangle($im,1,1,$x-2,$y-2,$white);}
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
else $green = ImageColorAllocate($im, 255,255,255);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImageTTFText($im,$font,0, 3,$y-5, $green, "times.ttf", $cnt);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImagePng($im);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImageDestroy($im);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
?>
php爱好者站 http://www.phpfans.net 网页特效|网页模板
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
关键词:PHP
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
此计数器能够自定义任意位数,而且在免费提供的时候能够显示一个简单的广告。
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
运行的时候需要在计数器目录下创建一个nobody帐户有权改写的目录datas.
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
实际运行的例子在
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
http://www.hnpts.ha.cn/freecount.htm
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
Header("Content-type: image/png");
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($user=="") $user="test";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$fn="datas/".$user.".txt";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($bit=="") $bit=8; //取默认值
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if (is_readable($fn)) {$f=fopen($fn,"r");
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$c=fgets($f,255);fclose($f);} //读出原来的计数值
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
else $c="0"; //新用户
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$l=strlen($c); //计算实际值长度
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$cnt="";
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
for ($i=0;$i<$bit-$l;$i++) $cnt.="0";//前面加“0”补足指定的位数
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$cnt.=$c;$c1=intval($c);$c1++;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$f=fopen($fn,"w");fputs($f,$c1);fclose($f); //写回
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$font=20;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if (($c1%10==9)&&($user!="test")) {$cnt="www.hnpts.ha.cn";$font=16;}
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
//达到条件就显示广告
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$s=ImageTTFBBox($font,0,"times.ttf", $cnt);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$x=abs($s[4])+8;$y=abs($s[5])+7;
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$im = imagecreate($x,$y);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$black = ImageColorAllocate($im, 0,0,0);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
$white = ImageColorAllocate($im, 255,255,255);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
if ($font==20) {$green = ImageColorAllocate($im, 0,255,0);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
imagerectangle($im,1,1,$x-2,$y-2,$white);}
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
else $green = ImageColorAllocate($im, 255,255,255);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImageTTFText($im,$font,0, 3,$y-5, $green, "times.ttf", $cnt);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImagePng($im);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
ImageDestroy($im);
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
China It Power . CombQcm7n29BBMzgCr6sTe8m4CaJ
?>
php爱好者站 http://www.phpfans.net 网页特效|网页模板
相关阅读 更多 +