--- lib/MT/App/Comments.pm.orig Thu Jan 15 17:41:46 2004 +++ lib/MT/App/Comments.pm Sun Jan 18 20:39:22 2004 @@ -74,7 +76,7 @@ $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); require MT::Comment; - if (MT::Comment->count({ ip => $user_ip, + if (MT::Comment->count({ blog_id => $entry->blog_id, ip => $user_ip, created_on => [$from] }, {range => {created_on => 1} })) { @@ -94,7 +96,7 @@ $entry->blog_id); $from = sprintf("%04d%02d%02d%02d%02d%02d", $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); - my $count = MT::Comment->count({ ip => $user_ip, + my $count = MT::Comment->count({ blog_id => $entry->blog_id, ip => $user_ip, created_on => [$from] }, { range => {created_on => 1}}); if ($count >= 8) @@ -135,6 +137,38 @@ } return $app->handle_error($app->translate("In an effort to curb malicious comment posting by abusive users, I've enabled a feature that requires a weblog commenter to wait a short amount of time before being able to post again. Please try to post your comment again in a short while. Thanks for your patience."), "403 Throttled"); } + @ts = MT::Util::offset_time_list(time - 3599, + $entry->blog_id); + $from = sprintf("%04d%02d%02d%02d%02d%02d", + $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); + + $count = MT::Comment->count({ blog_id => $entry->blog_id, created_on => [$from] }, + { range => {created_on => 1}}); + my $maxcomments = 20; + if ($count >= $maxcomments) + { + $app->log("Throttled comment. Limit of $maxcomments comments in the last hour."); + return $app->handle_error($app->translate("Too many comments +have been posted in the last hour. Someone may be crapflooding this +blog. Or we may just have become insanely popular. Either way, please +try your comment again later. Sorry."), "403 Throttled"); + } + @ts = MT::Util::offset_time_list(time - 86399, + $entry->blog_id); + $from = sprintf("%04d%02d%02d%02d%02d%02d", + $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); + + $count = MT::Comment->count({ blog_id => $entry->blog_id, created_on => [$from] }, + { range => {created_on => 1}}); + $maxcomments = 100; + if ($count >= $maxcomments) + { + $app->log("Throttled comment. Limit of $maxcomments comments in the last day."); + return $app->handle_error($app->translate("Too many comments +have been posted in the past 24 hours. Someone may be crapflooding this +blog. Or we may just have become insanely popular. Either way, please +try your comment again later. Sorry."), "403 Throttled"); + } if (my $state = $q->param('comment_state')) { require MT::Serialize;