PDA

View Full Version : Rate-limiting new thread creation


mute
02-14-2003, 11:26 AM
We disabled Guest posting on our board, but we occasionally get idiots who like to spam/flood the board by creating a multitude of new posts/threads.

The posts don't bother me so much as a million new threads, so I was wondering if anyone knew of a hack that would limit registered users to N new thread creations per hour (or some other time period).

I thought something along the lines of 5 new threads per hour wouldn't inconvienience anyone, but would keep the flooding to a minimum.

Anyone know if i just missed such a hack in the db?

filburt1
02-14-2003, 12:14 PM
You can already limit the time between posts in the admin CP unless you only want threads to be limited in which case I think you do need a hack.

mute
02-14-2003, 12:19 PM
Yeah, I don't actually wanna limit posting, just thread creation.

I think I have it nailed down.

mysql> select dateline,postusername from thread where dateline > UNIX_TIMESTAMP(NOW())-3600 and postusername = 'John-PB2X';

+------------+--------------+
| dateline | postusername |
+------------+--------------+
| 1045231378 | John-PB2X |
| 1045231443 | John-PB2X |
+------------+--------------+
2 rows in set (0.67 sec)

Thats just for some user I noticed was currently posting.

I think I can do something similar to that in the newthread.php and have it work..

mute
02-14-2003, 12:59 PM
This is what I came up with (in newthread.php)



// new thread creation rate-limiting
if ($enablefloodcheck) {
$lastthreads=$DB_site->query("SELECT dateline FROM thread WHERE dateline > UNIX_TIMESTAMP(NOW())-3600 AND postusername='$bbu
serinfo[username]'");
$lastthreads=$DB_site->num_rows($lastthreads);
if ($bbuserinfo[userid]!=0 and $lastthreads>=5 and !ismoderator($foruminfo[forumid])) {
eval("standarderror(\"".gettemplate("error_threadcheck")."\");");
exit;
}
}


All i have to do now is make an error_threadcheck template