From f7fd639d2dbc8af1aaabc35a5eda2c00919c3d18 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Mon, 4 Nov 2024 23:10:54 +0100 Subject: [PATCH] pages.php: use modern array syntax --- inc/mod/pages.php | 72 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index b9956eb7..ddf977d9 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -99,7 +99,7 @@ function mod_logout() { function mod_dashboard() { global $config, $mod; - $args = array(); + $args = []; $args['boards'] = listBoards(); @@ -239,7 +239,7 @@ function mod_search($type, $search_query_escaped, $page_no = 1) { $query = str_replace('`', '!`', $query); // Array of phrases to match - $match = array(); + $match = []; // Exact phrases ("like this") if (preg_match_all('/"(.+?)"/', $query, $exact_phrases)) { @@ -772,7 +772,7 @@ function mod_board_log($board, $page_no = 1, $hide_names = false, $public = fals function mod_view_catalog($boardName) { global $config, $mod; require_once($config['dir']['themes'].'/catalog/theme.php'); - $settings = array(); + $settings = []; $settings['boards'] = $boardName; $settings['update_on_posts'] = true; $settings['title'] = 'Catalog'; @@ -1109,7 +1109,7 @@ function mod_bans() { if (!hasPermission($config['mod']['unban'])) error($config['error']['noaccess']); - $unban = array(); + $unban = []; foreach ($_POST as $name => $unused) { if (preg_match('/^ban_(\d+)$/', $name, $match)) $unban[] = $match[1]; @@ -1198,16 +1198,16 @@ function mod_ban_appeals() { $query = query(sprintf("SELECT `num_files`, `files` FROM ``posts_%s`` WHERE `id` = " . (int)$ban['post']['id'], $board['uri'])); if ($_post = $query->fetch(PDO::FETCH_ASSOC)) { - $_post['files'] = $_post['files'] ? json_decode($_post['files']) : array(); + $_post['files'] = $_post['files'] ? json_decode($_post['files']) : []; $ban['post'] = array_merge($ban['post'], $_post); } else { - $ban['post']['files'] = array(array()); + $ban['post']['files'] = array([]); $ban['post']['files'][0]['file'] = 'deleted'; $ban['post']['files'][0]['thumb'] = false; $ban['post']['num_files'] = 1; } } else { - $ban['post']['files'] = array(array()); + $ban['post']['files'] = array([]); $ban['post']['files'][0]['file'] = 'deleted'; $ban['post']['files'][0]['thumb'] = false; $ban['post']['num_files'] = 1; @@ -1505,7 +1505,7 @@ function mod_move($originBoard, $postID) { $query->bindValue(':id', $postID, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $replies = array(); + $replies = []; while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $post['mod'] = true; @@ -1572,7 +1572,7 @@ function mod_move($originBoard, $postID) { if (!empty($post['tracked_cites'])) { - $insert_rows = array(); + $insert_rows = []; foreach ($post['tracked_cites'] as $cite) { $insert_rows[] = '(' . $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' . @@ -1770,7 +1770,7 @@ function mod_merge($originBoard, $postID) { $query->bindValue(':id', $postID, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $replies = array(); + $replies = []; while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $post['mod'] = true; @@ -1833,7 +1833,7 @@ function mod_merge($originBoard, $postID) { if (!empty($post['tracked_cites'])) { - $insert_rows = array(); + $insert_rows = []; foreach ($post['tracked_cites'] as $cite) { $insert_rows[] = '(' . $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' . @@ -1954,7 +1954,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { $name = $mypost["name"]; $subject = $mypost["subject"]; $filehash = $mypost["filehash"]; - $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : array(); + $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : []; // For each file append file name for ($file_count = 0; $file_count < $mypost["num_files"];$file_count++){ $filename .= $mypost['files'][$file_count]->name . "\r\n"; @@ -2065,7 +2065,7 @@ function mod_warning_post($board,$post, $token = false) { $name = $mypost["name"]; $subject = $mypost["subject"]; $filehash = $mypost["filehash"]; - $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : array(); + $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : []; // For each file append file name for ($file_count = 0; $file_count < $mypost["num_files"];$file_count++){ $filename .= $mypost['files'][$file_count]->name . "\r\n"; @@ -2217,7 +2217,7 @@ function mod_delete($board, $post) { $name = $mypost["name"]; $subject = $mypost["subject"]; $filehash = $mypost["filehash"]; - $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : array(); + $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : []; // For each file append file name for ($file_count = 0; $file_count < $mypost["num_files"];$file_count++){ $filename .= $mypost['files'][$file_count]->name . "\r\n"; @@ -2364,9 +2364,9 @@ function mod_deletebyip($boardName, $post, $global = false) { @set_time_limit($config['mod']['rebuild_timelimit']); - $boards_to_rebuild = array(); - $threads_to_rebuild = array(); - $threads_deleted = array(); + $boards_to_rebuild = []; + $threads_to_rebuild = []; + $threads_deleted = []; while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $boards_to_rebuild[$post['board']] = true; openBoard($post['board']); @@ -2388,7 +2388,7 @@ function mod_deletebyip($boardName, $post, $global = false) { $name = $mypost["name"]; $subject = $mypost["subject"]; $filehash = $mypost["filehash"]; - $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : array(); + $mypost['files'] = $mypost['files'] ? json_decode($mypost['files']) : []; // For each file append file name for ($file_count = 0; $file_count < $mypost["num_files"];$file_count++){ $filename .= $mypost['files'][$file_count]->name . "\r\n"; @@ -2466,7 +2466,7 @@ function mod_user($uid) { $board = $board['uri']; } - $boards = array(); + $boards = []; foreach ($_POST as $name => $value) { if (preg_match('/^board_(' . $config['board_regex'] . ')$/u', $name, $matches) && in_array($matches[1], $_boards)) $boards[] = $matches[1]; @@ -2557,7 +2557,7 @@ function mod_user($uid) { $query->execute() or error(db_error($query)); $log = $query->fetchAll(PDO::FETCH_ASSOC); } else { - $log = array(); + $log = []; } $user['boards'] = explode(',', $user['boards']); @@ -2590,7 +2590,7 @@ function mod_user_new() { $board = $board['uri']; } - $boards = array(); + $boards = []; foreach ($_POST as $name => $value) { if (preg_match('/^board_(' . $config['board_regex'] . ')$/u', $name, $matches) && in_array($matches[1], $_boards)) $boards[] = $matches[1]; @@ -2823,9 +2823,9 @@ function mod_rebuild() { if (isset($_POST['rebuild'])) { @set_time_limit($config['mod']['rebuild_timelimit']); - $log = array(); + $log = []; $boards = listBoards(); - $rebuilt_scripts = array(); + $rebuilt_scripts = []; if (isset($_POST['rebuild_cache'])) { if ($config['cache']['enabled']) { @@ -2897,16 +2897,16 @@ function mod_reports() { $query->execute() or error(db_error($query)); $reports = $query->fetchAll(PDO::FETCH_ASSOC); - $report_queries = array(); + $report_queries = []; foreach ($reports as $report) { if (!isset($report_queries[$report['board']])) - $report_queries[$report['board']] = array(); + $report_queries[$report['board']] = []; $report_queries[$report['board']][] = $report['post']; } - $report_posts = array(); + $report_posts = []; foreach ($report_queries as $board => $posts) { - $report_posts[$board] = array(); + $report_posts[$board] = []; $query = query(sprintf('SELECT * FROM ``posts_%s`` WHERE `id` = ' . implode(' OR `id` = ', $posts), $board)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { @@ -2918,7 +2918,7 @@ function mod_reports() { $body = ''; foreach ($reports as $report) { if (!isset($report_posts[$report['board']][$report['post']])) { - // // Invalid report (post has since been deleted) + // Invalid report (post has since been deleted) $query = prepare("DELETE FROM ``reports`` WHERE `post` = :id AND `board` = :board"); $query->bindValue(':id', $report['post'], PDO::PARAM_INT); $query->bindValue(':board', $report['board']); @@ -3014,7 +3014,7 @@ function mod_recent_posts($lim,$board_list = false,$json=false) { $limit = (is_numeric($lim))? $lim : 25; $last_time = (isset($_GET['last']) && is_numeric($_GET['last'])) ? $_GET['last'] : 0; - $mod_boards = array(); + $mod_boards = []; $boards = listBoards(); //if not all boards @@ -3028,7 +3028,7 @@ function mod_recent_posts($lim,$board_list = false,$json=false) { } if ($board_list != false){ $board_array = explode(",",$board_list); - $new_board_array = array(); + $new_board_array = []; foreach ($board_array as $board) { if (array_key_exists($board,$config['boards_alias'])){ $newboard = $config['boards_alias'][$board]; @@ -3038,7 +3038,7 @@ function mod_recent_posts($lim,$board_list = false,$json=false) { } $new_board_array[] = $newboard; } - $mod_boards = array(); + $mod_boards = []; foreach ($boards as $board) { if (in_array($board['uri'], $new_board_array)){ $mod_boards[] = $board; @@ -3059,7 +3059,7 @@ function mod_recent_posts($lim,$board_list = false,$json=false) { $posts = $query->fetchAll(PDO::FETCH_ASSOC); if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } foreach ($posts as &$post) { @@ -3215,7 +3215,7 @@ function mod_config($board_config = false) { if ($config['minify_html']) $config_append = str_replace("\n", ' ', $config_append); - $page = array(); + $page = []; $page['title'] = 'Cannot write to file!'; $page['config'] = $config; $page['body'] = ' @@ -3258,7 +3258,7 @@ function mod_themes_list() { $themes_in_use = $query->fetchAll(PDO::FETCH_COLUMN); // Scan directory for themes - $themes = array(); + $themes = []; while ($file = readdir($dir)) { if ($file[0] != '.' && is_dir($config['dir']['themes'] . '/' . $file)) { $themes[$file] = loadThemeConfig($file); @@ -3553,7 +3553,7 @@ function mod_pages($board = false) { function mod_debug_antispam() { global $pdo, $config; - $args = array(); + $args = []; if (isset($_POST['board'], $_POST['thread'])) { $where = '`board` = ' . $pdo->quote($_POST['board']); @@ -3657,7 +3657,7 @@ function mod_debug_apc() { $cache_info = apc_cache_info('user'); // $cached_vars = new APCIterator('user', '/^' . $config['cache']['prefix'] . '/'); - $cached_vars = array(); + $cached_vars = []; foreach ($cache_info['cache_list'] as $var) { if ($config['cache']['prefix'] != '' && strpos(isset($var['key']) ? $var['key'] : $var['info'], $config['cache']['prefix']) !== 0) continue;