com web/bugs: Prevent users from adding multiple votes on a single bug: www/bug.php www/vote.php
| From: | jacob@php.net | Date: | Wed, 31 Dec 2014 10:09:55 +0000 |
| Subject: | com web/bugs: Prevent users from adding multiple votes on a single bug: www/bug.php www/vote.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-20495@lists.php.net to get a copy of this message | ||
Commit: 90b07aee49ea4227c82f80a0136e21695126633b
Author: Jacob Bednarz <jacob.bednarz@gmail.com> Wed, 31 Dec 2014 07:41:55 +1000
Parents: 9612686ee3cfc0b0f529a596d75abdfb7e58f44d
Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=90b07aee49ea4227c82f80a0136e21695126633b
Log:
Prevent users from adding multiple votes on a single bug
Changed paths:
M www/bug.php
M www/vote.php
Diff:
diff --git a/www/bug.php b/www/bug.php
index d8f8398..4f73455 100644
--- a/www/bug.php
+++ b/www/bug.php
@@ -601,6 +601,9 @@ switch ($thanks)
case 9:
display_bug_success('You have successfully unsubscribed.');
break;
+ case 10:
+ display_bug_success('You have already voted on this bug.');
+ break;
default:
break;
diff --git a/www/vote.php b/www/vote.php
index 12d2ac5..536ff55 100644
--- a/www/vote.php
+++ b/www/vote.php
@@ -55,6 +55,16 @@ function get_real_ip ()
$ip = ip2long(get_real_ip());
// TODO: check if ip address has been banned. hopefully this will never need to be implemented.
+// Check whether the user has already voted on this bug.
+$bug_check = $dbh->prepare("SELECT bug, ip FROM bugdb_votes WHERE bug = ? AND ip = ? LIMIT
1")
+ ->execute(array($id, $ip))
+ ->fetchRow();
+
+if (!empty($bug_check)) {
+ // Let the user know they have already voted.
+ redirect("bug.php?id=$id&thanks=10");
+}
+
// add the vote
$dbh->prepare("
INSERT INTO bugdb_votes (bug,ip,score,reproduced,tried,sameos,samever)