post.php: use modern array syntax

This commit is contained in:
Zankaria 2024-11-27 17:27:46 +01:00
parent b88c876222
commit b8af67a5e2

View file

@ -407,7 +407,7 @@ function handle_nntpchan()
error("NNTPChan: Forbidden. $_SERVER[REMOTE_ADDR] is not a trusted peer"); error("NNTPChan: Forbidden. $_SERVER[REMOTE_ADDR] is not a trusted peer");
} }
$_POST = array(); $_POST = [];
$_POST['json_response'] = true; $_POST['json_response'] = true;
$headers = json_encode($_GET); $headers = json_encode($_GET);
@ -483,7 +483,7 @@ function handle_nntpchan()
$content = ''; $content = '';
$newfiles = array(); $newfiles = [];
foreach ($_FILES['attachment']['error'] as $id => $error) { foreach ($_FILES['attachment']['error'] as $id => $error) {
if ($_FILES['attachment']['type'][$id] == 'text/plain') { if ($_FILES['attachment']['type'][$id] == 'text/plain') {
$content .= file_get_contents($_FILES['attachment']['tmp_name'][$id]); $content .= file_get_contents($_FILES['attachment']['tmp_name'][$id]);
@ -491,7 +491,7 @@ function handle_nntpchan()
// Signed message, ignore for now // Signed message, ignore for now
} else { } else {
// A real attachment :^) // A real attachment :^)
$file = array(); $file = [];
$file['name'] = $_FILES['attachment']['name'][$id]; $file['name'] = $_FILES['attachment']['name'][$id];
$file['type'] = $_FILES['attachment']['type'][$id]; $file['type'] = $_FILES['attachment']['type'][$id];
$file['size'] = $_FILES['attachment']['size'][$id]; $file['size'] = $_FILES['attachment']['size'][$id];
@ -535,7 +535,7 @@ function handle_nntpchan()
if (count($ary) == 0) { if (count($ary) == 0) {
return ">>>>$id"; return ">>>>$id";
} else { } else {
$ret = array(); $ret = [];
foreach ($ary as $v) { foreach ($ary as $v) {
if ($v['board'] != $xboard) { if ($v['board'] != $xboard) {
$ret[] = ">>>/" . $v['board'] . "/" . $v['id']; $ret[] = ">>>/" . $v['board'] . "/" . $v['id'];
@ -580,7 +580,7 @@ function handle_delete()
error($config['error']['invalidpassword']); error($config['error']['invalidpassword']);
} }
$delete = array(); $delete = [];
foreach ($_POST as $post => $value) { foreach ($_POST as $post => $value) {
if (preg_match('/^delete_(\d+)$/', $post, $m)) { if (preg_match('/^delete_(\d+)$/', $post, $m)) {
$delete[] = (int) $m[1]; $delete[] = (int) $m[1];
@ -688,7 +688,7 @@ function handle_report()
if (!isset($_POST['board'], $_POST['reason'])) if (!isset($_POST['board'], $_POST['reason']))
error($config['error']['bot']); error($config['error']['bot']);
$report = array(); $report = [];
foreach ($_POST as $post => $value) { foreach ($_POST as $post => $value) {
if (preg_match('/^delete_(\d+)$/', $post, $m)) { if (preg_match('/^delete_(\d+)$/', $post, $m)) {
$report[] = (int) $m[1]; $report[] = (int) $m[1];
@ -839,7 +839,7 @@ function handle_post()
error($config['error']['bot']); error($config['error']['bot']);
} }
$post = array('board' => $_POST['board'], 'files' => array()); $post = array('board' => $_POST['board'], 'files' => []);
// Check if board exists // Check if board exists
if (!openBoard($post['board'])) { if (!openBoard($post['board'])) {
@ -1513,7 +1513,7 @@ function handle_post()
// getting all images and then choosing one. // getting all images and then choosing one.
for( $i = 0; $i < $zip->numFiles; $i++ ){ for( $i = 0; $i < $zip->numFiles; $i++ ){
$stat = $zip->statIndex( $i ); $stat = $zip->statIndex( $i );
$matches = array(); $matches = [];
if (preg_match('/.*cover.*\.(jpg|jpeg|png)/', $stat['name'], $matches)) { if (preg_match('/.*cover.*\.(jpg|jpeg|png)/', $stat['name'], $matches)) {
$filename = $matches[0]; $filename = $matches[0];
break; break;
@ -1764,7 +1764,7 @@ function handle_post()
} }
if (isset($post['tracked_cites']) && !empty($post['tracked_cites'])) { if (isset($post['tracked_cites']) && !empty($post['tracked_cites'])) {
$insert_rows = array(); $insert_rows = [];
foreach ($post['tracked_cites'] as $cite) { foreach ($post['tracked_cites'] as $cite) {
$insert_rows[] = '(' . $insert_rows[] = '(' .
$pdo->quote($board['uri']) . ', ' . (int) $id . ', ' . $pdo->quote($board['uri']) . ', ' . (int) $id . ', ' .
@ -1782,7 +1782,7 @@ function handle_post()
if (isset($_COOKIE[$config['cookies']['js']])) { if (isset($_COOKIE[$config['cookies']['js']])) {
$js = json_decode($_COOKIE[$config['cookies']['js']]); $js = json_decode($_COOKIE[$config['cookies']['js']]);
} else { } else {
$js = (object) array(); $js = (object) [];
} }
// Tell it to delete the cached post for referer // Tell it to delete the cached post for referer
$js->{$_SERVER['HTTP_REFERER']} = true; $js->{$_SERVER['HTTP_REFERER']} = true;