diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2019-11-16 00:24:28 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-16 00:24:28 +1000 |
| commit | 3a0c97b3d42a5476810590a20ab27e66aa0c2cac (patch) | |
| tree | 6b97aa70356fef1f30a25a972ee46cef8b77b1b5 | |
| parent | 1792bf48eec755ee9a07aa5bef5fbf1e27d406c4 (diff) | |
| parent | 3bd53e6caecf875a531070f427d72d93e281c835 (diff) | |
Merge pull request #174 from gamer551/master
#173 flood bump
| -rw-r--r-- | inc/config.php | 3 | ||||
| -rwxr-xr-x | inc/functions.php | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/inc/config.php b/inc/config.php index 3ac0c995..7c7d870d 100644 --- a/inc/config.php +++ b/inc/config.php @@ -221,6 +221,9 @@ // Skip checking certain IP addresses against blacklists (for troubleshooting or whatever) $config['dnsbl_exceptions'][] = '127.0.0.1'; + // To prevent bump atacks; returns the thread to last position after the last post is deleted. + $config['anti_bump_flood'] = false; + /* * Introduction to Tinyboard's spam filter: * 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(); |
