php专区

 首页 > php专区 > PHP应用 > 常用功能 > 改进的IP计数器-PHP实例

改进的IP计数器-PHP实例

分享到:
【字体:
导读:
          改进的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 "计数器";
    echo "你是第" .$num."访问者
";
    echo "今天你第".$click."次点击
";
    echo "今天总点击".$total."次
";

/*
表:  
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实例
图书查询部分: 书目查询
6、PHP列出目录下的文件名
如果你想列出目录下的所有文件,使用以下代码即可: 1 function listDirFiles($DirPath){ 2 3 if($dir = opendir($DirPath)){ 4 5 while(($file = readdir($dir))!== false){ 6 7 if(!is_dir($DirPath.$file)) 8 9 { 10 11 ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……