forked from leftypol/leftypol
Merge branch 'config' into display-appeal-src-ip
This commit is contained in:
commit
5f1f7319a3
211 changed files with 697 additions and 494 deletions
54
post.php
54
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -537,9 +537,21 @@ 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)));
|
||||
$error = event('report', [
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'board' => $board['uri'],
|
||||
'post' => $post,
|
||||
'reason' => $reason,
|
||||
'link' => link_for($post)
|
||||
]);
|
||||
if ($error) {
|
||||
error($error);
|
||||
}
|
||||
|
@ -548,7 +560,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 . '"'
|
||||
);
|
||||
|
||||
|
@ -579,20 +591,20 @@ function handle_report()
|
|||
return $result;
|
||||
}
|
||||
|
||||
$postcontent = mb_substr($thread['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
|
||||
$slackmessage = '<' . $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($thread['thread'] ? $thread['thread'] : $id) . ".html" . ($thread['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
|
||||
$postcontent = mb_substr($post['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
|
||||
$slackmessage = '<' . $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($post['thread'] ? $post['thread'] : $id) . ".html" . ($post['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
|
||||
|
||||
$slackresult = slack($slackmessage, $config['slack_channel']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($config['matrix'])) {
|
||||
$reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($thread['thread'] ? $thread['thread'] : $id) . ".html";
|
||||
$reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($post['thread'] ? $post['thread'] : $id) . ".html";
|
||||
$post_url = $config['matrix']['host'] . "/_matrix/client/r0/rooms/" . $config['matrix']['room_id'] . "/send/m.room.message?access_token=" . $config['matrix']['access_token'];
|
||||
|
||||
$trimmed_post = strlen($thread['body_nomarkup']) > $config['matrix']['max_message_length'] ? ' [...]' : '';
|
||||
$postcontent = mb_substr($thread['body_nomarkup'], 0, $config['matrix']['max_message_length']) . $trimmed_post;
|
||||
$matrix_message = $reported_post_url . ($thread['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n";
|
||||
$trimmed_post = strlen($post['body_nomarkup']) > $config['matrix']['max_message_length'] ? ' [...]' : '';
|
||||
$postcontent = mb_substr($post['body_nomarkup'], 0, $config['matrix']['max_message_length']) . $trimmed_post;
|
||||
$matrix_message = $reported_post_url . ($post['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n";
|
||||
$post_data = json_encode(
|
||||
array(
|
||||
"msgtype" => "m.text",
|
||||
|
@ -1147,7 +1159,7 @@ function handle_post()
|
|||
if (!$size = @getimagesize($file['tmp_name'])) {
|
||||
error($config['error']['invalidimg']);
|
||||
}
|
||||
if (!in_array($size[2], array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_BMP))) {
|
||||
if (!in_array($size[2], [IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_WEBP, IMAGETYPE_JPEG, IMAGETYPE_BMP])) {
|
||||
error($config['error']['invalidimg']);
|
||||
}
|
||||
if ($size[0] > $config['max_width'] || $size[1] > $config['max_height']) {
|
||||
|
@ -1240,10 +1252,10 @@ function handle_post()
|
|||
$thumb->_destroy();
|
||||
}
|
||||
|
||||
if ($config['redraw_image'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg'))) {
|
||||
if ($config['redraw_image'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg' || $file['extension'] == 'webp' || $file['extension'] == 'png'))) {
|
||||
if (!$config['redraw_image'] && $config['use_exiftool']) {
|
||||
if (
|
||||
$error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' .
|
||||
$error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= -Orientation ' .
|
||||
escapeshellarg($file['tmp_name']))
|
||||
) {
|
||||
error(_('Could not strip EXIF metadata!'), null, $error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue