summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VNDB/DB/Discussions.pm22
-rw-r--r--lib/VNDB/Handler/Discussions.pm3
-rw-r--r--lib/VNDB/Util/FormHTML.pm1
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index 58cc5f61..eed1b2f9 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Exporter 'import';
-our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPostAdd dbThreadCount|;
+our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPostAdd dbThreadCount dbPostCheckDouble|;
# Options: id, type, iid, results, page, what, notusers
@@ -241,5 +241,25 @@ sub dbPostAdd {
}
+# Checks if a user has recently made a post in a particular thread
+# If tid is omitted or equal to zero, check if user has made a recent post at all
+# uid, tid (optional)
+sub dbPostCheckDouble {
+ my($self, @o) = @_;
+
+ my $time = time - 30; # 30 Seconds
+ my $r;
+ if (defined $o[1] && $o[1] ne 0) {
+ $r = $self->dbRow('SELECT COUNT(num) FROM threads_posts WHERE uid = ? AND tid = ? AND date > ? LIMIT 1',
+ @o, $time);
+ } else {
+ $r = $self->dbRow('SELECT COUNT(num) FROM threads_posts WHERE uid = ? AND date > ? LIMIT 1',
+ $o[0], $time);
+ }
+
+ return $r->{count}||0;
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm
index eff8212e..dce8dcde 100644
--- a/lib/VNDB/Handler/Discussions.pm
+++ b/lib/VNDB/Handler/Discussions.pm
@@ -166,6 +166,9 @@ sub edit {
{ name => 'msg', maxlenght => 5000 },
);
+ # check for double-posting
+ push @{$frm->{_err}}, 'doublepost' if $self->dbPostCheckDouble($self->{_auth}{id}, $tid);
+
# parse and validate the boards
my @boards;
if(!$frm->{_err} && $frm->{boards}) {
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index dfb9a91f..f8047c4c 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -54,6 +54,7 @@ my %formerr_exeptions = (
toolarge => 'Image is too large, only 500kB allowed',
oneaday => 'You can only register one account from the same IP within 24 hours',
nochanges => 'No changes, please don\'t create an entry that is fully -identical- to another',
+ doublepost => 'Please wait 30 seconds before making another post',
);