From 997babeee0ed9cd00639c64a443d5eaccefee539 Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Sun, 13 Aug 2023 23:14:41 -0700 Subject: [PATCH] add hourly thread limit (from npfchan) --- inc/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 7c9b35bf..a3461128 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -3067,3 +3067,16 @@ function uncloak_mask($mask) { return $mask; } + +function check_thread_limit($post) { + global $config, $board; + if (!isset($config['max_threads_per_hour']) || !$config['max_threads_per_hour']) return false; + + if ($post['op']) { + $query = prepare(sprintf('SELECT COUNT(*) AS `count` FROM ``posts_%s`` WHERE `thread` IS NULL AND FROM_UNIXTIME(`time`) > DATE_SUB(NOW(), INTERVAL 1 HOUR);', $board['uri'])); + $query->execute() or error(db_error($query)); + $r = $query->fetch(PDO::FETCH_ASSOC); + + return $r['count'] >= $config['max_threads_per_hour']; + } +}