$aid=$_GET['aid'];//获取上页传来的文章ID
$ip=getenv("REMOTE_ADDR");//获取IP
include"conn.php";
$sql="select * from acounter where aid='$aid'";
);
);
$sql_count="select count(*) from acounter where aid='$aid' ";
);
);
/* print_r($result_count[0]);*/
// 判断IP与AID是不是一样,如果不同,则执行插入,
if(!$result['ip']&&$aid!=$result['aid']){
$sqlInsert = "INSERT INTO `acounter` (`countID` ,`ip` ,`timeAt` ,`aid` )
VALUES (NULL , '$ip', NOW( ) , '$aid')";
);
}else{/*如果相同,则不执行插入,执行下面的ELSE语句*/
$sqlS="SELECT TIME_TO_SEC( NOW( ) ) - TIME_TO_SEC( timeAt ) FROM `acounter`
WHERE ip = '$ip' and aid='$aid' ORDER BY `TIME_TO_SEC( NOW( ) ) - TIME_TO_SEC( timeAt )` ASC ";
);
);
if($resultS[0]>1*60*60){//判断用户刷新两次相隔时间是否大于一个小时,如果不大于一个小时,则不进行插入语句
$sqlI = "INSERT INTO `acounter` (`countID` ,`ip` ,`timeAt` ,`aid` )
VALUES (NULL , '$ip', NOW( ) , '$aid')";
);
}
}
?>
阅读(557) | 评论(0) | 转发(0) |