simple voting system [anti-brush program Refresh]
Include_once (".. /inc/connect.php ");
$value =$_server[' Http_host '];
if (Empty ($_cookie["Cook"])) {
if (sizeof ($_post) <9) {exit ("");}
for ($i =1; $i <=8; $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 "";
Setcookie ("Cook", $value, Time () +7200, "/");
}else{
Print "Sorry, you have already voted, click Back";
}
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 ']: ' Not acquired to 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+/",
"/< (\/?) (script|i?frame|style|html|body|title|link|meta|\?| \%) ([^>]*?) >/isu ",
"/(<[^>]*) on[a-za-z]+\s*= ([^>]*>)/isu",
);
$tarr = Array (
" ",
"<\\1\\2\\3>",//If you want to clear unsafe labels directly, you can leave this blank
"\\1\\2",
);
$str = Preg_replace ($farr, $tarr, $STR);
return $str;
}
?>
Recently, this cookie-like program can erase cookies, one way I have done before, first client anti-brush and then save the user's IP to the database, In this way, the user will use the PHP program to check whether it is within our specified time to operate, so you can achieve a real anti-brush.
http://www.bkjia.com/PHPjc/629751.html www.bkjia.com true http://www.bkjia.com/PHPjc/629751.html techarticle simple voting system [anti-brush program refresh]? php include_once (.. /inc/connect.php); $value =$_server[' Http_host ']; if (empty ($_cookie[cook))) {if (sizeof ($_post) 9) {exit (Scriptalert (' Sorry ...