1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-25 16:00:22 +01:00

Performance: Only purge old antispam hashes once per request (at most)

This commit is contained in:
Michael Foster 2013-08-28 17:08:56 +10:00
parent dab10e4889
commit f2bd33e345

View File

@ -178,11 +178,14 @@ class AntiBot {
}
function _create_antibot($board, $thread) {
global $config;
global $config, $purged_old_antispam;
$antibot = new AntiBot(array($board, $thread));
query('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error());
if (!isset($purged_old_antispam)) {
$purged_old_antispam = true;
query('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error());
}
if ($thread)
$query = prepare('UPDATE ``antispam`` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE `board` = :board AND `thread` = :thread AND `expires` IS NULL');