|
|
@ -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 . '"' |
|
|
|
); |
|
|
|
|
|
|
|