diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index 8502372b1..e9d54f642 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -56,7 +56,7 @@ if ($view === 'username') { $sort_order = 'DESC'; } else { $view = 'stats'; - $mode_types_text = array(); + $mode_types_text = []; $sort_order = 'ASC'; } @@ -148,7 +148,7 @@ $delete_id_list = get_var('delete_id_list', array(0)); $confirm = isset($_POST['confirm']); if ($confirm && count($delete_id_list) > 0) { - $attachments = array(); + $attachments = []; delete_attachment(0, $delete_id_list); } elseif ($delete && count($delete_id_list) > 0) { @@ -181,7 +181,7 @@ if ($submit_change && $view === 'attachments') { $attach_download_count_list = get_var('attach_count_list', array(0)); // Generate correct Change List - $attachments = array(); + $attachments = []; for ($i = 0, $iMax = count($attach_change_list); $i < $iMax; $i++) { $attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i]; @@ -330,7 +330,7 @@ if ($view === 'attachments') { $s_hidden = ''; - $template->assign_block_vars('switch_user_based', array()); + $template->assign_block_vars('switch_user_based', []); $template->assign_vars(array( 'S_USER_HIDDEN' => $s_hidden, @@ -356,7 +356,7 @@ if ($view === 'attachments') { $total_rows = $num_attach_ids; - $attach_id = array(); + $attach_id = []; for ($j = 0; $j < $num_attach_ids; $j++) { $attach_id[] = (int)$attach_ids[$j]['attach_id']; @@ -427,7 +427,7 @@ if ($view === 'attachments') { $post_title = str_short($post_title, 30); } - $view_topic = BB_ROOT . 'viewtopic.php?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id']; + $view_topic = BB_ROOT . POST_URL . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id']; $post_titles[] = '' . $post_title . ''; } else { diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index 64ba92967..38f9527ea 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -171,7 +171,7 @@ if ($search_imagick) { // Check Settings if ($check_upload) { // Some tests... - $attach_config = array(); + $attach_config = []; $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; @@ -266,7 +266,7 @@ if ($mode == 'cats') { $sql = 'SELECT group_name, cat_id FROM ' . BB_EXTENSION_GROUPS . ' WHERE cat_id > 0 ORDER BY cat_id'; - $s_assigned_group_images = array(); + $s_assigned_group_images = []; if (!($result = DB()->sql_query($sql))) { bb_die('Could not get group names from ' . BB_EXTENSION_GROUPS); @@ -294,7 +294,7 @@ if ($mode == 'cats') { if (!is_imagick() && !@extension_loaded('gd')) { $new_attach['img_create_thumbnail'] = '0'; } else { - $template->assign_block_vars('switch_thumbnail_support', array()); + $template->assign_block_vars('switch_thumbnail_support', []); } $template->assign_vars(array( @@ -319,7 +319,7 @@ if ($mode == 'cats') { // Check Cat Settings if ($check_image_cat) { // Some tests... - $attach_config = array(); + $attach_config = []; $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; @@ -386,7 +386,7 @@ if ($submit && $mode == 'quota') { $filesize_list = get_var('max_filesize_list', array(0)); $size_select_list = get_var('size_select_list', array('')); - $allowed_list = array(); + $allowed_list = []; for ($i = 0, $iMax = count($quota_change_list); $i < $iMax; $i++) { $filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]); @@ -519,7 +519,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota') { bb_die('Invalid call'); } - $template->assign_block_vars('switch_quota_limit_desc', array()); + $template->assign_block_vars('switch_quota_limit_desc', []); $sql = 'SELECT * FROM ' . BB_QUOTA_LIMITS . ' WHERE quota_limit_id = ' . (int)$quota_id . ' LIMIT 1'; diff --git a/admin/admin_cron.php b/admin/admin_cron.php index e51c31087..4d036550c 100644 --- a/admin/admin_cron.php +++ b/admin/admin_cron.php @@ -148,7 +148,7 @@ switch ($mode) { $run_day[$i] = $i; } - $schedule = array(); + $schedule = []; foreach ($lang['SCHEDULE'] as $type => $key) { $schedule[$key] = $type; } diff --git a/admin/admin_extensions.php b/admin/admin_extensions.php index a7529b93a..7d6f4e6f3 100644 --- a/admin/admin_extensions.php +++ b/admin/admin_extensions.php @@ -48,7 +48,7 @@ $delete_forum = isset($_POST['del_forum']); $submit = isset($_POST['submit']); // Get Attachment Config -$attach_config = array(); +$attach_config = []; $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; @@ -69,7 +69,7 @@ if ($submit && $mode == 'extensions') { $group_select_list = get_var('group_select', array(0)); // Generate correct Change List - $extensions = array(); + $extensions = []; for ($i = 0, $iMax = count($extension_change_list); $i < $iMax; $i++) { $extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i]; @@ -236,7 +236,7 @@ if ($submit && $mode == 'groups') { $filesize_list = get_var('max_filesize_list', array(0)); $size_select_list = get_var('size_select_list', array('')); - $allowed_list = array(); + $allowed_list = []; foreach ($group_allowed_list as $iValue) { for ($j = 0, $jMax = count($group_change_list); $j < $jMax; $j++) { @@ -485,7 +485,7 @@ if ($add_forum && $e_mode == 'perm' && $group) { DB()->sql_freeresult($result); if (trim($row['forum_permissions']) == '') { - $auth_p = array(); + $auth_p = []; } else { $auth_p = auth_unpack($row['forum_permissions']); } @@ -525,7 +525,7 @@ if ($delete_forum && $e_mode == 'perm' && $group) { DB()->sql_freeresult($result); $auth_p2 = auth_unpack(trim($row['forum_permissions'])); - $auth_p = array(); + $auth_p = []; // Generate array for Auth_Pack, delete the chosen ones foreach ($auth_p2 as $i => $iValue) { @@ -560,13 +560,13 @@ if ($e_mode == 'perm' && $group) { $group_name = $row['group_name']; $allowed_forums = trim($row['forum_permissions']); - $forum_perm = array(); + $forum_perm = []; if ($allowed_forums == '') { $forum_perm[0]['forum_id'] = 0; $forum_perm[0]['forum_name'] = $lang['PERM_ALL_FORUMS']; } else { - $forum_p = array(); + $forum_p = []; $act_id = 0; $forum_p = auth_unpack($allowed_forums); $sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' WHERE forum_id IN (' . implode(', ', $forum_p) . ')'; @@ -614,7 +614,7 @@ if ($e_mode == 'perm' && $group) { ); } - $empty_perm_forums = array(); + $empty_perm_forums = []; $sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' WHERE auth_attachments < ' . AUTH_ADMIN; diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 8ec6ad8f2..fc40979d5 100644 --- a/admin/admin_forums.php +++ b/admin/admin_forums.php @@ -693,7 +693,7 @@ if (!$mode || $show_main_page) { } // Okay, let's build the index - $gen_cat = array(); + $gen_cat = []; $bgr_class_1 = 'prow1'; $bgr_class_2 = 'prow2'; @@ -923,7 +923,7 @@ function renumber_order($mode, $cat = 0) */ function get_cat_forums($cat_id = false) { - $forums = array(); + $forums = []; $where_sql = ''; if ($cat_id = (int)$cat_id) { @@ -1019,7 +1019,7 @@ function get_orphan_sf() global $cat_forums; $last_root = 0; - $bad_sf_ary = array(); + $bad_sf_ary = []; foreach ($cat_forums as $cid => $c) { foreach ($c['f'] as $fid => $f) { diff --git a/admin/admin_log.php b/admin/admin_log.php index 976b0ac54..b99070354 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -205,7 +205,7 @@ if ($log_count == $per_page + 1) { generate_pagination($url, $items_count, $per_page, $start); -$filter = array(); +$filter = []; if ($log_rowset) { $log_type = $log_action->log_type; @@ -323,7 +323,7 @@ if ($log_rowset) { 'FILTER_USERS' => !empty($filter['users']), )); } else { - $template->assign_block_vars('log_not_found', array()); + $template->assign_block_vars('log_not_found', []); } // Select diff --git a/admin/admin_rebuild_search.php b/admin/admin_rebuild_search.php index e8e7bf5d4..3b0ca7704 100644 --- a/admin/admin_rebuild_search.php +++ b/admin/admin_rebuild_search.php @@ -157,7 +157,7 @@ if ($mode == 'submit' || $mode == 'refresh') { $expire_time = $start_time + $time_limit - 5; $start_post_id = $end_post_id = $num_rows = 0; $timer_expired = false; - $words_sql = array(); + $words_sql = []; while ($row = DB()->fetch_next($result) and !$timer_expired) { set_time_limit(600); @@ -367,7 +367,7 @@ if ($mode == 'submit' || $mode == 'refresh') { $last_saved_processing = sprintf($lang['INFO_PROCESSING_STOPPED'], $last_saved_post_id, $total_posts_processed, $last_saved_date); $clear_search_disabled = 'disabled'; - $template->assign_block_vars('start_select_input', array()); + $template->assign_block_vars('start_select_input', []); } elseif ($last_session_data['rebuild_session_status'] == REBUILD_SEARCH_ABORTED) { $last_saved_processing = sprintf($lang['INFO_PROCESSING_ABORTED'], $last_saved_post_id, $total_posts_processed, $last_saved_date); // check if the interrupted cycle has finished @@ -376,7 +376,7 @@ if ($mode == 'submit' || $mode == 'refresh') { } $clear_search_disabled = 'disabled'; - $template->assign_block_vars('start_select_input', array()); + $template->assign_block_vars('start_select_input', []); } else { // when finished @@ -384,17 +384,17 @@ if ($mode == 'submit' || $mode == 'refresh') { $last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED_NEW'], $last_saved_post_id, $total_posts_processed, $last_saved_date, $total_posts - $total_posts_processed); $clear_search_disabled = 'disabled'; - $template->assign_block_vars('start_select_input', array()); + $template->assign_block_vars('start_select_input', []); } else { $last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED'], $total_posts, $last_saved_date); - $template->assign_block_vars('start_text_input', array()); + $template->assign_block_vars('start_text_input', []); } } - $template->assign_block_vars('last_saved_info', array()); + $template->assign_block_vars('last_saved_info', []); } else { - $template->assign_block_vars('start_text_input', array()); + $template->assign_block_vars('start_text_input', []); } // create the output of page diff --git a/admin/admin_sitemap.php b/admin/admin_sitemap.php index fe2a43018..ce845017f 100644 --- a/admin/admin_sitemap.php +++ b/admin/admin_sitemap.php @@ -19,7 +19,7 @@ $sql = 'SELECT * FROM ' . BB_CONFIG; if (!$result = DB()->sql_query($sql)) { bb_die('Could not query config information in admin_sitemap'); } else { - $new_params = array(); + $new_params = []; while ($row = DB()->sql_fetchrow($result)) { $config_name = $row['config_name']; diff --git a/admin/admin_ug_auth.php b/admin/admin_ug_auth.php index a2cc7beb5..f027a6542 100644 --- a/admin/admin_ug_auth.php +++ b/admin/admin_ug_auth.php @@ -26,7 +26,7 @@ $cat_id = isset($_REQUEST['c']) ? (int)$_REQUEST['c'] : 0; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; $submit = isset($_REQUEST['submit']); -$group_data = array(); +$group_data = []; $forum_auth_fields = array( 'auth_view', @@ -108,7 +108,7 @@ if ($submit && $mode == 'user') { // // Submit new USER permissions // - $auth = array(); + $auth = []; if (!empty($_POST['auth']) && is_array($_POST['auth'])) { array_deep($_POST['auth'], 'intval'); @@ -139,7 +139,7 @@ elseif ($submit && $mode == 'group' && (!empty($_POST['auth']) && is_array($_POS bb_die($lang['GROUP_NOT_EXIST']); } - $auth = array(); + $auth = []; array_deep($_POST['auth'], 'intval'); foreach ($_POST['auth'] as $f_id => $bf_ary) { @@ -185,8 +185,8 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) { $ug_data = $this_userdata; $ug_data['session_logged_in'] = 1; - $u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_USER_ONLY); - $g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_GROUP_ONLY); + $u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, [], UG_PERM_USER_ONLY); + $g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, [], UG_PERM_GROUP_ONLY); foreach ($forums['c'] as $c_id => $c_data) { $template->assign_block_vars('c', array( @@ -276,7 +276,7 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) { '; - $template->assign_block_vars('switch_user_auth', array()); + $template->assign_block_vars('switch_user_auth', []); $template->assign_vars(array( 'TPL_AUTH_UG_MAIN' => true, diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php index 12950df83..db4530569 100644 --- a/admin/admin_user_search.php +++ b/admin/admin_user_search.php @@ -31,7 +31,7 @@ if (!isset($_REQUEST['dosearch'])) { $group_list = ''; if (DB()->num_rows($result) != 0) { - $template->assign_block_vars('groups_exist', array()); + $template->assign_block_vars('groups_exist', []); while ($row = DB()->sql_fetchrow($result)) { $group_list .= ''; @@ -44,7 +44,7 @@ if (!isset($_REQUEST['dosearch'])) { } $rank_select_box = ''; if (DB()->num_rows($result) != 0) { - $template->assign_block_vars('ranks_exist', array()); + $template->assign_block_vars('ranks_exist', []); while ($row = DB()->sql_fetchrow($result)) { $rank = $row['rank_title']; $rank_id = $row['rank_id']; @@ -63,10 +63,10 @@ if (!isset($_REQUEST['dosearch'])) { bb_die('Could not select forum data'); } - $forums = array(); + $forums = []; if (DB()->num_rows($result) != 0) { - $template->assign_block_vars('forums_exist', array()); + $template->assign_block_vars('forums_exist', []); $last_cat_id = -1; $forums_list = ''; @@ -912,7 +912,7 @@ if (!isset($_REQUEST['dosearch'])) { unset($banned); - $banned = array(); + $banned = []; while ($row = DB()->sql_fetchrow($result)) { $banned[$row['user_id']] = true; diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index e2e465e43..1573029ff 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -22,7 +22,7 @@ $peers_in_last_minutes = [30, 15, 5, 1]; $peers_in_last_sec_limit = 300; $announce_interval = (int)$bb_cfg['announce_interval']; -$stat = array(); +$stat = []; define('TMP_TRACKER_TABLE', 'tmp_tracker'); @@ -59,7 +59,7 @@ $stat += DB()->fetch_row('SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FRO $stat += DB()->fetch_row('SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM ' . BB_BT_TORRENTS); // Last xx minutes -$peers_in_last_min = array(); +$peers_in_last_min = []; foreach ($peers_in_last_minutes as $t) { $row = DB()->fetch_row(' SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' WHERE update_time >= ' . (TIMENOW - 60 * $t) . ' @@ -67,7 +67,7 @@ foreach ($peers_in_last_minutes as $t) { $peers_in_last_min[$t] = (int)$row['peers']; } // Last xx seconds -$peers_in_last_sec = array(); +$peers_in_last_sec = []; $rowset = DB()->fetch_rowset('SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' GROUP BY update_time ORDER BY update_time DESC LIMIT ' . $peers_in_last_sec_limit); foreach ($rowset as $cnt => $row) { $peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : ''); diff --git a/common.php b/common.php index 784dbe4ed..1772762a5 100644 --- a/common.php +++ b/common.php @@ -91,7 +91,7 @@ if (file_exists(BB_PATH . '/library/config.local.php')) { * Server variables initialize */ $server_protocol = $bb_cfg['cookie_secure'] ? 'https://' : 'http://'; -$server_port = in_array((int)$bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port']; +$server_port = in_array((int)$bb_cfg['server_port'], [80, 443], true) ? '' : ':' . $bb_cfg['server_port']; define('FORUM_PATH', $bb_cfg['script_path']); define('FULL_URL', $server_protocol . $bb_cfg['server_name'] . $server_port . $bb_cfg['script_path']); unset($server_protocol, $server_port); @@ -152,11 +152,11 @@ switch ($bb_cfg['datastore_type']) { break; case 'sqlite': - $default_cfg = array( + $default_cfg = [ 'db_file_path' => $bb_cfg['cache']['db_dir'] . 'datastore.sqlite.db', 'pconnect' => true, 'con_required' => true, - ); + ]; $datastore = new TorrentPier\Legacy\Datastore\Sqlite($default_cfg, $bb_cfg['cache']['prefix']); break; @@ -265,7 +265,7 @@ function verify_id($id, $length): bool function clean_filename($fname) { - static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' '); + static $s = ['\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ']; return str_replace($s, '_', str_compact($fname)); } diff --git a/dl.php b/dl.php index 5f3a903f5..6c1efd2bd 100644 --- a/dl.php +++ b/dl.php @@ -13,10 +13,10 @@ define('NO_GZIP', true); require __DIR__ . '/common.php'; require ATTACH_DIR . '/attachment_mod.php'; -$datastore->enqueue(array( +$datastore->enqueue([ 'attach_extensions', - 'cat_forums', -)); + 'cat_forums' +]); $download_id = request_var('id', 0); $thumbnail = request_var('thumb', 0); @@ -194,9 +194,7 @@ if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) { $message .= ''; $message .= ''; - $template->assign_vars(array( - 'ERROR_MESSAGE' => $message, - )); + $template->assign_vars(['ERROR_MESSAGE' => $message]); require(PAGE_HEADER); require(PAGE_FOOTER); diff --git a/dl_list.php b/dl_list.php index 1e0607e1e..49fdf830a 100644 --- a/dl_list.php +++ b/dl_list.php @@ -78,16 +78,16 @@ if ($mode == 'dl_delete' && $topic_id) { } if (!$confirmed) { - $hidden_fields = array( + $hidden_fields = [ 't' => $topic_id, 'mode' => 'dl_delete', - ); + ]; - print_confirmation(array( + print_confirmation([ 'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'], 'FORM_ACTION' => 'dl_list.php', 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), - )); + ]); } clear_dl_list($topic_id); @@ -95,7 +95,7 @@ if ($mode == 'dl_delete' && $topic_id) { } // Update DL status -$req_topics_ary = $topics_ary = array(); +$req_topics_ary = $topics_ary = []; // Get topics selected by user if ($mode == 'set_topics_dl_status') { @@ -120,14 +120,14 @@ if ($req_topics_sql = implode(',', $req_topics_ary)) { } if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) { - $new_dlstatus_ary = array(); + $new_dlstatus_ary = []; foreach ($topics_ary as $topic_id) { - $new_dlstatus_ary[] = array( + $new_dlstatus_ary[] = [ 'user_id' => (int)$user->id, 'topic_id' => (int)$topic_id, 'user_status' => (int)$new_dl_status, - ); + ]; } $new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary); diff --git a/feed.php b/feed.php index 31443fc10..3688accc1 100644 --- a/feed.php +++ b/feed.php @@ -12,7 +12,7 @@ define('BB_SCRIPT', 'feed'); require __DIR__ . '/common.php'; // Init userdata -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); $mode = $_REQUEST['mode'] ?? ''; $type = $_POST['type'] ?? ''; @@ -29,7 +29,7 @@ if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) { $sql = "SELECT allow_reg_tracker, forum_name FROM " . BB_FORUMS . " WHERE forum_id = $id LIMIT 1"; if (!$forum_data = DB()->fetch_row($sql)) { if ($id == 0) { - $forum_data = array(); + $forum_data = []; } else { bb_simple_die($lang['ATOM_ERROR'] . ' #1'); } diff --git a/group.php b/group.php index fd7b92288..1fc69570f 100644 --- a/group.php +++ b/group.php @@ -18,7 +18,7 @@ $s_member_groups = $s_pending_groups = $s_member_groups_opt = $s_pending_groups_ $select_sort_mode = $select_sort_order = ''; // Init userdata -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); set_die_append_msg(); @@ -28,7 +28,7 @@ $per_page = $bb_cfg['group_members_per_page']; $view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null; $rel_limit = 50; -$group_info = array(); +$group_info = []; $is_moderator = false; if ($group_id) { @@ -43,7 +43,7 @@ if ($group_id) { if (!$group_id) { // Show the main screen where the user can select a group. - $groups = array(); + $groups = []; $pending = 10; $member = 20; @@ -92,7 +92,7 @@ if (!$group_id) { continue; } - $data = array('id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']); + $data = ['id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']]; $groups[$type][$row['group_name']] = $data; } @@ -123,18 +123,18 @@ if (!$group_id) { $s_hidden_fields = ''; foreach ($groups as $type => $grp) { - $template->assign_block_vars('groups', array( + $template->assign_block_vars('groups', [ 'MEMBERSHIP' => $lang["GROUP_MEMBER_{$type}"], - 'GROUP_SELECT' => build_group($grp), - )); + 'GROUP_SELECT' => build_group($grp) + ]); } - $template->assign_vars(array( + $template->assign_vars([ 'SELECT_GROUP' => true, 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'], 'S_USERGROUP_ACTION' => 'group.php', - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - )); + 'S_HIDDEN_FIELDS' => $s_hidden_fields + ]); } else { if (IS_ADMIN) { redirect('admin/admin_groups.php'); @@ -176,12 +176,12 @@ if (!$group_id) { $emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_REQUEST']); $emailer->set_template('group_request', $moderator['user_lang']); - $emailer->assign_vars(array( + $emailer->assign_vars([ 'USER' => $userdata['username'], 'SITENAME' => $bb_cfg['sitename'], 'GROUP_MODERATOR' => $moderator['username'], - 'U_GROUP' => make_url(GROUP_URL . $group_id), - )); + 'U_GROUP' => make_url(GROUP_URL . $group_id) + ]); $emailer->send(); } @@ -217,11 +217,11 @@ if (!$group_id) { $emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_ADDED']); $emailer->set_template('group_added', $row['user_lang']); - $emailer->assign_vars(array( + $emailer->assign_vars([ 'SITENAME' => $bb_cfg['sitename'], 'GROUP_NAME' => $group_info['group_name'], - 'U_GROUP' => make_url(GROUP_URL . $group_id), - )); + 'U_GROUP' => make_url(GROUP_URL . $group_id) + ]); $emailer->send(); } @@ -229,7 +229,7 @@ if (!$group_id) { if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members']))) { $members = (!empty($_POST['approve']) || !empty($_POST['deny'])) ? $_POST['pending_members'] : $_POST['members']; - $sql_in = array(); + $sql_in = []; foreach ($members as $members_id) { $sql_in[] = (int)$members_id; } @@ -275,11 +275,11 @@ if (!$group_id) { $emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_APPROVED']); $emailer->set_template('group_approved', $row['user_lang']); - $emailer->assign_vars(array( + $emailer->assign_vars([ 'SITENAME' => $bb_cfg['sitename'], 'GROUP_NAME' => $group_info['group_name'], - 'U_GROUP' => make_url(GROUP_URL . $group_id), - )); + 'U_GROUP' => make_url(GROUP_URL . $group_id) + ]); $emailer->send(); } @@ -317,10 +317,10 @@ if (!$group_id) { $group_details = $lang['ARE_GROUP_MODERATOR']; $s_hidden_fields = ''; } elseif ($is_group_member || $is_group_pending_member) { - $template->assign_vars(array( + $template->assign_vars([ 'SHOW_UNSUBSCRIBE_CONTROLS' => true, 'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending', - )); + ]); $group_details = ($is_group_pending_member) ? $lang['PENDING_THIS_GROUP'] : $lang['MEMBER_THIS_GROUP']; $s_hidden_fields = ''; } elseif (IS_GUEST) { @@ -357,7 +357,7 @@ if (!$group_id) { } $i = 0; - $template->assign_vars(array( + $template->assign_vars([ 'ROW_NUMBER' => $i + ($start + 1), 'GROUP_INFO' => true, 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'], @@ -395,7 +395,7 @@ if (!$group_id) { 'S_ORDER_SELECT' => $select_sort_order, 'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id", - )); + ]); switch ($view_mode) { case 'releases': @@ -440,20 +440,18 @@ if (!$group_id) { foreach ($releases as $i => $release) { $row_class = !($i % 2) ? 'row1' : 'row2'; - $template->assign_block_vars('releases', array( + $template->assign_block_vars('releases', [ 'ROW_NUMBER' => $i + ($start + 1), 'ROW_CLASS' => $row_class, - 'RELEASER' => profile_url(array('user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank'])), + 'RELEASER' => profile_url(['user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank']]), 'AVATAR_IMG' => get_avatar($release['poster_id'], $release['avatar_ext_id'], !bf($release['user_opt'], 'user_opt', 'dis_avatar'), 50, 50), 'RELEASE_NAME' => sprintf('%s', TOPIC_URL . $release['topic_id'], htmlCHR($release['topic_title'])), 'RELEASE_TIME' => bb_date($release['topic_time']), 'RELEASE_FORUM' => sprintf('%s', FORUM_URL . $release['forum_id'], htmlCHR($release['forum_name'])), - )); + ]); } - $template->assign_vars(array( - 'RELEASES' => true, - )); + $template->assign_vars(['RELEASES' => true]); break; @@ -499,7 +497,7 @@ if (!$group_id) { if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator) { $row_class = !($i % 2) ? 'row1' : 'row2'; - $template->assign_block_vars('member', array( + $template->assign_block_vars('member', [ 'ROW_NUMBER' => $i + ($start + 1), 'ROW_CLASS' => $row_class, 'USER' => profile_url($member), @@ -511,23 +509,23 @@ if (!$group_id) { 'PM' => $member_info['pm'], 'EMAIL' => $member_info['email'], 'WWW' => $member_info['www'], - 'TIME' => $member_info['user_time'], - )); + 'TIME' => $member_info['user_time'] + ]); if ($is_moderator) { - $template->assign_block_vars('member.switch_mod_option', array()); + $template->assign_block_vars('member.switch_mod_option', []); } } } // No group members if (!$members_count) { - $template->assign_block_vars('switch_no_members', array()); + $template->assign_block_vars('switch_no_members', []); } // No group members if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator) { - $template->assign_block_vars('switch_hidden_group', array()); + $template->assign_block_vars('switch_hidden_group', []); } // Pending @@ -554,7 +552,7 @@ if (!$group_id) { $user_select = ''; - $template->assign_block_vars('pending', array( + $template->assign_block_vars('pending', [ 'ROW_CLASS' => $row_class, 'AVATAR_IMG' => $member_info['avatar'], 'USER' => profile_url($member), @@ -563,21 +561,19 @@ if (!$group_id) { 'POSTS' => $member_info['posts'], 'USER_ID' => $user_id, 'PM' => $member_info['pm'], - 'EMAIL' => $member_info['email'], - )); + 'EMAIL' => $member_info['email'] + ]); } - $template->assign_vars(array( - 'PENDING_USERS' => true, - )); + $template->assign_vars(['PENDING_USERS' => true]); } - $template->assign_vars(array('MEMBERS' => true)); + $template->assign_vars(['MEMBERS' => true]); } if ($is_moderator) { - $template->assign_block_vars('switch_mod_option', array()); - $template->assign_block_vars('switch_add_member', array()); + $template->assign_block_vars('switch_mod_option', []); + $template->assign_block_vars('switch_add_member', []); } } diff --git a/group_edit.php b/group_edit.php index 3d4bdd778..efa1162f4 100644 --- a/group_edit.php +++ b/group_edit.php @@ -14,10 +14,10 @@ require __DIR__ . '/common.php'; $page_cfg['include_bbcode_js'] = true; // Start session management -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); $group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null; -$group_info = array(); +$group_info = []; $is_moderator = false; $submit = !empty($_POST['submit']); @@ -38,7 +38,7 @@ if ($is_moderator) { if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed']) { $upload = new TorrentPier\Legacy\Common\Upload(); - if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) { + if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', ['user_id' => GROUP_AVATAR_MASK . $group_id, 'avatar_ext_id' => $group_info['avatar_ext_id']])) { $avatar_ext_id = (int)$upload->file_ext_id; } else { bb_die(implode($upload->errors)); @@ -59,7 +59,7 @@ if ($is_moderator) { $s_hidden_fields = ''; - $template->assign_vars(array( + $template->assign_vars([ 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'], 'GROUP_NAME' => htmlCHR($group_info['group_name']), 'GROUP_ID' => $group_id, @@ -79,10 +79,10 @@ if ($is_moderator) { 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))), 'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']), - )); + ]); - $template->set_filenames(array('body' => 'group_edit.tpl')); - $template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION'])); + $template->set_filenames(['body' => 'group_edit.tpl']); + $template->assign_vars(['PAGE_TITLE' => $lang['GROUP_CONFIGURATION']]); require(PAGE_HEADER); diff --git a/index.php b/index.php index 3a561761d..eb10bf754 100644 --- a/index.php +++ b/index.php @@ -11,9 +11,9 @@ define('BB_SCRIPT', 'index'); require __DIR__ . '/common.php'; -$page_cfg['load_tpl_vars'] = array( - 'post_icons', -); +$page_cfg['load_tpl_vars'] = [ + 'post_icons' +]; // Show last topic $show_last_topic = true; @@ -25,11 +25,11 @@ $show_online_users = true; // Show subforums $show_subforums = true; -$datastore->enqueue(array( +$datastore->enqueue([ 'stats', 'moderators', - 'cat_forums', -)); + 'cat_forums' +]); if ($bb_cfg['show_latest_news']) { $datastore->enqueue('latest_news'); @@ -121,15 +121,15 @@ $sql = " ORDER BY c.cat_order, f.forum_order '; -$replace_in_parent = array( +$replace_in_parent = [ 'last_post_id', 'last_post_time', 'last_post_user_id', 'last_post_username', 'last_post_user_rank', 'last_topic_title', - 'last_topic_id', -); + 'last_topic_id' +]; $cache_name = 'index_sql_' . md5($sql); if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) { @@ -168,7 +168,7 @@ if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) { } // Obtain list of moderators -$moderators = array(); +$moderators = []; if (!$mod = $datastore->get('moderators')) { $datastore->update('moderators'); $mod = $datastore->get('moderators'); @@ -193,25 +193,23 @@ $datastore->rm('moderators'); // Build index page $forums_count = 0; foreach ($cat_forums as $cid => $c) { - $template->assign_block_vars('h_c', array( + $template->assign_block_vars('h_c', [ 'H_C_ID' => $cid, 'H_C_TITLE' => $cat_title_html[$cid], 'H_C_CHEKED' => in_array($cid, preg_split('/[-]+/', $hide_cat_opt)) ? 'checked' : '', - )); + ]); - $template->assign_vars(array( - 'H_C_AL_MESS' => $hide_cat_opt && !$showhide, - )); + $template->assign_vars(['H_C_AL_MESS' => $hide_cat_opt && !$showhide]); if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) { continue; } - $template->assign_block_vars('c', array( + $template->assign_block_vars('c', [ 'CAT_ID' => $cid, 'CAT_TITLE' => $cat_title_html[$cid], 'U_VIEWCAT' => CAT_URL . $cid, - )); + ]); foreach ($c['f'] as $fid => $f) { if (!$fname_html =& $forum_name_html[$fid]) { @@ -228,15 +226,15 @@ foreach ($cat_forums as $cid => $c) { } if ($is_sf) { - $template->assign_block_vars('c.f.sf', array( + $template->assign_block_vars('c.f.sf', [ 'SF_ID' => $fid, 'SF_NAME' => $fname_html, - 'SF_NEW' => $new ? ' new' : '', - )); + 'SF_NEW' => $new ? ' new' : '' + ]); continue; } - $template->assign_block_vars('c.f', array( + $template->assign_block_vars('c.f', [ 'FORUM_FOLDER_IMG' => $folder_image, 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname_html, @@ -245,22 +243,22 @@ foreach ($cat_forums as $cid => $c) { 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => $f['last_sf_id'] ?? null, 'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '', - 'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD'], - )); + 'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD'] + ]); if ($f['last_post_id']) { - $template->assign_block_vars('c.f.last', array( + $template->assign_block_vars('c.f.last', [ 'LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_TIP' => $f['last_topic_title'], 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), - 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])), - )); + 'LAST_POST_USER' => profile_url(['username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']]), + ]); } } } -$template->assign_vars(array( +$template->assign_vars([ 'SHOW_FORUMS' => $forums_count, 'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST, 'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'], @@ -310,7 +308,7 @@ $template->assign_vars(array( 'SHOW_LAST_TOPIC' => $show_last_topic, 'BOARD_START' => $bb_cfg['show_board_start_index'] ? ($lang['BOARD_STARTED'] . ': ' . '' . bb_date($bb_cfg['board_startdate']) . '') : false, -)); +]); // Set tpl vars for bt_userdata if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) { @@ -324,17 +322,15 @@ if ($bb_cfg['show_latest_news']) { $latest_news = $datastore->get('latest_news'); } - $template->assign_vars(array( - 'SHOW_LATEST_NEWS' => true, - )); + $template->assign_vars(['SHOW_LATEST_NEWS' => true]); foreach ($latest_news as $news) { - $template->assign_block_vars('news', array( + $template->assign_block_vars('news', [ 'NEWS_TOPIC_ID' => $news['topic_id'], 'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']), 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false), 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']), - )); + ]); } } @@ -345,22 +341,20 @@ if ($bb_cfg['show_network_news']) { $network_news = $datastore->get('network_news'); } - $template->assign_vars(array( - 'SHOW_NETWORK_NEWS' => true, - )); + $template->assign_vars(['SHOW_NETWORK_NEWS' => true]); foreach ($network_news as $net) { - $template->assign_block_vars('net', array( + $template->assign_block_vars('net', [ 'NEWS_TOPIC_ID' => $net['topic_id'], 'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']), 'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false), 'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']), - )); + ]); } } if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { - $week_list = $today_list = array(); + $week_list = $today_list = []; $week_all = $today_all = false; if (!empty($stats['birthday_week_list'])) { @@ -393,10 +387,10 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { $today_list = $lang['NOBIRTHDAY_TODAY']; } - $template->assign_vars(array( + $template->assign_vars([ 'WHOSBIRTHDAY_WEEK' => $week_list, - 'WHOSBIRTHDAY_TODAY' => $today_list, - )); + 'WHOSBIRTHDAY_TODAY' => $today_list + ]); } // Allow cron @@ -413,7 +407,7 @@ if (IS_AM) { define('SHOW_ONLINE', $show_online_users); if (isset($_GET['map'])) { - $template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP'])); + $template->assign_vars(['PAGE_TITLE' => $lang['FORUM_MAP']]); } print_page('index.tpl'); diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php index ba51fd847..067d369bd 100644 --- a/library/ajax/edit_user_profile.php +++ b/library/ajax/edit_user_profile.php @@ -126,7 +126,7 @@ switch ($field) { $table = BB_BT_USERS; $value = (float)str_replace(',', '.', $this->request['value']); - foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4, 'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8) as $s => $m) { + foreach (['KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4, 'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8] as $s => $m) { if (stripos($this->request['value'], $s) !== false) { $value *= (1024 ** $m); break; diff --git a/library/ajax/group_membership.php b/library/ajax/group_membership.php index 2979a2dbd..6b595f5ec 100644 --- a/library/ajax/group_membership.php +++ b/library/ajax/group_membership.php @@ -31,7 +31,7 @@ switch ($mode) { WHERE ug.user_id = $user_id ORDER BY g.group_name "; - $html = array(); + $html = []; foreach (DB()->fetch_rowset($sql) as $row) { $class = ($row['user_pending']) ? 'med' : 'med bold'; $class .= ($row['group_moderator'] == $user_id) ? ' colorMod' : ''; diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php index 49ae9b971..5d470571d 100644 --- a/library/ajax/index_data.php +++ b/library/ajax/index_data.php @@ -19,9 +19,9 @@ $html = ''; switch ($mode) { case 'birthday_week': $stats = $datastore->get('stats'); - $datastore->enqueue(array( - 'stats', - )); + $datastore->enqueue([ + 'stats' + ]); $users = []; @@ -37,9 +37,9 @@ switch ($mode) { case 'birthday_today': $stats = $datastore->get('stats'); - $datastore->enqueue(array( - 'stats', - )); + $datastore->enqueue([ + 'stats' + ]); $users = []; @@ -56,12 +56,12 @@ switch ($mode) { case 'get_forum_mods': $forum_id = (int)$this->request['forum_id']; - $datastore->enqueue(array( + $datastore->enqueue([ 'moderators', - 'cat_forums', - )); + 'cat_forums' + ]); - $moderators = array(); + $moderators = []; $mod = $datastore->get('moderators'); if (isset($mod['mod_users'][$forum_id])) { diff --git a/library/ajax/mod_action.php b/library/ajax/mod_action.php index 9de6f8f19..5a2568117 100644 --- a/library/ajax/mod_action.php +++ b/library/ajax/mod_action.php @@ -69,12 +69,12 @@ switch ($mode) { } // Log action - $log_action->mod('mod_topic_renamed', array( + $log_action->mod('mod_topic_renamed', [ 'forum_id' => $t_data['forum_id'], 'topic_id' => $topic_id, 'topic_title' => $old_title, - 'topic_title_new' => $new_title, - )); + 'topic_title_new' => $new_title + ]); $this->response['topic_id'] = $topic_id; $this->response['topic_title'] = $new_title; diff --git a/library/ajax/post_mod_comment.php b/library/ajax/post_mod_comment.php index 213d4c2cd..17e12d467 100644 --- a/library/ajax/post_mod_comment.php +++ b/library/ajax/post_mod_comment.php @@ -30,11 +30,11 @@ if (!$post) { $this->ajax_die('not post'); } -$data = array( +$data = [ 'mc_comment' => ($mc_type) ? $mc_text : '', 'mc_type' => $mc_type, - 'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0, -); + 'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0 +]; $sql_args = DB()->build_array('UPDATE', $data); DB()->query("UPDATE " . BB_POSTS . " SET $sql_args WHERE post_id = $post_id"); diff --git a/library/ajax/posts.php b/library/ajax/posts.php index 2e55eb265..7c441a189 100644 --- a/library/ajax/posts.php +++ b/library/ajax/posts.php @@ -48,8 +48,8 @@ if (isset($this->request['post_id'])) { } if (!defined('WORD_LIST_OBTAINED')) { - $orig_word = array(); - $replace_word = array(); + $orig_word = []; + $replace_word = []; obtain_word_list($orig_word, $replace_word); define('WORD_LIST_OBTAINED', true); } @@ -142,10 +142,10 @@ switch ($this->request['type']) { $s_text = str_replace('\n', "\n", $text); $s_topic_title = str_replace('\n', "\n", $post['topic_title']); add_search_words($post_id, stripslashes($s_text), stripslashes($s_topic_title)); - update_post_html(array( + update_post_html([ 'post_id' => $post_id, - 'post_text' => $text, - )); + 'post_text' => $text + ]); } } else { $this->ajax_die($lang['EMPTY_MESSAGE']); @@ -276,10 +276,10 @@ switch ($this->request['type']) { $s_message = str_replace('\n', "\n", $message); $s_topic_title = str_replace('\n', "\n", $post['topic_title']); add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title)); - update_post_html(array( + update_post_html([ 'post_id' => $post_id, - 'post_text' => $message, - )); + 'post_text' => $message + ]); if ($bb_cfg['topic_notify_enabled']) { $notify = !empty($this->request['notify']); diff --git a/library/ajax/topic_tpl.php b/library/ajax/topic_tpl.php index cbdfc535a..17085ae5b 100644 --- a/library/ajax/topic_tpl.php +++ b/library/ajax/topic_tpl.php @@ -60,7 +60,7 @@ switch ($mode) { preg_match('#\d+#', (string)$this->request['tpl_rules'], $m); $tpl_rules_post_id = isset($m[0]) ? (int)$m[0] : 0; - $sql_args = array( + $sql_args = [ 'tpl_name' => (string)$tpl_name, 'tpl_src_form' => (string)$tpl_src_form, 'tpl_src_title' => (string)$tpl_src_title, @@ -68,8 +68,8 @@ switch ($mode) { 'tpl_comment' => (string)$tpl_comment, 'tpl_rules_post_id' => (int)$tpl_rules_post_id, 'tpl_last_edit_tm' => (int)TIMENOW, - 'tpl_last_edit_by' => (int)$userdata['user_id'], - ); + 'tpl_last_edit_by' => (int)$userdata['user_id'] + ]; break; } // выполнение diff --git a/library/attach_mod/attachment_mod.php b/library/attach_mod/attachment_mod.php index 004604c90..e1f2c1269 100644 --- a/library/attach_mod/attachment_mod.php +++ b/library/attach_mod/attachment_mod.php @@ -48,7 +48,7 @@ function get_config() { global $bb_cfg; - $attach_config = array(); + $attach_config = []; $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; @@ -67,7 +67,7 @@ function get_config() } // Get Attachment Config -$attach_config = array(); +$attach_config = []; if (!$attach_config = CACHE('bb_cache')->get('attach_config')) { $attach_config = get_config(); diff --git a/library/attach_mod/displaying.php b/library/attach_mod/displaying.php index 012bac2b6..40b101c45 100644 --- a/library/attach_mod/displaying.php +++ b/library/attach_mod/displaying.php @@ -11,11 +11,11 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -$allowed_extensions = array(); -$display_categories = array(); -$download_modes = array(); -$upload_icons = array(); -$attachments = array(); +$allowed_extensions = []; +$display_categories = []; +$download_modes = []; +$upload_icons = []; +$attachments = []; /** * Create needed arrays for Extension Assignments @@ -28,7 +28,7 @@ function init_complete_extensions_data() $GLOBALS['datastore']->update('attach_extensions'); $extension_informations = get_extension_informations(); } - $allowed_extensions = array(); + $allowed_extensions = []; for ($i = 0, $size = count($extension_informations); $i < $size; $i++) { $extension = strtolower(trim($extension_informations[$i]['extension'])); @@ -116,7 +116,7 @@ function init_display_post_attachments($switch_attachment) return; } - $post_id_array = array(); + $post_id_array = []; for ($i = 0; $i < $total_posts; $i++) { if ($postrow[$i]['post_attachment'] == 1) { @@ -173,7 +173,7 @@ function display_attachments($post_id) return; } - $template->assign_block_vars('postrow.attach', array()); + $template->assign_block_vars('postrow.attach', []); for ($i = 0; $i < $num_attachments; $i++) { // Some basic things... @@ -200,9 +200,7 @@ function display_attachments($post_id) if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) { $denied = true; - $template->assign_block_vars('postrow.attach.denyrow', array( - 'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension'])) - ); + $template->assign_block_vars('postrow.attach.denyrow', ['L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension'])]); } if (!$denied || IS_ADMIN) { @@ -246,13 +244,13 @@ function display_attachments($post_id) $download_link = false; } - $template->assign_block_vars('postrow.attach.cat_images', array( + $template->assign_block_vars('postrow.attach.cat_images', [ 'DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => $img_source, 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - )); + 'COMMENT' => $comment + ]); // Directly Viewed Image ... update the download count if (!$download_link) { @@ -274,14 +272,14 @@ function display_attachments($post_id) $thumb_source = $thumbnail_filename; } - $template->assign_block_vars('postrow.attach.cat_thumb_images', array( + $template->assign_block_vars('postrow.attach.cat_thumb_images', [ 'DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'], 'IMG_THUMB_SRC' => $thumb_source, 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - )); + 'COMMENT' => $comment + ]); } // bt @@ -291,15 +289,15 @@ function display_attachments($post_id) $target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : ''; // display attachment - $template->assign_block_vars('postrow.attach.attachrow', array( + $template->assign_block_vars('postrow.attach.attachrow', [ 'U_DOWNLOAD_LINK' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'], 'S_UPLOAD_IMAGE' => $upload_image, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'COMMENT' => $comment, 'TARGET_BLANK' => $target_blank, - 'DOWNLOAD_COUNT' => declension((int)$attachments['_' . $post_id][$i]['download_count'], 'times'), - )); + 'DOWNLOAD_COUNT' => declension((int)$attachments['_' . $post_id][$i]['download_count'], 'times') + ]); } } } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 5ebb8351b..81f4b895f 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -28,15 +28,15 @@ $upload_image = '' . $lang['DL_TORREN
 
 $peers_cnt = $seed_count = 0;
 $seeders = $leechers = '';
-$tor_info = array();
+$tor_info = [];
 
-$template->assign_vars(array(
+$template->assign_vars([
     'SEED_COUNT' => false,
     'LEECH_COUNT' => false,
     'TOR_SPEED_UP' => false,
     'TOR_SPEED_DOWN' => false,
-    'SHOW_RATIO_WARN' => false,
-));
+    'SHOW_RATIO_WARN' => false
+]);
 
 // Define show peers mode (count only || user names with complete % || full details)
 $cfg_sp_mode = $bb_cfg['bt_show_peers_mode'];
@@ -90,7 +90,7 @@ if ($tor_auth_reg || $tor_auth_del) {
 $display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.torrent';
 
 if (!$tor_reged) {
-    $template->assign_block_vars('postrow.attach.tor_not_reged', array(
+    $template->assign_block_vars('postrow.attach.tor_not_reged', [
         'DOWNLOAD_NAME' => $display_name,
         'TRACKER_LINK' => $tracker_link,
         'ATTACH_ID' => $attach_id,
@@ -101,10 +101,10 @@ if (!$tor_reged) {
 
         'DOWNLOAD_COUNT' => declension((int)$download_count, 'times'),
         'POSTED_TIME' => $tor_file_time,
-    ));
+    ]);
 
     if ($comment) {
-        $template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
+        $template->assign_block_vars('postrow.attach.tor_not_reged.comment', ['COMMENT' => $comment]);
     }
 } else {
     $sql = assign_vars(array( + $template->assign_vars([ 'TOR_CONTROLS' => true, - 'TOR_ATTACH_ID' => $attach_id, - )); + 'TOR_ATTACH_ID' => $attach_id + ]); if ($t_data['self_moderated'] || $is_auth['auth_mod']) { - $template->assign_vars(array('AUTH_MOVE' => true)); + $template->assign_vars(['AUTH_MOVE' => true]); } } @@ -175,21 +175,21 @@ if ($tor_reged && $tor_info) { } if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) { - $template->assign_vars(array( + $template->assign_vars([ 'SHOW_RATIO_WARN' => true, - 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']), - )); + 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']) + ]); } } if (!$dl_allowed) { - $template->assign_block_vars('postrow.attach.tor_reged', array()); - $template->assign_vars(array( + $template->assign_block_vars('postrow.attach.tor_reged', []); + $template->assign_vars([ 'TOR_BLOCKED' => true, 'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$bt_user_id&dlc=1"), - )); + ]); } else { - $template->assign_block_vars('postrow.attach.tor_reged', array( + $template->assign_block_vars('postrow.attach.tor_reged', [ 'DOWNLOAD_NAME' => $display_name, 'TRACKER_LINK' => $tracker_link, 'ATTACH_ID' => $attach_id, @@ -218,22 +218,22 @@ if ($tor_reged && $tor_info) { 'REGED_DELTA' => delta_time($tor_info['reg_time']), 'TORRENT_SIZE' => humn_size($tor_size), 'COMPLETED' => declension((int)$tor_info['complete_count'], 'times'), - )); + ]); if ($comment) { - $template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment)); + $template->assign_block_vars('postrow.attach.tor_reged.comment', ['COMMENT' => $comment]); } } if ($bb_cfg['show_tor_info_in_dl_list']) { - $template->assign_vars(array( + $template->assign_vars([ 'SHOW_DL_LIST' => true, 'SHOW_DL_LIST_TOR_INFO' => true, 'TOR_SIZE' => humn_size($tor_size), 'TOR_LONGEVITY' => delta_time($tor_info['reg_time']), 'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times'), - )); + ]); } // Show peers @@ -250,7 +250,7 @@ if ($tor_reged && $tor_info) { } if (isset($_REQUEST['porder'])) { - $peer_orders = array( + $peer_orders = [ 'name' => 'u.username', 'ip' => 'tr.ip', 'port' => 'tr.port', @@ -259,8 +259,8 @@ if ($tor_reged && $tor_info) { 'cdown' => 'tr.downloaded', 'sup' => 'tr.speed_up', 'sdown' => 'tr.speed_down', - 'time' => 'tr.update_time', - ); + 'time' => 'tr.update_time' + ]; foreach ($peer_orders as $get_key => $order_by_value) { if ($_REQUEST['porder'] == $get_key) { @@ -299,11 +299,11 @@ if ($tor_reged && $tor_info) { if ($peers = DB()->fetch_rowset($sql)) { $peers_cnt = count($peers); - $cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = array(); + $cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = []; $cnt['s'] = $tr['s'] = $sp_up['s'] = $sp_down['s'] = $sp_up_tot['s'] = $sp_down_tot['s'] = 0; $cnt['l'] = $tr['l'] = $sp_up['l'] = $sp_down['l'] = $sp_up_tot['l'] = $sp_down_tot['l'] = 0; - $max_up = $max_down = $max_sp_up = $max_sp_down = array(); + $max_up = $max_down = $max_sp_up = $max_sp_down = []; $max_up['s'] = $max_down['s'] = $max_sp_up['s'] = $max_sp_down['s'] = 0; $max_up['l'] = $max_down['l'] = $max_sp_up['l'] = $max_sp_down['l'] = 0; $max_up_id['s'] = $max_down_id['s'] = $max_sp_up_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1); @@ -348,7 +348,7 @@ if ($tor_reged && $tor_info) { } if ($s_mode == 'count') { - $tmp = array(); + $tmp = []; $tmp[0]['seeder'] = $tmp[0]['username'] = $tmp[1]['username'] = 0; $tmp[1]['seeder'] = 1; $tmp[0]['username'] = (int)@$peers[0]['leechers']; @@ -357,10 +357,10 @@ if ($tor_reged && $tor_info) { $tor_speed_down = (int)@$peers[0]['speed_down']; $peers = $tmp; - $template->assign_vars(array( + $template->assign_vars([ 'TOR_SPEED_UP' => ($tor_speed_up) ? humn_size($tor_speed_up, 0, 'KB') . '/s' : '0 KB/s', - 'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s', - )); + 'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s' + ]); } foreach ($peers as $pid => $peer) { @@ -384,18 +384,18 @@ if ($tor_reged && $tor_info) { if (!defined('SEEDER_EXIST')) { define('SEEDER_EXIST', true); - $seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders"; + $seed_order_action = TOPIC_URL . "$bt_topic_id&spmode=full#seeders"; - $template->assign_block_vars((string)$x_full, array( + $template->assign_block_vars((string)$x_full, [ 'SEED_ORD_ACT' => $seed_order_action, 'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s' - )); + ]); if ($ip) { - $template->assign_block_vars("$x_full.iphead", array()); + $template->assign_block_vars("$x_full.iphead", []); } if ($port !== false) { - $template->assign_block_vars("$x_full.porthead", array()); + $template->assign_block_vars("$x_full.porthead", []); } } $compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0; @@ -406,19 +406,19 @@ if ($tor_reged && $tor_info) { if (!defined('LEECHER_EXIST')) { define('LEECHER_EXIST', true); - $leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#leechers"; + $leech_order_action = TOPIC_URL . "$bt_topic_id&spmode=full#leechers"; - $template->assign_block_vars((string)$x_full, array( + $template->assign_block_vars((string)$x_full, [ 'LEECH_ORD_ACT' => $leech_order_action, 'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s', 'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s' - )); + ]); if ($ip) { - $template->assign_block_vars("$x_full.iphead", array()); + $template->assign_block_vars("$x_full.iphead", []); } if ($port !== false) { - $template->assign_block_vars("$x_full.porthead", array()); + $template->assign_block_vars("$x_full.porthead", []); } } $compl_size = ($peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0; @@ -437,7 +437,7 @@ if ($tor_reged && $tor_info) { $row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : ''; $tr[$x]++; - $template->assign_block_vars("$x_full.$x_row", array( + $template->assign_block_vars("$x_full.$x_row", [ 'ROW_BGR' => $row_bgr, 'NAME' => ($peer['update_time']) ? $name : "$name", 'COMPL_PRC' => $compl_perc, @@ -450,14 +450,14 @@ if ($tor_reged && $tor_info) { 'SPEED_UP_RAW' => $peer['speed_up'], 'SPEED_DOWN_RAW' => $peer['speed_down'], 'UPD_EXP_TIME' => ($peer['update_time']) ? $lang['DL_UPD'] . bb_date($peer['update_time'], 'd-M-y H:i') . ' · ' . delta_time($peer['update_time']) . $lang['TOR_BACK'] : $lang['DL_STOPPED'], - 'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '', - )); + 'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '' + ]); if ($ip) { - $template->assign_block_vars("$x_full.$x_row.ip", array('IP' => $ip)); + $template->assign_block_vars("$x_full.$x_row.ip", ['IP' => $ip]); } if ($port !== false) { - $template->assign_block_vars("$x_full.$x_row.port", array('PORT' => $port)); + $template->assign_block_vars("$x_full.$x_row.port", ['PORT' => $port]); } } // Count only & only names modes else { @@ -478,17 +478,17 @@ if ($tor_reged && $tor_info) { if ($s_mode != 'full' && $seeders) { $seeders[strlen($seeders) - 9] = ' '; - $template->assign_vars(array( + $template->assign_vars([ 'SEED_LIST' => $seeders, 'SEED_COUNT' => ($seed_count) ?: 0, - )); + ]); } if ($s_mode != 'full' && $leechers) { $leechers[strlen($leechers) - 9] = ' '; - $template->assign_vars(array( + $template->assign_vars([ 'LEECH_LIST' => $leechers, 'LEECH_COUNT' => ($leech_count) ?: 0, - )); + ]); } } unset($peers); @@ -497,27 +497,27 @@ if ($tor_reged && $tor_info) { if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST'))) { $last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : $lang['NEVER']; - $template->assign_vars(array( - 'SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time), - )); + $template->assign_vars(['SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time)]); } } - $template->assign_block_vars('tor_title', array('U_DOWNLOAD_LINK' => $download_link)); + $template->assign_block_vars('tor_title', ['U_DOWNLOAD_LINK' => $download_link]); if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full') { - $template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_overflow)); - $template->assign_vars(array('PEERS_OVERFLOW' => true)); + $template->assign_vars([ + 'PEERS_OVERFLOW' => true, + 'PEERS_DIV_STYLE' => $peers_div_style_overflow + ]); } else { - $template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_normal)); + $template->assign_vars(['PEERS_DIV_STYLE' => $peers_div_style_normal]); } } if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') { - $template->assign_vars(array( + $template->assign_vars([ 'PEERS_FULL_LINK' => true, - 'SPMODE_FULL_HREF' => "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders", - )); + 'SPMODE_FULL_HREF' => TOPIC_URL . "$bt_topic_id&spmode=full#seeders" + ]); } $template->assign_vars(array( diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index 6b978af24..5c0b7f22c 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -55,7 +55,7 @@ function base64_unpack($string) for ($i = 1; $i <= $length; $i++) { $pos = $length - $i; - $operand = strpos($chars, (string) $string[$pos]); + $operand = strpos($chars, (string)$string[$pos]); $exponent = $base ** ($i - 1); $decValue = $operand * $exponent; $number += $decValue; @@ -454,7 +454,7 @@ function _set_var(&$result, $var, $type, $multibyte = false) $result = $var; if ($type == 'string') { - $result = trim(str_replace(array("\r\n", "\r", '\xFF'), array("\n", "\n", ' '), $result)); + $result = trim(str_replace(["\r\n", "\r", '\xFF'], ["\n", "\n", ' '], $result)); // 2.0.x is doing addslashes on all variables $result = stripslashes($result); if ($multibyte) { diff --git a/library/attach_mod/includes/functions_delete.php b/library/attach_mod/includes/functions_delete.php index 93fa89a05..b462226c6 100644 --- a/library/attach_mod/includes/functions_delete.php +++ b/library/attach_mod/includes/functions_delete.php @@ -23,7 +23,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } if ($post_id_array === 0 && $attach_id_array !== 0) { - $post_id_array = array(); + $post_id_array = []; if (!is_array($attach_id_array)) { if (false !== strpos($attach_id_array, ', ')) { @@ -32,7 +32,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $attach_id_array = explode(',', $attach_id_array); } else { $attach_id = (int)$attach_id_array; - $attach_id_array = array(); + $attach_id_array = []; $attach_id_array[] = $attach_id; } } @@ -74,7 +74,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } else { $post_id = (int)$post_id_array; - $post_id_array = array(); + $post_id_array = []; $post_id_array[] = $post_id; } } @@ -85,7 +85,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, // First of all, determine the post id and attach_id if ($attach_id_array === 0) { - $attach_id_array = array(); + $attach_id_array = []; // Get the attach_ids to fill the array $whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')'; @@ -119,7 +119,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } else { $attach_id = (int)$attach_id_array; - $attach_id_array = array(); + $attach_id_array = []; $attach_id_array[] = $attach_id; } } @@ -147,7 +147,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, bb_die($lang['ERROR_DELETED_ATTACHMENTS']); } - $torrents_sql = array(); + $torrents_sql = []; while ($row = DB()->sql_fetchrow($result)) { $torrents_sql[] = $row['topic_id']; diff --git a/library/attach_mod/includes/functions_filetypes.php b/library/attach_mod/includes/functions_filetypes.php index ed1f0e12b..ad2c1fba3 100644 --- a/library/attach_mod/includes/functions_filetypes.php +++ b/library/attach_mod/includes/functions_filetypes.php @@ -109,11 +109,11 @@ function image_getdimension($file) if (!$error) { fclose($fp); - return array( + return [ $width, $height, 6 - ); + ]; } $error = false; @@ -147,11 +147,11 @@ function image_getdimension($file) if (!$error) { fclose($fp); - return array( + return [ $width, $height, 1 - ); + ]; } $error = false; @@ -199,11 +199,11 @@ function image_getdimension($file) if (!$error) { fclose($fp); - return array( + return [ $width, $height, 2 - ); + ]; } $error = false; @@ -245,11 +245,11 @@ function image_getdimension($file) if (!$error) { fclose($fp); - return array( + return [ $width, $height, 7 - ); + ]; } fclose($fp); diff --git a/library/attach_mod/includes/functions_includes.php b/library/attach_mod/includes/functions_includes.php index bf0632b68..67a025724 100644 --- a/library/attach_mod/includes/functions_includes.php +++ b/library/attach_mod/includes/functions_includes.php @@ -98,10 +98,10 @@ function attachment_quota_settings($admin_mode, $mode, $submit = false) } DB()->sql_freeresult($result); - $template->assign_vars(array( + $template->assign_vars([ 'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), - 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota), - )); + 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota) + ]); } if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) { @@ -148,10 +148,10 @@ function attachment_quota_settings($admin_mode, $mode, $submit = false) } DB()->sql_freeresult($result); - $template->assign_vars(array( + $template->assign_vars([ 'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), - 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota), - )); + 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota) + ]); } if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) { diff --git a/library/attach_mod/includes/functions_selects.php b/library/attach_mod/includes/functions_selects.php index 3a3bc1c6e..24aac4745 100644 --- a/library/attach_mod/includes/functions_selects.php +++ b/library/attach_mod/includes/functions_selects.php @@ -120,8 +120,8 @@ function category_select($select_name, $group_id = 0) } } - $types = array(NONE_CAT); - $modes = array('none'); + $types = [NONE_CAT]; + $modes = ['none']; for ($i = 0, $iMax = count($types_category); $i < $iMax; $i++) { $types[] = $types_category[$i]; @@ -152,8 +152,8 @@ function size_select($select_name, $size_compare) { global $lang; - $size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']); - $size_types = array('b', 'kb', 'mb'); + $size_types_text = [$lang['BYTES'], $lang['KB'], $lang['MB']]; + $size_types = ['b', 'kb', 'mb']; $select_field = ' mode $select_sort_mode = ''; // // Generate page // -$template->assign_vars(array( +$template->assign_vars([ 'S_MODE_SELECT' => $select_sort_mode, 'S_ORDER_SELECT' => $select_sort_order, 'S_MODE_ACTION' => "memberlist.php", 'S_USERNAME' => $paginationusername, -)); +]); switch ($mode) { case 'joined': @@ -139,10 +139,10 @@ $select_letter .= ($by_letter == 'others') ? '' . $lang['OTHERS'] . '&nbs $select_letter .= ': '; $select_letter .= ($by_letter == 'all') ? '' . $lang['ALL'] . '' : '' . $lang['ALL'] . ''; -$template->assign_vars(array( +$template->assign_vars([ 'S_LETTER_SELECT' => $select_letter, 'S_LETTER_HIDDEN' => '', -)); +]); // per-letter selection end $sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email, avatar_ext_id FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")"; @@ -160,7 +160,7 @@ if ($result = DB()->fetch_rowset($sql)) { $user_info = generate_user_info($row); $row_class = !($i % 2) ? 'row1' : 'row2'; - $template->assign_block_vars('memberrow', array( + $template->assign_block_vars('memberrow', [ 'ROW_NUMBER' => $i + ($start + 1), 'ROW_CLASS' => $row_class, 'USER' => profile_url($row), @@ -172,13 +172,11 @@ if ($result = DB()->fetch_rowset($sql)) { 'PM' => $user_info['pm'], 'EMAIL' => $user_info['email'], 'WWW' => $user_info['www'], - 'U_VIEWPROFILE' => PROFILE_URL . $user_id, - )); + 'U_VIEWPROFILE' => PROFILE_URL . $user_id + ]); } } else { - $template->assign_block_vars('no_username', array( - 'NO_USER_ID_SPECIFIED' => $lang['NO_USER_ID_SPECIFIED'], - )); + $template->assign_block_vars('no_username', ['NO_USER_ID_SPECIFIED' => $lang['NO_USER_ID_SPECIFIED']]); } $paginationurl = "memberlist.php?mode=$mode&order=$sort_order&letter=$by_letter"; @@ -198,8 +196,6 @@ if ($mode != 'topten' || $bb_cfg['topics_per_page'] < 10) { DB()->sql_freeresult($result); } -$template->assign_vars(array( - 'PAGE_TITLE' => $lang['MEMBERLIST'], -)); +$template->assign_vars(['PAGE_TITLE' => $lang['MEMBERLIST']]); print_page('memberlist.tpl'); diff --git a/modcp.php b/modcp.php index 754c0dafd..f404e0df9 100644 --- a/modcp.php +++ b/modcp.php @@ -41,7 +41,7 @@ function return_msg_mcp($status_msg) function validate_topics($forum_id, &$req_topics, &$topic_titles) { - $valid_topics = $valid_titles = array(); + $valid_topics = $valid_titles = []; if ($topic_csv = get_id_csv($req_topics)) { $sql = "SELECT topic_id, topic_title FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND forum_id = $forum_id"; @@ -130,7 +130,7 @@ if ($topic_id) { } // Start session management -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); // Check if user did or did not confirm. If they did not, forward them to the last page they were on if (isset($_POST['cancel']) || IS_GUEST) { @@ -173,7 +173,7 @@ if ($is_moderator && !$userdata['session_admin']) { // // Get required vars // -$req_topics = $topic_csv = $topic_titles = $hidden_fields = array(); +$req_topics = $topic_csv = $topic_titles = $hidden_fields = []; switch ($mode) { case 'delete': @@ -196,12 +196,12 @@ switch ($mode) { bb_die($lang['NONE_SELECTED']); } - $hidden_fields = array( + $hidden_fields = [ 'sid' => $userdata['session_id'], 'mode' => $mode, 'f' => $forum_id, - 't' => $topic_id, - ); + 't' => $topic_id + ]; foreach ($req_topics as $req_topic_id) { $hidden_fields['topic_id_list'][] = $req_topic_id; } @@ -238,12 +238,12 @@ switch ($mode) { $msg = ($result) ? $lang['TOPICS_REMOVED'] : $lang['NO_TOPICS_REMOVED']; bb_die(return_msg_mcp($msg)); } else { - print_confirmation(array( + print_confirmation([ 'QUESTION' => $lang['CONFIRM_DELETE_TOPIC'], 'ITEMS_LIST' => implode("\n\n
  • \n", $topic_titles), 'FORM_ACTION' => "modcp.php", - 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), - )); + 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields) + ]); } break; @@ -278,7 +278,7 @@ switch ($mode) { $forum_select = get_forum_select($forum_select_mode, 'new_forum', $forum_id); - $template->assign_vars(array( + $template->assign_vars([ 'TPL_MODCP_MOVE' => true, 'SHOW_LEAVESHADOW' => $is_moderator, 'SHOW_BOT_OPTIONS' => $is_moderator, @@ -290,9 +290,9 @@ switch ($mode) { 'S_FORUM_SELECT' => $forum_select, 'S_MODCP_ACTION' => "modcp.php", 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), - )); + ]); - $template->set_filenames(array('body' => 'modcp.tpl')); + $template->set_filenames(['body' => 'modcp.tpl']); } break; @@ -310,7 +310,7 @@ switch ($mode) { AND topic_status != $new_topic_status "; - $topic_csv = array(); + $topic_csv = []; foreach (DB()->fetch_rowset($sql) as $row) { $topic_csv[] = $row['topic_id']; @@ -331,11 +331,11 @@ switch ($mode) { $type = ($lock) ? 'mod_topic_lock' : 'mod_topic_unlock'; foreach ($log_topics as $topic_id => $topic_title) { - $log_action->mod($type, array( + $log_action->mod($type, [ 'forum_id' => $forum_id, 'topic_id' => $topic_id, - 'topic_title' => $topic_title, - )); + 'topic_title' => $topic_title + ]); } $msg = ($lock) ? $lang['TOPICS_LOCKED'] : $lang['TOPICS_UNLOCKED']; @@ -364,11 +364,11 @@ switch ($mode) { // Log action $type = ($set_download) ? 'mod_topic_set_downloaded' : 'mod_topic_unset_downloaded'; - $log_action->mod($type, array( + $log_action->mod($type, [ 'forum_id' => $forum_id, 'topic_id' => $topic_id, - 'topic_title' => get_topic_title($topic_id), - )); + 'topic_title' => get_topic_title($topic_id) + ]); $msg = ($set_download) ? $lang['TOPICS_DOWN_SETS'] : $lang['TOPICS_DOWN_UNSETS']; bb_die(return_msg_mcp($msg)); @@ -379,12 +379,12 @@ switch ($mode) { //mpd $delete_posts = isset($_POST['delete_posts']); $split = (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond'])); - $posts = $_POST['post_id_list'] ?? array(); + $posts = $_POST['post_id_list'] ?? []; $start = /* (isset($_POST['start'])) ? intval($_POST['start']) : */ 0; $topic_first_post_id = $topic_row['topic_first_post_id'] ?? ''; - $post_id_sql = $req_post_id_sql = array(); + $post_id_sql = $req_post_id_sql = []; if (($split || $delete_posts) && ($posts && $topic_id && $forum_id && $topic_first_post_id) && $confirmed) { foreach ($posts as $post_id) { @@ -489,22 +489,22 @@ switch ($mode) { \TorrentPier\Legacy\Post::insert_post('after_split_to_new', $new_topic_id, $new_forum_id, $forum_id, $new_topic_id, '', $topic_id); } - \TorrentPier\Legacy\Admin\Common::sync('topic', array($topic_id, $new_topic_id)); - \TorrentPier\Legacy\Admin\Common::sync('forum', array($forum_id, $new_forum_id)); + \TorrentPier\Legacy\Admin\Common::sync('topic', [$topic_id, $new_topic_id]); + \TorrentPier\Legacy\Admin\Common::sync('forum', [$forum_id, $new_forum_id]); //bot - $message = $lang['TOPIC_SPLIT'] . '

    ' . $lang['TOPIC_SPLIT_OLD'] . ''; - $message .= '  ::  ' . $lang['TOPIC_SPLIT_NEW'] . ''; + $message = $lang['TOPIC_SPLIT'] . '

    ' . $lang['TOPIC_SPLIT_OLD'] . ''; + $message .= '  ::  ' . $lang['TOPIC_SPLIT_NEW'] . ''; // Log action - $log_action->mod('mod_topic_split', array( + $log_action->mod('mod_topic_split', [ 'forum_id' => $forum_id, 'forum_id_new' => $new_forum_id, 'topic_id' => $topic_id, 'topic_title' => get_topic_title($topic_id), 'topic_id_new' => $new_topic_id, - 'topic_title_new' => htmlCHR($_POST['subject']), - )); + 'topic_title_new' => htmlCHR($_POST['subject']) + ]); bb_die($message); } @@ -534,13 +534,13 @@ switch ($mode) { if (($total_posts = DB()->num_rows($result)) > 0) { $postrow = DB()->sql_fetchrowset($result); - $template->assign_vars(array( + $template->assign_vars([ 'FORUM_NAME' => htmlCHR($forum_name), 'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'S_SPLIT_ACTION' => 'modcp.php', 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORUM_SELECT' => get_forum_select('admin', 'new_forum_id', $forum_id), - )); + ]); for ($i = 0; $i < $total_posts; $i++) { $post_id = $postrow[$i]['post_id']; @@ -559,7 +559,7 @@ switch ($mode) { $row_class = !($i % 2) ? 'row1' : 'row2'; - $template->assign_block_vars('postrow', array( + $template->assign_block_vars('postrow', [ 'ROW_CLASS' => $row_class, 'POSTER_NAME' => wbr($poster), 'POST_DATE' => $post_date, @@ -567,8 +567,8 @@ switch ($mode) { 'CHECKBOX' => defined('BEGIN_CHECKBOX'), 'POST_ID' => $post_id, 'ROW_ID' => $i, - 'CB_ID' => 'cb_' . $i, - )); + 'CB_ID' => 'cb_' . $i + ]); if ($post_id == $topic_first_post_id) { define('BEGIN_CHECKBOX', true); @@ -576,7 +576,7 @@ switch ($mode) { } } } - $template->set_filenames(array('body' => 'modcp_split.tpl')); + $template->set_filenames(['body' => 'modcp_split.tpl']); break; case 'ip': @@ -606,11 +606,11 @@ switch ($mode) { $poster_id = $post_row['poster_id']; - $template->assign_vars(array( + $template->assign_vars([ 'TPL_MODCP_IP' => true, 'IP' => $ip_this_post, 'U_LOOKUP_IP' => "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=$ip_this_post&sid=" . $userdata['session_id'], - )); + ]); // // Get other IP's this user has posted under @@ -626,9 +626,7 @@ switch ($mode) { $i = 0; do { if ($row['poster_ip'] == $post_row['poster_ip']) { - $template->assign_vars(array( - 'POSTS' => $row['postings'], - )); + $template->assign_vars(['POSTS' => $row['postings']]); continue; } @@ -637,12 +635,12 @@ switch ($mode) { } $ip = ($rdns_ip_num == $ip || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip; - $template->assign_block_vars('iprow', array( + $template->assign_block_vars('iprow', [ 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', 'IP' => $ip, 'POSTS' => $row['postings'], 'U_LOOKUP_IP' => "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $ip . "&sid=" . $userdata['session_id'], - )); + ]); $i++; } while ($row = DB()->sql_fetchrow($result)); @@ -671,19 +669,19 @@ switch ($mode) { $id = $row['user_id']; $username = (!$row['username']) ? $lang['GUEST'] : $row['username']; - $template->assign_block_vars('userrow', array( + $template->assign_block_vars('userrow', [ 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', 'USERNAME' => wbr($username), 'POSTS' => $row['postings'], 'U_PROFILE' => ($id == GUEST_UID) ? "modcp.php?mode=ip&p=$post_id&t=$topic_id" : PROFILE_URL . $id, 'U_SEARCHPOSTS' => "search.php?search_author=1&uid=$id", - )); + ]); $i++; } while ($row = DB()->sql_fetchrow($result)); } - $template->set_filenames(array('body' => 'modcp.tpl')); + $template->set_filenames(['body' => 'modcp.tpl']); break; case 'post_pin': @@ -701,7 +699,7 @@ switch ($mode) { AND topic_show_first_post != $new_topic_status "; - $topic_csv = array(); + $topic_csv = []; foreach (DB()->fetch_rowset($sql) as $row) { $topic_csv[] = $row['topic_id']; @@ -722,11 +720,11 @@ switch ($mode) { $type = ($pin) ? 'mod_post_pin' : 'mod_post_unpin'; foreach ($log_topics as $topic_id => $topic_title) { - $log_action->mod($type, array( + $log_action->mod($type, [ 'forum_id' => $forum_id, 'topic_id' => $topic_id, - 'topic_title' => $topic_title, - )); + 'topic_title' => $topic_title + ]); } $msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED']; @@ -742,7 +740,7 @@ switch ($mode) { LIMIT 1 "; - $topic_csv = array(); + $topic_csv = []; foreach (DB()->fetch_rowset($sql) as $row) { $topic_csv[] = $row['topic_id']; @@ -763,11 +761,11 @@ switch ($mode) { $type = ($pin) ? 'mod_post_pin' : 'mod_post_unpin'; foreach ($log_topics as $topic_id => $topic_title) { - $log_action->mod($type, array( + $log_action->mod($type, [ 'forum_id' => $forum_id, 'topic_id' => $topic_id, 'topic_title' => $topic_title, - )); + ]); } $msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED']; @@ -780,7 +778,7 @@ switch ($mode) { break; } -$template->assign_vars(array('PAGE_TITLE' => $lang['MOD_CP'])); +$template->assign_vars(['PAGE_TITLE' => $lang['MOD_CP']]); require(PAGE_HEADER); diff --git a/poll.php b/poll.php index bd60286f1..e5b7dd27b 100644 --- a/poll.php +++ b/poll.php @@ -12,7 +12,7 @@ define('BB_SCRIPT', 'vote'); require __DIR__ . '/common.php'; // Start session management -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); $mode = (string)@$_POST['mode']; $topic_id = (int)@$_POST['topic_id']; diff --git a/posting.php b/posting.php index 1ac2633e6..c9f03bd83 100644 --- a/posting.php +++ b/posting.php @@ -13,7 +13,9 @@ require __DIR__ . '/common.php'; require INC_DIR . '/bbcode.php'; require ATTACH_DIR . '/attachment_mod.php'; -$page_cfg['load_tpl_vars'] = array('post_icons'); +$page_cfg['load_tpl_vars'] = [ + 'post_icons' +]; $submit = (bool)@$_REQUEST['post']; $preview = (bool)@$_REQUEST['preview']; @@ -28,11 +30,11 @@ $mode = (string)@$_REQUEST['mode']; $confirm = isset($_POST['confirm']); $refresh = $preview; -$orig_word = $replacement_word = array(); +$orig_word = $replacement_word = []; // Set topic type $topic_type = (@$_POST['topictype']) ? (int)$_POST['topictype'] : POST_NORMAL; -$topic_type = in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ? $topic_type : POST_NORMAL; +$topic_type = in_array($topic_type, [POST_NORMAL, POST_STICKY, POST_ANNOUNCE]) ? $topic_type : POST_NORMAL; $selected_rg = 0; $switch_rg_sig = 0; @@ -52,7 +54,7 @@ $user->session_start(); set_die_append_msg($forum_id, $topic_id); // What auth type do we need to check? -$is_auth = array(); +$is_auth = []; switch ($mode) { case 'newtopic': case 'new_rel': @@ -94,7 +96,7 @@ switch ($mode) { // Various lookups to find topic_id, forum_id, post_id etc $error_msg = ''; -$post_data = array(); +$post_data = []; switch ($mode) { case 'newtopic': case 'new_rel': @@ -278,17 +280,15 @@ if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' $topic_has_new_posts = true; foreach ($rowset as $i => $row) { - $template->assign_block_vars('new_posts', array( + $template->assign_block_vars('new_posts', [ 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POSTER' => profile_url($row), 'POSTER_NAME_JS' => addslashes($row['username']), 'POST_DATE' => bb_date($row['post_time'], $bb_cfg['post_date_format']), - 'MESSAGE' => get_parsed_post($row), - )); + 'MESSAGE' => get_parsed_post($row) + ]); } - $template->assign_vars(array( - 'TPL_SHOW_NEW_POSTS' => true, - )); + $template->assign_vars(['TPL_SHOW_NEW_POSTS' => true]); set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id); unset($rowset); @@ -301,15 +301,15 @@ if (($delete || $mode == 'delete') && !$confirm) { if (isset($_POST['cancel'])) { redirect(POST_URL . "$post_id#$post_id"); } - $hidden_fields = array( + $hidden_fields = [ 'p' => $post_id, - 'mode' => 'delete', - ); - print_confirmation(array( + 'mode' => 'delete' + ]; + print_confirmation([ 'QUESTION' => $lang['CONFIRM_DELETE'], 'FORM_ACTION' => POSTING_URL, - 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), - )); + 'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields) + ]); } elseif (($submit || $confirm) && !$topic_has_new_posts) { // // Submit post (newtopic, edit, reply, etc.) @@ -347,13 +347,13 @@ if (($delete || $mode == 'delete') && !$confirm) { if (!$post_data['first_post']) { \TorrentPier\Legacy\Post::delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id); } else { - redirect("modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']); + redirect('modcp.php?' . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']); } break; } if (!$error_msg) { - if (!in_array($mode, array('editpost', 'delete'))) { + if (!in_array($mode, ['editpost', 'delete'])) { $user_id = ($mode == 'reply' || $mode == 'newtopic') ? $userdata['user_id'] : $post_data['poster_id']; \TorrentPier\Legacy\Post::update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id); } @@ -376,7 +376,7 @@ if (($delete || $mode == 'delete') && !$confirm) { $forum_parent = $post_info['forum_parent']; } $count_rowset = DB()->fetch_rowset("SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_parent = $forum_parent"); - $sub_forums = array(); + $sub_forums = []; foreach ($count_rowset as $count_row) { if ($count_row['forum_id'] != $forum_id) { $sub_forums[] = $count_row['forum_id']; @@ -432,14 +432,14 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) { $preview_message = htmlCHR($message, false, ENT_NOQUOTES); $preview_message = bbcode2html($preview_message); - $template->assign_vars(array( + $template->assign_vars([ 'TPL_PREVIEW_POST' => true, 'TOPIC_TITLE' => wbr($preview_subject), 'POST_SUBJECT' => $preview_subject, 'POSTER_NAME' => $preview_username, 'POST_DATE' => bb_date(TIMENOW), - 'PREVIEW_MSG' => $preview_message, - )); + 'PREVIEW_MSG' => $preview_message + ]); } } else { // User default entry point @@ -455,8 +455,8 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) { if ($mode == 'quote') { if (!defined('WORD_LIST_OBTAINED')) { - $orig_word = array(); - $replace_word = array(); + $orig_word = []; + $replace_word = []; obtain_word_list($orig_word, $replace_word); define('WORD_LIST_OBTAINED', true); } @@ -489,9 +489,7 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) { } if ($error_msg) { - $template->assign_vars(array( - 'ERROR_MESSAGE' => $error_msg, - )); + $template->assign_vars(['ERROR_MESSAGE' => $error_msg]); } if (IS_GUEST || ($mode == 'editpost' && $post_info['poster_id'] == GUEST_UID)) { @@ -508,7 +506,7 @@ if (!IS_GUEST) { // Topic type selection $topic_type_toggle = ''; if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) { - $template->assign_block_vars('switch_type_toggle', array()); + $template->assign_block_vars('switch_type_toggle', []); if ($is_auth['auth_sticky']) { $topic_type_toggle .= '