<?php<br />
error_reporting(0);<br />
session_start();<br />
require_once 'config.php';<br />
require_once COMMON_PATH.'Common.php';<br />
$common = new Common();<br />
date_default_timezone_set ('Asia/Shanghai');<br />
$weil = strtotime("2013-08-07 23:59:59"); <br />
$now = time();<br />
if($weil-$now < 0){//投票时间过期<br />
echo 0;<br />
exit;<br />
}<br />
<br />
$ip = $common->getClientIp();<br />
$id = $_POST['id'];<br />
$ipid=$ip.$id;<br />
if($_SESSION['ipid']==$ipid||$_COOKIE['ipid']==$ipid){<br />
<br />
//$array = array('48','49','67','47'); <br />
//if ( in_array($id,$array) ) {<br />
echo 2;<br />
} else {<br />
$tbName = TB_NAME;<br />
$limit_time = 3600;<br />
$arr = $common->getItems('id,addTime','20130618_ztao_jtsjip','id','desc',"where tpId='$id' and ip='$ip'");<br />
$row = false;<br />
if (count($arr) > 0) {<br />
$row = $arr[0];<br />
}<br />
if(!$row){<br />
$common->insertItems('20130618_ztao_jtsjip','tpId,ip,addTime',"'$id','$ip','$now'");<br />
$res = $common->updateItems("$tbName",'voteNum=voteNum+1',"$id");<br />
$_SESSION['ipid']=$ipid;<br />
setcookie("ipid","$ipid",time()+$limit_time);<br />
if($res == true){<br />
echo 1;//投票成功 <br />
}else{<br />
echo 3;<br />
}<br />
<br />
}else if(($now-$row['addTime'])>$limit_time){<br />
$common->insertItems('20130618_ztao_jtsjip','tpId,ip,addTime',"'$id','$ip','$now'");<br />
$res = $common->updateItems("$tbName",'voteNum=voteNum+1',"$id");<br />
$_SESSION['ipid']=$ipid;<br />
setcookie("ipid","$ipid",time()+$limit_time);<br />
if($res == true){<br />
echo 1;<br />
}else{<br />
echo 3;<br />
}<br />
}else if(($now-$row['addTime'])<$limit_time){<br />
echo 2;<br />
}else{<br />
echo 3;<br />
}<br />
}<br />
<br />
?><br />
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn