From 1c0551edadee3629c5ee7bf73ca13d61f0c30afa Mon Sep 17 00:00:00 2001 From: gamer551 <46283343+gamer551@users.noreply.github.com> Date: Fri, 15 Nov 2019 17:25:09 +0400 Subject: [PATCH] anti bump flood (#173) --- inc/functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 07585b2c..23b61404 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1201,6 +1201,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { while ($post = $query->fetch(PDO::FETCH_ASSOC)) { event('delete', $post); + $thread_id = $post['thread']; if (!$post['thread']) { // Delete thread HTML page file_unlink($board['dir'] . $config['dir']['res'] . link_for($post) ); @@ -1252,6 +1253,17 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { $query->bindValue(':board', $board['uri']); $query->execute() or error(db_error($query)); + if ($config['anti_bump_flood']) { + $query = prepare(sprintf("SELECT `time` FROM ``posts_%s`` WHERE (`thread` = :thread OR `id` = :thread) AND `sage` = 0 ORDER BY `time` DESC LIMIT 1", $board['uri'])); + $query->bindValue(':thread', $thread_id); + $query->execute() or error(db_error($query)); + $bump = $query->fetchColumn(); + $query = prepare(sprintf("UPDATE ``posts_%s`` SET `bump` = :bump WHERE `id` = :thread", $board['uri'])); + $query->bindValue(':bump', $bump); + $query->bindValue(':thread', $thread_id); + $query->execute() or error(db_error($query)); + } + if (isset($rebuild) && $rebuild_after) { buildThread($rebuild); buildIndex();