forked from leftypol/leftypol
Handle reporting non-existing posts. Fix #96
This commit is contained in:
parent
5709513cb7
commit
e496fb10a5
|
@ -1170,6 +1170,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.');
|
||||
|
@ -1991,4 +1992,3 @@
|
|||
|
||||
//Logo location for themes
|
||||
$config['logo'] = 'static/logo.png';
|
||||
|
||||
|
|
28
post.php
28
post.php
|
@ -123,24 +123,24 @@ function db_select_thread_with_attributes($board, $thread_id)
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the threads with the given id in the given board.
|
||||
* Get the post with the given id in the given board.
|
||||
*
|
||||
* @param string $board Board to search in. MUST ALREADY BE SANITIZED.
|
||||
* @param int $thread_id Id of the thread.
|
||||
* @return false|array Returns false if no thread exists. Otherwise, an array of arrays with the threads 'id', 'thread'
|
||||
* and 'body_nomarkup' properties.
|
||||
* @param int $id Id of the post.
|
||||
* @return false|array Returns false if no post exists. Otherwise, an array with the post's 'id', 'thread' and
|
||||
* 'body_nomarkup' keys.
|
||||
*/
|
||||
function db_select_threads_minimal($board, $thread_id)
|
||||
function db_select_post_minimal($board, $id)
|
||||
{
|
||||
$query = prepare(sprintf("SELECT `id`, `thread`, `body_nomarkup` FROM ``posts_%s`` WHERE `id` = :id", $board));
|
||||
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
$threads = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$post = $query->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$threads) {
|
||||
if (!$post) {
|
||||
return false;
|
||||
}
|
||||
return $threads;
|
||||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -536,7 +536,13 @@ function handle_report()
|
|||
markup($reason);
|
||||
|
||||
foreach ($report as $id) {
|
||||
$thread = db_select_threads_minimal($board['uri'], $id);
|
||||
$post = db_select_post_minimal($board['uri'], $id);
|
||||
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($thread)));
|
||||
if ($error) {
|
||||
|
@ -547,7 +553,7 @@ function handle_report()
|
|||
_syslog(
|
||||
LOG_INFO,
|
||||
'Reported post: ' .
|
||||
'/' . $board['dir'] . $config['dir']['res'] . link_for($thread) . ($thread['thread'] ? '#' . $id : '') .
|
||||
'/' . $board['dir'] . $config['dir']['res'] . link_for($post) . ($post['thread'] ? '#' . $id : '') .
|
||||
' for "' . $reason . '"'
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user