--- lib/MT/App/Trackback.pm.orig Thu Jan 15 17:41:46 2004 +++ lib/MT/App/Trackback.pm Mon Jan 19 11:11:16 2004 @@ -157,6 +157,38 @@ $app->translate("You are not allowed to send TrackBack pings.")); } } +## Do some simple throttling + my @ts = MT::Util::offset_time_list(time - 3599, $tb->blog_id); + my $from = sprintf("%04d%02d%02d%02d%02d%02d", + $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); + + my $count = MT::TBPing->count({ blog_id => $tb->blog_id, created_on => [$from] }, + { range => {created_on => 1}}); + my $maxpings = 20; + if ($count >= $maxpings) + { + $app->log("Throttled comment. Limit of $maxpings trackbacks in the last hour."); + return $app->_response(Error =>"Too many Trackbacks +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 Trackback again later. Sorry."); + } + @ts = MT::Util::offset_time_list(time - 86399, $tb->blog_id); + $from = sprintf("%04d%02d%02d%02d%02d%02d", + $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]); + + $count = MT::TBPing->count({ blog_id => $tb->blog_id, created_on => [$from] }, + { range => {created_on => 1}}); + $maxpings = 100; + if ($count >= $maxpings) + { + $app->log("Throttled comment. Limit of $maxpings Trackbacks in the last day."); + return $app->_response(Error => "Too many Trackbacks +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 Trackback again later. Sorry."); + } + ## Check if user has pinged recently #my @past = MT::TBPing->load({ tb_id => $tb_id, ip => $host_ip });