diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-28 17:08:56 +1000 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-28 17:08:56 +1000 |
| commit | dc8b1948ddb75ac9a620f1146ce2b19627de4222 (patch) | |
| tree | 67b04eb698571cd22a3c4d272985c81bc222e056 /inc | |
| parent | a7ac3339def8d07d825d64f33e8ca69c21dd2743 (diff) | |
Performance: Only purge old antispam hashes once per request (at most)
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/anti-bot.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/inc/anti-bot.php b/inc/anti-bot.php index fde97096..41e0a1d6 100644 --- a/inc/anti-bot.php +++ b/inc/anti-bot.php @@ -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'); |
