简单投票系统[防刷程序刷新]
简单投票系统[防刷程序刷新]
include_once("../inc/connect.php");
$value =$_SERVER['HTTP_HOST'];
if(empty($_COOKIE["cook"])){
if(sizeof($_POST)alert('对不起,你还有选项未选!');history.back();");}
for($i=1;$i
$c =$_POST['r'.$i];
switch( intval($c) ){
case 0:
$word ='vote_r1';
break;
case 1:
$word ='vote_r2';
break;
case 2:
$word ='vote_r3';
break;
default:
exit('error');
}
$sql ="update gx_votes set $word=$word+1,vote_times=vote_times+1 where id=$i";
mysql_query($sql) or die(mysql_error());
}
if( !empty($_POST['r9']) || !empty($_POST['r10']) ){ sava_voteinfo();}
echo "<script>alert('感谢你的参与,你的报表己提交!');history.back();</script>";
setcookie("cook", $value, time()+7200, "/");
}else{
print "对不起,你己经投票了,点击返回";
}
function sava_voteinfo(){
$vote_modi =addslashes(php_sava(isset($_POST['r9'])?$_POST['r9']:''));
$vote_info =addslashes(php_sava(isset($_POST['r10'])?$_POST['r10']:''));
$vote_ip =isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'未获取到IP';
$vote_time =date("Y-m-d H:i:s");
$vote_sql ="Insert into ss(vote_ip,vote_modi,vote_info,vote_time) value('$vote_ip','$vote_modi','$vote_info','$vote_time')";
mysql_query($vote_sql) or die('error');
}
function php_sava($str)
{
$farr = array(
"/\s+/",
"/]*?)>/isU",
"/(]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
);
$tarr = array(
" ",
"<\\1\\2\\3>", //如果要直接清除不安全的标签,这里可以留空
"\\1\\2",
);
$str = preg_replace( $farr,$tarr,$str);
return $str;
}
?>
最新说一下,这种用cookie形式的程序可以清除cookie再刷,有一种办法是我以前做过了,先是客户端防刷然后再把用户的IP保存到数据库,这样用户刷时就会用php程序来检查是否在我们规定的时间内操作喽这样就可以实现真正的防刷喽.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
