Jump to content

voting flaw


abazoskib

Recommended Posts

I have a table for votes in one of my websites that accepts votes for different photos. The code that accepts votes looks like this:

 

             /////////////////////
             //BEGIN CHECK IF USER HAS VOTED TODAY
             //AND IF USER IS CONFIRMED
             /////////////////////

             $query = "SELECT photo_id,voter_id,timestamp FROM votes WHERE voter_id=$user_id and YEAR(DATE(timestamp))=YEAR(DATE(NOW())) and DAYOFYEAR(DATE(timestamp))=DAYOFYEAR(DATE(NOW()))";
             $result = @mysql_query($query);
             if(@mysql_num_rows($result) < 3) { //VOTES PER DAY
                 $voteButton = true;
                 $ip=$_SERVER["REMOTE_ADDR"];
                 $query = "INSERT INTO votes VALUES($pid,$user_id,NOW(),INET_ATON('$ip'))"; //DECODE IP WITH INET_NTOA($ip);
                 $result = mysql_query($query);
                 $value = 1;
                 echo $value;
             } else {
                 $value = 2;
                 echo $value;
             }

 

This script is accessed via Ajax, and it seems that people have been voting more than 3 times per day but I cannot figure out how it is possible. Anyone see a flaw?

Link to comment
https://forums.phpfreaks.com/topic/179891-voting-flaw/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.