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 ("<script>alert" (' Sorry, you still have the option not selected!) '); History.back ();</script> ");}
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 "<script>alert (' Thank you for your participation, your report has been submitted!") '); History.back ();</script> ";
Setcookie ("Cook", $value, Time () +7200, "/");
}else{
Print "Sorry, you have already voted, <a href=# onclick=\" history.back (); \ > click Back </a>;
}
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 get 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 the unsafe label directly, leave this blank
"\\1\\2",
);
$str = Preg_replace ($farr, $tarr, $STR);
return $str;
}
?>
The latest, this cookie-like program can remove cookies and brushes, there is a way I have done before, first the client brush and then the user's IP saved to the database, In this way, the user will use the PHP program to check whether the operation within the time we specify, so you can achieve the real brush.