Simple voting system [anti-brush Program Refresh]

Source: Internet
Author: User
Tags get ip

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.