织梦DedeCMS自定义表单限制IP24小时只能提交多少次
方法1.打开plus/diy.php,找到一下代码,
if(!is_array($diyform)) { showmsg('自定义表单不存在', '-1'); exit(); }
然后再在以下代码后面插入
if(isset($_COOKIE['VOTE_MEMBER_IP'])) { if($_COOKIE['VOTE_MEMBER_IP'] == $_SERVER['REMOTE_ADDR']) { ShowMsg('您已经填写过表单啦','-1');exit(); }else{setcookie('VOTE_MEMBER_IP',$_SERVER['REMOTE_ADDR'],time()*$row['spec']*3600,'/');} }else{setcookie('VOTE_MEMBER_IP',$_SERVER['REMOTE_ADDR'],time()*$row['spec']*3600,'/');}
方法2.
//判断ip,限制预约次数
//利用限制IP达到重复多次提交的目的,用户同一个IP只能一天内只能提交三次,在上面的代码替换成下面代码:
$intime = date('Y-m-d'); $row_ip = $dsql->getOne("SELECT count(*) as dd FROM `dede_xxxx` WHERE ip like '%{$ip}%' and date like '%{$intime}%'"); if($row_ip['dd'] >= 3) { echo "<script>alert('您今天的次数已经到达上限,欢迎明天前来!'); window.location.href=''"; exit(); }