From 03a875f663f5509ff0b16ddb19a71fdeea8d1a2b Mon Sep 17 00:00:00 2001 From: Zankaria Date: Mon, 1 Apr 2024 19:20:23 +0200 Subject: [PATCH] Handle reporting non-existing posts. --- inc/config.php | 1 + post.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/inc/config.php b/inc/config.php index 9140201c..0cece593 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1187,6 +1187,7 @@ $config['error']['fileext'] = _('Unsupported image format.'); $config['error']['noboard'] = _('Invalid board!'); $config['error']['nonexistant'] = _('Thread specified does not exist.'); + $config['error']['nopost'] = _('Post specified does not exist.'); $config['error']['locked'] = _('Thread locked. You may not reply at this time.'); $config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.'); $config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.'); diff --git a/post.php b/post.php index e22171ea..2cc99071 100644 --- a/post.php +++ b/post.php @@ -519,6 +519,12 @@ if (isset($_POST['delete'])) { $query->execute() or error(db_error($query)); $post = $query->fetch(PDO::FETCH_ASSOC); + if ($post === false) { + if ($config['syslog']) { + _syslog(LOG_INFO, "Failed to report non-existing post #{$id} in {$board['dir']}"); + } + error($config['error']['nopost']); + } $error = event('report', array('ip' => $_SERVER['REMOTE_ADDR'], 'board' => $board['uri'], 'post' => $post, 'reason' => $reason, 'link' => link_for($post))); if ($error) {