php 文件计数据器+mysql双保护

php图片计数器代码,他的落到实处形式是先用程序把数字保存到贰个txt文件或数据库,然后再读取,当然数字大家要做0-9的图片啊.好了上面我们来看看计算代码吧.

php
文件计数据器+mysql双护卫,那是上次进级版了,上次流量大太日常出标题今日改正回复了.

?phprequire_once(../inc/connect.php);Class Sit_count{ public $FileName
= ‘count.txt’; function Count_add(){if(file_exists($this-FileName)
){$Temp = file_get_contents($this-FileName);$Array =
explode(=,$Temp);if(count($Array) != 2){$Tmp
=’mytext=’.$this-Tcount();}else{$Total = $Array[1]+1;$Tmp
=$Array[0].’=’.$Total;}$T =
@fopen($this-FileName,’w’);if($T){fwrite($T,$Tmp);fclose($T);}mysql_query(update
wk_count set count_bak =count_bak+1 where id=1);}else{echo ‘!
file_exists’;} } function Tcount(){ $result =mysql_query(Select *
from wk_count where id =1 ) or die(mysql_error());$rs
=mysql_fetch_array($result);return $rs[‘count_bak’]; }} $tp = new
Sit_count; $tp-Count_add(卡塔尔国;?好了下边大家来探视show.php输出文件.

?phprequire_once(../inc/connect.php);Class Sit_count{ public $FileName
= ‘count.txt’; function Count_add(){if(file_exists($this-FileName)
){$Temp = file_get_contents($this-FileName);$Array =
explode(=,$Temp);if(count($Array) != 2){$Tmp
=’mytext=’.$this-Tcount();}else{$Total = $Array[1]+1;$Tmp
=$Array[0].’=’.$Total;}$T =
@fopen($this-FileName,’w’);if($T){fwrite($T,$Tmp);fclose($T);}mysql_query(update
wk_count set count_bak =count_bak+1 where id=1);}else{echo ‘!
file_exists’;} } function Tcount(){ $result =mysql_query(Select *
from wk_count where id =1 ) or die(mysql_error());$rs
=mysql_fetch_array($result);return $rs[‘count_bak’]; }} $tp = new
Sit_count; $tp-Count_add(State of Qatar;?本站原创转发注解

?php$count = substr(file_get_contents(‘count.txt’),7);$con_len
=strlen($count);for($i=$con_len-1;$i=0;$i–){echodocument.write(‘img
src=../counter/counter/.substr($count,$i,1)..jpg /’);; }

?

如此那般大家的输片流量计就出去了,注意哦.echodocument.write(‘img
src=../counter/counter/.substr($count,$i,1State of Qatar..jpg
/’State of Qatar;;必需以document.write输出哦,因为大家上边要用js情势调用哦.

上边在txt.html那样调用show.php文件就能够了如下.

script src=’show.php’/script

等啊,我们学科就OK了.

本站原创转请注明:

发表评论

电子邮件地址不会被公开。 必填项已用*标注