Hi,
This is my attempt at a patch for a bug related to users being able to vote multiple times on the same bug (full report is at https://bugs.php.net/bug.php?id=51535). While this isn't a huge change I wanted to get confirmation on a few things before I went ahead so that I didn't break anything too badly.

1. Is this the correct list for changes related to bugs.php.net itself? If
   not, what is the correct mailing list for this change?

2. I see php-src has a defined coding standard however I wasn't able
   to see one for bugs.php.net so I have just gone with the standards that
   were already present near my changes. If there is a defined
   standards guideline which I have missed, feel free to direct me that
   way and I will check for any violations within my changes before this
   is merged.

3. Hannes was nice enough to give me some direction around getting my
   changes reviewed however with code changes is the preferred option to
   get review and merge it yourself? Or is there a release cycle? Or how
   does that aspect work?

I've attached the patch and opened a pull request via GitHub (https://github.com/php/web-bugs/pull/13) for anyone that would like to review this one for me.

Thanks again,
Jacob.
From 90b07aee49ea4227c82f80a0136e21695126633b Mon Sep 17 00:00:00 2001
From: Jacob Bednarz <jacob.bedn...@gmail.com>
Date: Wed, 31 Dec 2014 07:41:55 +1000
Subject: [PATCH] Prevent users from adding multiple votes on a single bug

---
 www/bug.php  |  3 +++
 www/vote.php | 10 ++++++++++
 2 files changed, 13 insertions(+)

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)
-- 
2.2.1

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to