diff --git a/inc/anti-bot.php b/inc/anti-bot.php index e2687148..d41be3e0 100644 --- a/inc/anti-bot.php +++ b/inc/anti-bot.php @@ -196,9 +196,9 @@ function _create_antibot($board, $thread) { $antibot = new AntiBot(array($board, $thread)); // Delete old expired antispam, skipping those with NULL expiration timestamps (infinite lifetime). - if (!isset($purged_old_antispam)) { + if (!isset($purged_old_antispam) && $config['auto_maintenance']) { $purged_old_antispam = true; - query('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error()); + purge_old_antispam(); } // Keep the now invalid timestamps around for a bit to enable users to post if they're still on an old version of @@ -224,3 +224,9 @@ function _create_antibot($board, $thread) { return $antibot; } + +function purge_old_antispam() { + $query = prepare('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()'); + $query->execute() or error(db_error()); + return $query->rowCount(); +}