Home >Backend Development >PHP Tutorial >投票系统 有人刷票 求大神帮忙解决解决方案

投票系统 有人刷票 求大神帮忙解决解决方案

WBOY
WBOYOriginal
2016-06-13 11:26:301194browse

投票系统 有人刷票 求大神帮忙解决

本帖最后由 u010603569 于 2013-06-21 08:55:59 编辑
我这投票是一个IP地址在一个小时只能只能对一个ID投一票,但是那些刷票机器为什么能绕过一个小时,同一个IP能在一个小时之内不断的写入数据库,这点让我很不解,一个小时的时间限制完全对刷票机器不起作用,求大神帮忙解决,验证码很不友好,能不能有什么好方法解决这个问题
[size=36px][/size]
<?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 />


投票系统 PHP session
Statement:
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