[Cpan-forum-commit] rev 111 - in trunk: lib/CPAN lib/CPAN/Forum
templates
svn at pti.co.il
svn at pti.co.il
Tue Feb 8 21:48:07 IST 2005
Author: gabor
Date: 2005-02-08 21:48:06 +0200 (Tue, 08 Feb 2005)
New Revision: 111
Modified:
trunk/lib/CPAN/Forum.pm
trunk/lib/CPAN/Forum/Configure.pm
trunk/templates/editor.tmpl
Log:
implement a flood control time period
Modified: trunk/lib/CPAN/Forum/Configure.pm
===================================================================
--- trunk/lib/CPAN/Forum/Configure.pm 2005-02-08 19:08:36 UTC (rev 110)
+++ trunk/lib/CPAN/Forum/Configure.pm 2005-02-08 19:48:06 UTC (rev 111)
@@ -6,12 +6,17 @@
__PACKAGE__->table('configure');
__PACKAGE__->columns(All => qw/field value/);
+my %default = (
+ flood_control_time_limit => 10,
+);
+
sub param {
my ($self, $field, $value) = @_;
my ($handle) = CPAN::Forum::Configure->search({field => $field});
return $handle->value if $handle;
+ return $default{$field} if defined $default{$field};
return;
}
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2005-02-08 19:08:36 UTC (rev 110)
+++ trunk/lib/CPAN/Forum.pm 2005-02-08 19:48:06 UTC (rev 111)
@@ -1394,6 +1394,27 @@
push @errors, "no_text" if not $new_text;
push @errors, "subject_too_long" if $new_subject and length($new_subject) > 50;
+
+ $self->log->debug("username: " .
+ $self->session->param("username") .
+ " uid: " .
+ $self->session->param("uid"));
+
+ my $button = $q->param("button");
+ # BUG: we are putting in the usernames instead of the user ids in the uid field of the posts
+ # but for this reason we'll have to use the username in every other place
+ if (not @errors and $button eq "Submit") {
+ my ($last_post) = CPAN::Forum::Posts->search(uid => $self->session->param("username"), {order_by => 'id DESC', limit => 1});
+ if ($last_post) {
+ $self->log->debug("username: " .
+ $self->session->param("username") .
+ " last post: " . $last_post->date . " now: " . time());
+ if ($last_post->date > time() - $self->config("flood_control_time_limit")) {
+ push @errors, "flood_control";
+ }
+ }
+ }
+
return $self->posts(\@errors) if @errors;
@@ -1412,7 +1433,6 @@
}
- my $button = $q->param("button");
if ($button eq "Preview") {
return $self->posts(["preview"]);
}
Modified: trunk/templates/editor.tmpl
===================================================================
--- trunk/templates/editor.tmpl 2005-02-08 19:08:36 UTC (rev 110)
+++ trunk/templates/editor.tmpl 2005-02-08 19:48:06 UTC (rev 111)
@@ -8,6 +8,8 @@
<TMPL_IF bad_group>Bad distribution name<br /></TMPL_IF>
<TMPL_IF bad_data>Bad data<br /></TMPL_IF>
<TMPL_IF subject_too_long>Subject must be up to 50 characters.<br /></TMPL_IF>
+ <TMPL_IF flood_control>Trying to submit posts too quickly.
+ Please wait 10 more seconds before posting again.</TMPL_IF>
<TMPL_IF text_format>Text format is not correct. As we are still in development
this might be either a bug or on purpose. If after reading again the rules of posting
at the bottom of this page you still think your post should work, please send a copy of
More information about the Cpan-forum-commit
mailing list