来源:自学PHP网 时间:2014-12-25 09:57 作者: 阅读:次
[导读] 改进的IP计数器,lt;?nbsp;nbsp;//require’common.inc’;nbsp;nbsp;$arr_request=array;nbsp;nbsp;ifcount$HTTP_GET_VARSnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;{nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;whilelist$key,$value=each$HTTP_GET_VARSnbsp;nbsp;nbsp;nbsp;...
<?
//require (’common.inc’); $arr_request=array(); if (count($HTTP_GET_VARS)) { while (list($key,$value)=each($HTTP_GET_VARS)) { $arr_request[strtolower($key)]=$value; } } if (count($HTTP_POST_VARS)) { WHILE (list($key,$value)=each($HTTP_POST_VARS)) { $arr_request[strtolower($key)]=$value; } } $link=@MySQL_connect("localhost","kong","kong"); mysql_select_db("mywebdb"); $ip=$REMOTE_ADDR; $current=getdate(time()); $day=$current["mday"]; $query="select * from addcount where day=\"$day\""; $result=@mysql_query($query); if(!$num=@mysql_num_rows($result)) $num=1; while($row=@mysql_fetch_row($result)) { if (strcmp($ip,$row[1])==0) { $i=1; $id=$row[0]; $click=$row[3]+1; $up="update addcount set click_count=click_count+1 where id=$id"; $result2=@mysql_query($up); // break; } $total+=$row[3]; } $total++; if(!$i){ $query1="insert into addcount (ip,day,click_count )values ('$ip','$day',1)"; mysql_db_query("mywebdb",$query1,$link); $click=1; } echo "<html><head><title>计数器</title></head>"; echo "你是第" .$num."访问者<BR>"; echo "今天你第".$click."次点击<BR>"; echo "今天总点击".$total."次<BR>"; /* 表: addcount CREATE TABLE addcount ( id int(6) DEFAULT '0' NOT NULL auto_increment, ip char(20) NOT NULL, day int(2) NOT NULL, click_count int(3) NOT NULL, PRIMARY KEY (id) ); */ ?> |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com