Used new-style [] array constructions in some cases (#1111)

* Used new-style [] array constructions in some cases

* Used new-style [] array constructions in some cases
This commit is contained in:
Roman Kelesidis 2023-11-17 14:43:38 +07:00 committed by GitHub
commit a77b32e2ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 42 deletions

View file

@ -5,6 +5,7 @@
**Merged pull requests:** **Merged pull requests:**
- Used new-style [] array constructions in some cases [\#1111](https://github.com/torrentpier/torrentpier/pull/1111) ([belomaxorka](https://github.com/belomaxorka))
- Use http_response_code() functions instead of old header() functions [\#1110](https://github.com/torrentpier/torrentpier/pull/1110) ([belomaxorka](https://github.com/belomaxorka)) - Use http_response_code() functions instead of old header() functions [\#1110](https://github.com/torrentpier/torrentpier/pull/1110) ([belomaxorka](https://github.com/belomaxorka))
- Fix bypassing cache if IP changed while using cache [\#1109](https://github.com/torrentpier/torrentpier/pull/1109) ([kovalensky](https://github.com/kovalensky)) - Fix bypassing cache if IP changed while using cache [\#1109](https://github.com/torrentpier/torrentpier/pull/1109) ([kovalensky](https://github.com/kovalensky))
- Use one variable to determine update status for hybrids [\#1108](https://github.com/torrentpier/torrentpier/pull/1108) ([kovalensky](https://github.com/kovalensky)) - Use one variable to determine update status for hybrids [\#1108](https://github.com/torrentpier/torrentpier/pull/1108) ([kovalensky](https://github.com/kovalensky))

View file

@ -126,11 +126,11 @@ $forum_rows = DB()->fetch_rowset('SELECT * FROM ' . BB_FORUMS . " $forum_sql");
if (empty($forum_id)) { if (empty($forum_id)) {
// Output the selection table if no forum id was specified // Output the selection table if no forum id was specified
$template->assign_vars(array( $template->assign_vars([
'TPL_AUTH_SELECT_FORUM' => true, 'TPL_AUTH_SELECT_FORUM' => true,
'S_AUTH_ACTION' => 'admin_forumauth.php', 'S_AUTH_ACTION' => 'admin_forumauth.php',
'S_AUTH_SELECT' => get_forum_select('admin', 'f', null, 80), 'S_AUTH_SELECT' => get_forum_select('admin', 'f', null, 80),
)); ]);
} else { } else {
// Output the authorisation details if an id was specified // Output the authorisation details if an id was specified
$forum_name = reset($forum_rows)['forum_name']; $forum_name = reset($forum_rows)['forum_name'];
@ -171,10 +171,10 @@ if (empty($forum_id)) {
$simple_auth .= '</select>'; $simple_auth .= '</select>';
$template->assign_block_vars('forum_auth', array( $template->assign_block_vars('forum_auth', [
'CELL_TITLE' => $lang['SIMPLE_MODE'], 'CELL_TITLE' => $lang['SIMPLE_MODE'],
'S_AUTH_LEVELS_SELECT' => $simple_auth, 'S_AUTH_LEVELS_SELECT' => $simple_auth,
)); ]);
$s_column_span++; $s_column_span++;
} else { } else {
@ -190,10 +190,10 @@ if (empty($forum_id)) {
$cell_title = $field_names[$forum_auth_fields[$j]]; $cell_title = $field_names[$forum_auth_fields[$j]];
$template->assign_block_vars('forum_auth', array( $template->assign_block_vars('forum_auth', [
'CELL_TITLE' => $cell_title, 'CELL_TITLE' => $cell_title,
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j], 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j],
)); ]);
$s_column_span++; $s_column_span++;
} }
@ -206,7 +206,7 @@ if (empty($forum_id)) {
$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">'; $s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
$template->assign_vars(array( $template->assign_vars([
'TPL_EDIT_FORUM_AUTH' => true, 'TPL_EDIT_FORUM_AUTH' => true,
'FORUM_NAME' => htmlCHR($forum_name), 'FORUM_NAME' => htmlCHR($forum_name),
'U_VIEWFORUM' => BB_ROOT . FORUM_URL . $forum_id, 'U_VIEWFORUM' => BB_ROOT . FORUM_URL . $forum_id,
@ -214,7 +214,7 @@ if (empty($forum_id)) {
'S_FORUMAUTH_ACTION' => 'admin_forumauth.php', 'S_FORUMAUTH_ACTION' => 'admin_forumauth.php',
'S_COLUMN_SPAN' => $s_column_span, 'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_HIDDEN_FIELDS' => $s_hidden_fields,
)); ]);
} }
print_page('admin_forumauth.tpl', 'admin'); print_page('admin_forumauth.tpl', 'admin');

View file

@ -32,20 +32,20 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
// Get modules from cache // Get modules from cache
$module = CACHE('bb_cache')->get('admin_module_' . $user->id); $module = CACHE('bb_cache')->get('admin_module_' . $user->id);
$template->assign_vars(array( $template->assign_vars([
'TPL_ADMIN_NAVIGATE' => true, 'TPL_ADMIN_NAVIGATE' => true,
'U_FORUM_INDEX' => '../index.php', 'U_FORUM_INDEX' => '../index.php',
'U_ADMIN_INDEX' => 'index.php?pane=right', 'U_ADMIN_INDEX' => 'index.php?pane=right',
)); ]);
ksort($module); ksort($module);
foreach ($module as $cat => $action_array) { foreach ($module as $cat => $action_array) {
$cat = (!empty($lang[$cat])) ? $lang[$cat] : str_replace("_", ' ', $cat); $cat = (!empty($lang[$cat])) ? $lang[$cat] : str_replace("_", ' ', $cat);
$template->assign_block_vars('catrow', array( $template->assign_block_vars('catrow', [
'ADMIN_CATEGORY' => $cat, 'ADMIN_CATEGORY' => $cat,
)); ]);
ksort($action_array); ksort($action_array);
@ -55,20 +55,20 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$action = (!empty($lang[$action])) ? $lang[$action] : str_replace("_", ' ', $action); $action = (!empty($lang[$action])) ? $lang[$action] : str_replace("_", ' ', $action);
$template->assign_block_vars('catrow.modulerow', array( $template->assign_block_vars('catrow.modulerow', [
'ROW_CLASS' => $row_class, 'ROW_CLASS' => $row_class,
'ADMIN_MODULE' => $action, 'ADMIN_MODULE' => $action,
'U_ADMIN_MODULE' => $file, 'U_ADMIN_MODULE' => $file,
)); ]);
$row_count++; $row_count++;
} }
} }
} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') { } elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
$template->assign_vars(array( $template->assign_vars([
'TPL_ADMIN_MAIN' => true, 'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => (bool)$bb_cfg['board_disable'], 'ADMIN_LOCK' => (bool)$bb_cfg['board_disable'],
'ADMIN_LOCK_CRON' => file_exists(BB_DISABLED), 'ADMIN_LOCK_CRON' => file_exists(BB_DISABLED),
)); ]);
// Get forum statistics // Get forum statistics
$total_posts = get_db_stat('postcount'); $total_posts = get_db_stat('postcount');
@ -108,7 +108,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$users_per_day = $total_users; $users_per_day = $total_users;
} }
$template->assign_vars(array( $template->assign_vars([
'NUMBER_OF_POSTS' => $total_posts, 'NUMBER_OF_POSTS' => $total_posts,
'NUMBER_OF_TOPICS' => $total_topics, 'NUMBER_OF_TOPICS' => $total_topics,
'NUMBER_OF_USERS' => $total_users, 'NUMBER_OF_USERS' => $total_users,
@ -117,12 +117,12 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
'TOPICS_PER_DAY' => $topics_per_day, 'TOPICS_PER_DAY' => $topics_per_day,
'USERS_PER_DAY' => $users_per_day, 'USERS_PER_DAY' => $users_per_day,
'AVATAR_DIR_SIZE' => $avatar_dir_size, 'AVATAR_DIR_SIZE' => $avatar_dir_size,
)); ]);
if (isset($_GET['users_online'])) { if (isset($_GET['users_online'])) {
$template->assign_vars(array( $template->assign_vars([
'SHOW_USERS_ONLINE' => true, 'SHOW_USERS_ONLINE' => true,
)); ]);
// Get users online information. // Get users online information.
$sql = 'SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start $sql = 'SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
@ -157,14 +157,14 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$row_class = 'row1'; $row_class = 'row1';
$reg_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($onlinerow_reg[$i]['session_ip']); $reg_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($onlinerow_reg[$i]['session_ip']);
$template->assign_block_vars('reg_user_row', array( $template->assign_block_vars('reg_user_row', [
'ROW_CLASS' => $row_class, 'ROW_CLASS' => $row_class,
'USER' => profile_url($onlinerow_reg[$i]), 'USER' => profile_url($onlinerow_reg[$i]),
'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false), 'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false), 'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false),
'IP_ADDRESS' => $reg_ip, 'IP_ADDRESS' => $reg_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip, 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip,
)); ]);
} }
} }
@ -177,26 +177,26 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$row_class = 'row2'; $row_class = 'row2';
$guest_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($onlinerow_guest[$i]['session_ip']); $guest_ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($onlinerow_guest[$i]['session_ip']);
$template->assign_block_vars('guest_user_row', array( $template->assign_block_vars('guest_user_row', [
'ROW_CLASS' => $row_class, 'ROW_CLASS' => $row_class,
'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false), 'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i', false), 'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i', false),
'IP_ADDRESS' => $guest_ip, 'IP_ADDRESS' => $guest_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip, 'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip,
)); ]);
} }
} }
} else { } else {
$template->assign_vars(array( $template->assign_vars([
'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1', 'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
)); ]);
} }
} else { } else {
// Generate frameset // Generate frameset
$template->assign_vars(array( $template->assign_vars([
'CONTENT_ENCODING' => $bb_cfg['charset'], 'CONTENT_ENCODING' => $bb_cfg['charset'],
'TPL_ADMIN_FRAMESET' => true, 'TPL_ADMIN_FRAMESET' => true,
)); ]);
send_no_cache_headers(); send_no_cache_headers();
print_page('index.tpl', 'admin', 'no_header'); print_page('index.tpl', 'admin', 'no_header');
} }

View file

@ -366,12 +366,12 @@ if ($forum_data['allow_reg_tracker']) {
} }
// Post URL generation for templating vars // Post URL generation for templating vars
$template->assign_vars(array( $template->assign_vars([
'U_POST_NEW_TOPIC' => $post_new_topic_url, 'U_POST_NEW_TOPIC' => $post_new_topic_url,
'S_SELECT_TOPIC_DAYS' => build_select('topicdays', array_flip($sel_previous_days), $topic_days), 'S_SELECT_TOPIC_DAYS' => build_select('topicdays', array_flip($sel_previous_days), $topic_days),
'S_POST_DAYS_ACTION' => FORUM_URL . "$forum_id&amp;start=$start", 'S_POST_DAYS_ACTION' => FORUM_URL . "$forum_id&amp;start=$start",
'S_DISPLAY_ORDER' => $s_display_order, 'S_DISPLAY_ORDER' => $s_display_order,
)); ]);
// User authorisation levels output // User authorisation levels output
$u_auth = []; $u_auth = [];
@ -385,7 +385,7 @@ $u_auth[] = ($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['R
$u_auth[] = ($is_auth['auth_mod']) ? $lang['RULES_MODERATE'] : ''; $u_auth[] = ($is_auth['auth_mod']) ? $lang['RULES_MODERATE'] : '';
$u_auth = implode("<br />\n", $u_auth); $u_auth = implode("<br />\n", $u_auth);
$template->assign_vars(array( $template->assign_vars([
'PAGE_TITLE' => htmlCHR($forum_data['forum_name']), 'PAGE_TITLE' => htmlCHR($forum_data['forum_name']),
'FORUM_ID' => $forum_id, 'FORUM_ID' => $forum_id,
'FORUM_NAME' => htmlCHR($forum_data['forum_name']), 'FORUM_NAME' => htmlCHR($forum_data['forum_name']),
@ -411,7 +411,7 @@ $template->assign_vars(array(
'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'U_VIEW_FORUM' => FORUM_URL . $forum_id,
'U_MARK_READ' => FORUM_URL . $forum_id . "&amp;mark=topics", 'U_MARK_READ' => FORUM_URL . $forum_id . "&amp;mark=topics",
'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&f=$forum_id", 'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&f=$forum_id",
)); ]);
// Okay, lets dump out the page ... // Okay, lets dump out the page ...
$found_topics = 0; $found_topics = 0;
@ -437,7 +437,7 @@ foreach ($topic_rowset as $topic) {
} }
} }
$template->assign_block_vars('t', array( $template->assign_block_vars('t', [
'FORUM_ID' => $forum_id, 'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id, 'TOPIC_ID' => $topic_id,
'HREF_TOPIC_ID' => ($moved) ? $topic['topic_moved_id'] : $topic['topic_id'], 'HREF_TOPIC_ID' => ($moved) ? $topic['topic_moved_id'] : $topic['topic_id'],
@ -462,23 +462,23 @@ foreach ($topic_rowset as $topic) {
'POLL' => $topic['topic_vote'], 'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',
'TOPIC_AUTHOR' => profile_url(array('username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank'])), 'TOPIC_AUTHOR' => profile_url(['username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank']]),
'LAST_POSTER' => profile_url(array('username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank'])), 'LAST_POSTER' => profile_url(['username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank']]),
'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']),
'LAST_POST_ID' => $topic['topic_last_post_id'], 'LAST_POST_ID' => $topic['topic_last_post_id'],
)); ]);
if (isset($topic['tor_size'])) { if (isset($topic['tor_size'])) {
$tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_ent_decode($topic['topic_title'])); $tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_ent_decode($topic['topic_title']));
$template->assign_block_vars('t.tor', array( $template->assign_block_vars('t.tor', [
'SEEDERS' => (int)$topic['seeders'], 'SEEDERS' => (int)$topic['seeders'],
'LEECHERS' => (int)$topic['leechers'], 'LEECHERS' => (int)$topic['leechers'],
'TOR_SIZE' => humn_size($topic['tor_size']), 'TOR_SIZE' => humn_size($topic['tor_size']),
'COMPL_CNT' => (int)$topic['complete_count'], 'COMPL_CNT' => (int)$topic['complete_count'],
'ATTACH_ID' => $topic['attach_id'], 'ATTACH_ID' => $topic['attach_id'],
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
)); ]);
} }
$found_topics++; $found_topics++;
} }
@ -503,12 +503,12 @@ if ($found_topics) {
} else { } else {
$no_topics_msg = ($topic_days || $title_match) ? $lang['NO_SEARCH_MATCH'] : ($forum_data['allow_reg_tracker'] ? $lang['NO_RELEASES_POST_ONE'] : $lang['NO_TOPICS_POST_ONE']); $no_topics_msg = ($topic_days || $title_match) ? $lang['NO_SEARCH_MATCH'] : ($forum_data['allow_reg_tracker'] ? $lang['NO_RELEASES_POST_ONE'] : $lang['NO_TOPICS_POST_ONE']);
} }
$template->assign_vars(array( $template->assign_vars([
'NO_TOPICS' => $no_topics_msg, 'NO_TOPICS' => $no_topics_msg,
)); ]);
} }
$template->assign_vars(array( $template->assign_vars([
'PAGE_URL' => $pg_url, 'PAGE_URL' => $pg_url,
'PAGE_URL_TPP' => url_arg($pg_url, 'tpp', null), 'PAGE_URL_TPP' => url_arg($pg_url, 'tpp', null),
'FOUND_TOPICS' => $found_topics, 'FOUND_TOPICS' => $found_topics,
@ -524,6 +524,6 @@ $template->assign_vars(array(
'U_VIEWCAT' => CAT_URL . $forum_data['cat_id'], 'U_VIEWCAT' => CAT_URL . $forum_data['cat_id'],
'PARENT_FORUM_HREF' => ($parent_id = $forum_data['forum_parent']) ? FORUM_URL . $forum_data['forum_parent'] : '', 'PARENT_FORUM_HREF' => ($parent_id = $forum_data['forum_parent']) ? FORUM_URL . $forum_data['forum_parent'] : '',
'PARENT_FORUM_NAME' => ($parent_id = $forum_data['forum_parent']) ? $forums['forum_name_html'][$parent_id] : '', 'PARENT_FORUM_NAME' => ($parent_id = $forum_data['forum_parent']) ? $forums['forum_name_html'][$parent_id] : '',
)); ]);
print_page('viewforum.tpl'); print_page('viewforum.tpl');