一个自定义位数的多用户计数器
来源:互联网 发布:sql注入攻防入门详解 编辑:程序博客网 时间:2024/06/06 19:47
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
运行的时候需要在计数器目录下创建一个nobody帐户有权改写的目录datas.
实际运行的例子在
http://www.hnpts.ha.cn/freecount.htm
<?
Header("Content-type: image/png");
if ($user=="") $user="test";
$fn="datas/".$user.".txt";
if ($bit=="") $bit=8; //取默认值
if (is_readable($fn)) {$f=fopen($fn,"r");
$c=fgets($f,255);fclose($f);} //读出原来的计数值
else $c="0"; //新用户
$l=strlen($c); //计算实际值长度
$cnt="";
for ($i=0;$i<$bit-$l;$i++) $cnt.="0";//前面加“0”补足指定的位数
$cnt.=$c;$c1=intval($c);$c1++;
$f=fopen($fn,"w");fputs($f,$c1);fclose($f); //写回
$font=20;
if (($c1%10==9)&&($user!="test")) {$cnt="www.hnpts.ha.cn";$font=16;}
//达到条件就显示广告
$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 ($font==20) {$green = ImageColorAllocate($im, 0,255,0);
imagerectangle($im,1,1,$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);
?>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
此计数器能够自定义任意位数,而且在免费提供的时候能够显示一个简单的广告。运行的时候需要在计数器目录下创建一个nobody帐户有权改写的目录datas.
实际运行的例子在
http://www.hnpts.ha.cn/freecount.htm
<?
Header("Content-type: image/png");
if ($user=="") $user="test";
$fn="datas/".$user.".txt";
if ($bit=="") $bit=8; //取默认值
if (is_readable($fn)) {$f=fopen($fn,"r");
$c=fgets($f,255);fclose($f);} //读出原来的计数值
else $c="0"; //新用户
$l=strlen($c); //计算实际值长度
$cnt="";
for ($i=0;$i<$bit-$l;$i++) $cnt.="0";//前面加“0”补足指定的位数
$cnt.=$c;$c1=intval($c);$c1++;
$f=fopen($fn,"w");fputs($f,$c1);fclose($f); //写回
$font=20;
if (($c1%10==9)&&($user!="test")) {$cnt="www.hnpts.ha.cn";$font=16;}
//达到条件就显示广告
$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 ($font==20) {$green = ImageColorAllocate($im, 0,255,0);
imagerectangle($im,1,1,$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);
?>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 一个自定义位数的多用户计数器
- 一个不错的计数器
- 一个简单的计数器
- Hadoop自定义计数器的使用
- 一个正整数的位数
- 一个简单的网页计数器
- 一个简单的图形计数器
- 一个简单计数器的源代码
- 一个简陋的文字计数器
- 一个漂亮的点击计数器
- 一个简单的性能计数器
- 一个简单的性能计数器
- jsp 一个简单的计数器
- 自定义计数器
- 生成一个包含数字和字母的自定义位数的验证码
- 自定义一个控制输入小数或整数的位数的EditText
- 求一个整数的位数
- 计算一个数的位数
- DataList控件也玩分页 (转自aspcn.com)
- MySQL通用查询程序
- C#排序算法大全
- 一个简单的图形计数器
- .NET几大热点问题(转)
- 一个自定义位数的多用户计数器
- C#的4个基本技巧
- 一个模仿oso的论坛程序(之三)
- 六种快速修理C# Bug的方法
- 一个模仿oso的论坛程序(之一)
- C#中调用Windows API的要点
- 一个模仿oso的论坛程序(之二)
- 用 StringBuilder 类替代 String
- 一个个人网页自动化生成系统(6)