From 552f2a24a482eb3a89d390405d6beea0021961b7 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Fri, 5 May 2017 00:59:21 +0300 Subject: [PATCH] Null coalescing operator can be used. --- admin/admin_board.php | 4 ++-- admin/admin_cron.php | 6 +++--- admin/admin_forums.php | 4 ++-- admin/admin_groups.php | 2 +- admin/admin_ranks.php | 2 +- admin/admin_sitemap.php | 2 +- admin/admin_smilies.php | 8 ++++---- bt/announce.php | 2 +- feed.php | 6 +++--- index.php | 2 +- library/attach_mod/displaying_torrent.php | 4 ++-- library/includes/classes/reflection.php | 4 ++-- library/includes/classes/utf8.php | 18 +++++++++--------- library/includes/core/mysql.php | 2 +- library/includes/functions.php | 16 ++++++++-------- library/includes/functions_admin_torrent.php | 6 +++--- library/includes/page_header.php | 3 +-- library/includes/sessions.php | 3 +-- library/includes/template.php | 6 +++--- login.php | 6 +++--- modcp.php | 16 ++++++++-------- posting.php | 2 +- search.php | 2 +- tracker.php | 4 ++-- viewforum.php | 4 ++-- viewtopic.php | 4 ++-- 26 files changed, 68 insertions(+), 70 deletions(-) diff --git a/admin/admin_board.php b/admin/admin_board.php index f359d244c..f08178dd9 100644 --- a/admin/admin_board.php +++ b/admin/admin_board.php @@ -31,7 +31,7 @@ if (!empty($setmodules)) { require __DIR__ . '/pagestart.php'; require INC_DIR . '/functions_selects.php'; -$mode = isset($_GET['mode']) ? $_GET['mode'] : ''; +$mode = $_GET['mode'] ?? ''; $return_links = array( 'index' => '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''), @@ -51,7 +51,7 @@ if (!$result = DB()->sql_query($sql)) { $config_value = $row['config_value']; $default_config[$config_name] = $config_value; - $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; + $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name]; if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') { diff --git a/admin/admin_cron.php b/admin/admin_cron.php index f7cd011c8..8fff900c9 100644 --- a/admin/admin_cron.php +++ b/admin/admin_cron.php @@ -30,11 +30,11 @@ if (!empty($setmodules)) { return; } -$mode = isset($_GET['mode']) ? $_GET['mode'] : ''; +$mode = $_GET['mode'] ?? ''; $job_id = isset($_GET['id']) ? (int)$_GET['id'] : ''; $submit = isset($_POST['submit']); $jobs = isset($_POST['select']) ? implode(',', $_POST['select']) : ''; -$cron_action = isset($_POST['cron_action']) ? $_POST['cron_action'] : ''; +$cron_action = $_POST['cron_action'] ?? ''; if ($mode == 'run' && !$job_id) { define('BB_ROOT', './../'); @@ -59,7 +59,7 @@ foreach ($sql as $row) { $config_value = $row['config_value']; $default_config[$config_name] = $config_value; - $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; + $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name]; if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { bb_update_config(array($config_name => $new[$config_name])); diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 0815c822d..4b0b76171 100644 --- a/admin/admin_forums.php +++ b/admin/admin_forums.php @@ -576,8 +576,8 @@ if ($mode) { $move_down_forum_id = false; $forums = $cat_forums[$cat_id]['f_ord']; $forum_order = $forum_info['forum_order']; - $prev_forum = (isset($forums[$forum_order - 10])) ? $forums[$forum_order - 10] : false; - $next_forum = (isset($forums[$forum_order + 10])) ? $forums[$forum_order + 10] : false; + $prev_forum = $forums[$forum_order - 10] ?? false; + $next_forum = $forums[$forum_order + 10] ?? false; // move selected forum ($forum_id) UP if ($move < 0 && $prev_forum) { diff --git a/admin/admin_groups.php b/admin/admin_groups.php index b671bfa87..8a51b03b6 100644 --- a/admin/admin_groups.php +++ b/admin/admin_groups.php @@ -104,7 +104,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) { $release_group = isset($_POST['release_group']) ? intval($_POST['release_group']) : 0; $group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : ''; $group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : ''; - $group_moderator = isset($_POST['username']) ? $_POST['username'] : ''; + $group_moderator = $_POST['username'] ?? ''; if ($group_name === '') { bb_die($lang['NO_GROUP_NAME']); diff --git a/admin/admin_ranks.php b/admin/admin_ranks.php index 75bec2f52..ab0dcf1cb 100644 --- a/admin/admin_ranks.php +++ b/admin/admin_ranks.php @@ -33,7 +33,7 @@ $_POST['special_rank'] = 1; $_POST['min_posts'] = -1; if (isset($_GET['mode']) || isset($_POST['mode'])) { - $mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode']; + $mode = $_GET['mode'] ?? $_POST['mode']; } else { // // These could be entered via a form button diff --git a/admin/admin_sitemap.php b/admin/admin_sitemap.php index 676b6f1a1..01e20ca69 100644 --- a/admin/admin_sitemap.php +++ b/admin/admin_sitemap.php @@ -41,7 +41,7 @@ if (!$result = DB()->sql_query($sql)) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = $config_value; - $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; + $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name]; if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { $new_params[$config_name] = $new[$config_name]; diff --git a/admin/admin_smilies.php b/admin/admin_smilies.php index 1e69fb524..3ccb43b5e 100644 --- a/admin/admin_smilies.php +++ b/admin/admin_smilies.php @@ -31,7 +31,7 @@ require('./pagestart.php'); // Check to see what mode we should operate in if (isset($_POST['mode']) || isset($_GET['mode'])) { - $mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode']; + $mode = $_POST['mode'] ?? $_GET['mode']; $mode = htmlspecialchars($mode); } else { $mode = ''; @@ -268,10 +268,10 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { break; case 'savenew': - $smile_code = (isset($_POST['smile_code'])) ? $_POST['smile_code'] : $_GET['smile_code']; - $smile_url = (isset($_POST['smile_url'])) ? $_POST['smile_url'] : $_GET['smile_url']; + $smile_code = $_POST['smile_code'] ?? $_GET['smile_code']; + $smile_url = $_POST['smile_url'] ?? $_GET['smile_url']; $smile_url = bb_ltrim(basename($smile_url), "'"); - $smile_emotion = (isset($_POST['smile_emotion'])) ? $_POST['smile_emotion'] : $_GET['smile_emotion']; + $smile_emotion = $_POST['smile_emotion'] ?? $_GET['smile_emotion']; $smile_code = trim($smile_code); $smile_url = trim($smile_url); $smile_emotion = trim($smile_emotion); diff --git a/bt/announce.php b/bt/announce.php index 97c272473..338fac1c2 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -90,7 +90,7 @@ foreach ($input_vars_num as $var_name) { $$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null; } // Passkey -$passkey = isset($$passkey_key) ? $$passkey_key : null; +$passkey = $$passkey_key ?? null; // Verify request // Required params (info_hash, peer_id, port, uploaded, downloaded, left, passkey) diff --git a/feed.php b/feed.php index d7de75514..726ca847f 100644 --- a/feed.php +++ b/feed.php @@ -30,9 +30,9 @@ require __DIR__ . '/common.php'; $user->session_start(array('req_login' => true)); -$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; -$type = isset($_POST['type']) ? $_POST['type'] : ''; -$id = isset($_POST['id']) ? $_POST['id'] : 0; +$mode = $_REQUEST['mode'] ?? ''; +$type = $_POST['type'] ?? ''; +$id = $_POST['id'] ?? 0; $timecheck = TIMENOW - 600; if (!$mode) { diff --git a/index.php b/index.php index ed60a32bf..689d604d7 100644 --- a/index.php +++ b/index.php @@ -254,7 +254,7 @@ foreach ($cat_forums as $cid => $c) { 'FORUM_DESC' => $f['forum_desc'], 'POSTS' => commify($f['forum_posts']), 'TOPICS' => commify($f['forum_topics']), - 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, + 'LAST_SF_ID' => $f['last_sf_id'] ?? null, 'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '', 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'], )); diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 275c83ad0..f67816919 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -56,7 +56,7 @@ $template->assign_vars(array( // Define show peers mode (count only || user names with complete % || full details) $cfg_sp_mode = $bb_cfg['bt_show_peers_mode']; -$get_sp_mode = (isset($_GET['spmode'])) ? $_GET['spmode'] : ''; +$get_sp_mode = $_GET['spmode'] ?? ''; $s_mode = 'count'; @@ -185,7 +185,7 @@ if ($tor_reged && $tor_info) { $bt_userdata = DB()->fetch_row($sql); - $user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null; + $user_status = $bt_userdata['user_status'] ?? null; if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) { if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) { diff --git a/library/includes/classes/reflection.php b/library/includes/classes/reflection.php index 13e11d4f5..e6c03c38c 100644 --- a/library/includes/classes/reflection.php +++ b/library/includes/classes/reflection.php @@ -165,7 +165,7 @@ class ReflectionTypeHint } // Next frame. - $next = isset($trace[$i + 1]) ? $trace[$i + 1] : null; + $next = $trace[$i + 1] ?? null; // Dummy frame before call_user_func*() frames. if (!isset($t['file']) && $next) { @@ -184,7 +184,7 @@ class ReflectionTypeHint if ($re_ignore && $next) { // Name of function "inside which" frame was generated. $frame_caller = (isset($next['class']) ? $next['class'] . $next['type'] : '') - . (isset($next['function']) ? $next['function'] : ''); + . ($next['function'] ?? ''); if (preg_match($re_ignore, $frame_caller)) { continue; } diff --git a/library/includes/classes/utf8.php b/library/includes/classes/utf8.php index f8da0f87e..90d166e3d 100644 --- a/library/includes/classes/utf8.php +++ b/library/includes/classes/utf8.php @@ -2846,9 +2846,9 @@ class utf8 } if ($is_converted) { $_REQUEST = - (isset($_COOKIE) ? $_COOKIE : array()) + - (isset($_POST) ? $_POST : array()) + - (isset($_GET) ? $_GET : array()); + ($_COOKIE ?? array()) + + ($_POST ?? array()) + + ($_GET ?? array()); } return true; } @@ -4049,13 +4049,13 @@ class utf8 { $fixed = false; #ATTENTION! HTTP_RAW_POST_DATA is only accessible when Content-Type of POST request is NOT default "application/x-www-form-urlencoded"! - $HTTP_RAW_POST_DATA = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' ? (isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : @file_get_contents('php://input')) : null; + $HTTP_RAW_POST_DATA = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' ? ($GLOBALS['HTTP_RAW_POST_DATA'] ?? @file_get_contents('php://input')) : null; if (ini_get('always_populate_raw_post_data')) { $GLOBALS['HTTP_RAW_POST_DATA'] = $HTTP_RAW_POST_DATA; } - foreach (array('_GET' => isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null, + foreach (array('_GET' => $_SERVER['QUERY_STRING'] ?? null, '_POST' => $HTTP_RAW_POST_DATA, - '_COOKIE' => isset($_SERVER['HTTP_COOKIE']) ? $_SERVER['HTTP_COOKIE'] : null, + '_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? null, ) as $k => $v) { if (!is_string($v)) { continue; @@ -4077,9 +4077,9 @@ class utf8 } if ($fixed) { $_REQUEST = - (isset($_COOKIE) ? $_COOKIE : array()) + - (isset($_POST) ? $_POST : array()) + - (isset($_GET) ? $_GET : array()); + ($_COOKIE ?? array()) + + ($_POST ?? array()) + + ($_GET ?? array()); } } diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index e0b605909..e25afd498 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -273,7 +273,7 @@ class sql_db $row = mysqli_fetch_assoc($result); if ($field_name) { - return isset($row[$field_name]) ? $row[$field_name] : false; + return $row[$field_name] ?? false; } return $row; diff --git a/library/includes/functions.php b/library/includes/functions.php index 47690d947..31c42896b 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -30,21 +30,21 @@ if (!defined('BB_ROOT')) { function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) { global $bb_cfg; - $ext = isset($bb_cfg['file_id_ext'][$ext_id]) ? $bb_cfg['file_id_ext'][$ext_id] : ''; + $ext = $bb_cfg['file_id_ext'][$ext_id] ?? ''; return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : ''); } function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100) { global $bb_cfg; - $base_path = isset($base_path) ? $base_path : $bb_cfg['avatars']['upload_path']; + $base_path = $base_path ?? $bb_cfg['avatars']['upload_path']; return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100) { global $bb_cfg; - $base_path = isset($base_path) ? $base_path : $bb_cfg['attach']['upload_path']; + $base_path = $base_path ?? $bb_cfg['attach']['upload_path']; return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } @@ -120,8 +120,8 @@ function get_last_read($topic_id = 0, $forum_id = 0) { global $tracking_topics, $tracking_forums, $user; - $t = isset($tracking_topics[$topic_id]) ? $tracking_topics[$topic_id] : 0; - $f = isset($tracking_forums[$forum_id]) ? $tracking_forums[$forum_id] : 0; + $t = $tracking_topics[$topic_id] ?? 0; + $f = $tracking_forums[$forum_id] ?? 0; return max($t, $f, $user->data['user_lastvisit']); } @@ -1017,7 +1017,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) { return (is_array($default)) ? array() : $default; } - $_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name]; + $_REQUEST[$var_name] = $_POST[$var_name] ?? $_GET[$var_name]; } if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) { @@ -1723,7 +1723,7 @@ function bb_realpath($path) function login_redirect($url = '') { - redirect(LOGIN_URL . '?redirect=' . (($url) ?: (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'))); + redirect(LOGIN_URL . '?redirect=' . (($url) ?: ($_SERVER['REQUEST_URI'] ?? '/'))); } function meta_refresh($url, $time = 5) @@ -1792,7 +1792,7 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis if ($action == 'list') { for ($i = 0; $i < count($listrow['lang_key']); $i++) { $selected = ($i == $selected_row) ? ' selected="selected"' : ''; - $l_value = (isset($lang[$listrow['lang_key'][$i]])) ? $lang[$listrow['lang_key'][$i]] : $listrow['lang_key'][$i]; + $l_value = $lang[$listrow['lang_key'][$i]] ?? $listrow['lang_key'][$i]; $res .= ''; } } else { diff --git a/library/includes/functions_admin_torrent.php b/library/includes/functions_admin_torrent.php index d2fb5d931..47bc20fb1 100644 --- a/library/includes/functions_admin_torrent.php +++ b/library/includes/functions_admin_torrent.php @@ -93,9 +93,9 @@ function set_tpl_vars_lang($default_cfg) foreach ($default_cfg as $config_name => $config_value) { $template->assign_vars(array( - 'L_' . strtoupper($config_name) => isset($lang[$config_name]) ? $lang[$config_name] : '', - 'L_' . strtoupper($config_name) . '_EXPL' => isset($lang[$config_name . '_expl']) ? $lang[$config_name . '_expl'] : '', - 'L_' . strtoupper($config_name) . '_HEAD' => isset($lang[$config_name . '_head']) ? $lang[$config_name . '_head'] : '', + 'L_' . strtoupper($config_name) => $lang[$config_name] ?? '', + 'L_' . strtoupper($config_name) . '_EXPL' => $lang[$config_name . '_expl'] ?? '', + 'L_' . strtoupper($config_name) . '_HEAD' => $lang[$config_name . '_head'] ?? '', )); } } diff --git a/library/includes/page_header.php b/library/includes/page_header.php index d16bd911a..4b261829a 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -125,8 +125,7 @@ $template->assign_vars(array( // The following assigns all _common_ variables that may be used at any point in a template $template->assign_vars(array( 'SIMPLE_HEADER' => !empty($gen_simple_header), - 'CONTENT_ENCODING' => isset($bb_cfg['lang'][$userdata['user_lang']]['encoding']) ? - $bb_cfg['lang'][$userdata['user_lang']]['encoding'] : 'utf-8', + 'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'] ?? 'utf-8', 'IN_ADMIN' => defined('IN_ADMIN'), 'SHOW_ADS' => (!$logged_in || isset($bb_cfg['show_ads_users'][$user->id]) || (!IS_AM && $user->show_ads)), diff --git a/library/includes/sessions.php b/library/includes/sessions.php index 9d2807304..b7e6442da 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -566,8 +566,7 @@ class user_common } require(LANG_DIR . 'main.php'); - setlocale(LC_ALL, isset($bb_cfg['lang'][$this->data['user_lang']]['locale']) ? - $bb_cfg['lang'][$this->data['user_lang']]['locale'] : 'en_US.UTF-8'); + setlocale(LC_ALL, $bb_cfg['lang'][$this->data['user_lang']]['locale'] ?? 'en_US.UTF-8'); $theme = setup_style(); $DeltaTime = new Date_Delta(); diff --git a/library/includes/template.php b/library/includes/template.php index 7cdaf142d..35c9bd617 100644 --- a/library/includes/template.php +++ b/library/includes/template.php @@ -1060,14 +1060,14 @@ class template $this->xs_started = 1; // adding language variable (eg: "english" or "german") // can be used to make truly multi-lingual templates - $this->vars['LANG'] = isset($this->vars['LANG']) ? $this->vars['LANG'] : $bb_cfg['default_lang']; + $this->vars['LANG'] = $this->vars['LANG'] ?? $bb_cfg['default_lang']; // adding current template $tpl = $this->root . '/'; if (substr($tpl, 0, 2) === './') { $tpl = substr($tpl, 2, strlen($tpl)); } - $this->vars['TEMPLATE'] = isset($this->vars['TEMPLATE']) ? $this->vars['TEMPLATE'] : $tpl; - $this->vars['TEMPLATE_NAME'] = isset($this->vars['TEMPLATE_NAME']) ? $this->vars['TEMPLATE_NAME'] : $this->tpl; + $this->vars['TEMPLATE'] = $this->vars['TEMPLATE'] ?? $tpl; + $this->vars['TEMPLATE_NAME'] = $this->vars['TEMPLATE_NAME'] ?? $this->tpl; } } diff --git a/login.php b/login.php index af077e1b3..34eecacc6 100644 --- a/login.php +++ b/login.php @@ -54,7 +54,7 @@ if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING } elseif (!empty($_POST['redirect'])) { $redirect_url = str_replace('&', '&', htmlspecialchars($_POST['redirect'])); } elseif (!empty($_SERVER['HTTP_REFERER']) && ($parts = @parse_url($_SERVER['HTTP_REFERER']))) { - $redirect_url = (isset($parts['path']) ? $parts['path'] : "index.php") . (isset($parts['query']) ? '?' . $parts['query'] : ''); + $redirect_url = ($parts['path'] ?? "index.php") . (isset($parts['query']) ? '?' . $parts['query'] : ''); } $redirect_url = str_replace('&admin=1', '', $redirect_url); @@ -73,8 +73,8 @@ if (isset($_REQUEST['admin']) && !IS_AM) { $mod_admin_login = (IS_AM && !$user->data['session_admin']); // login username & password -$login_username = ($mod_admin_login) ? $userdata['username'] : (isset($_POST['login_username']) ? $_POST['login_username'] : ''); -$login_password = isset($_POST['login_password']) ? $_POST['login_password'] : ''; +$login_username = ($mod_admin_login) ? $userdata['username'] : ($_POST['login_username'] ?? ''); +$login_password = $_POST['login_password'] ?? ''; // Проверка на неверную комбинацию логин/пароль $need_captcha = false; diff --git a/modcp.php b/modcp.php index 42c9066a6..cfc8a08f9 100644 --- a/modcp.php +++ b/modcp.php @@ -89,9 +89,9 @@ function validate_mode_condition($request_index, $mod_action = '') } // Obtain initial vars -$forum_id = isset($_REQUEST['f']) ? $_REQUEST['f'] : 0; -$topic_id = isset($_REQUEST['t']) ? $_REQUEST['t'] : 0; -$post_id = isset($_REQUEST['p']) ? $_REQUEST['p'] : 0; +$forum_id = $_REQUEST['f'] ?? 0; +$topic_id = $_REQUEST['t'] ?? 0; +$post_id = $_REQUEST['p'] ?? 0; $start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; $confirmed = isset($_POST['confirm']); @@ -185,7 +185,7 @@ if (!$is_auth['auth_mod']) { // Redirect to login page if not admin session if ($is_moderator && !$userdata['session_admin']) { - $redirect = isset($_POST['redirect']) ? $_POST['redirect'] : $_SERVER['REQUEST_URI']; + $redirect = $_POST['redirect'] ?? $_SERVER['REQUEST_URI']; redirect(LOGIN_URL . "?redirect=$redirect&admin=1"); } @@ -208,7 +208,7 @@ switch ($mode) { bb_die($lang['NONE_SELECTED']); } - $req_topics = isset($_POST['topic_id_list']) ? $_POST['topic_id_list'] : $topic_id; + $req_topics = $_POST['topic_id_list'] ?? $topic_id; validate_topics($forum_id, $req_topics, $topic_titles); if (!$req_topics or !$topic_csv = get_id_csv($req_topics)) { @@ -389,10 +389,10 @@ switch ($mode) { //mpd $delete_posts = isset($_POST['delete_posts']); $split = (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond'])); - $posts = (isset($_POST['post_id_list'])) ? $_POST['post_id_list'] : array(); + $posts = $_POST['post_id_list'] ?? array(); $start = /* (isset($_POST['start'])) ? intval($_POST['start']) : */ 0; - $topic_first_post_id = (isset($topic_row['topic_first_post_id'])) ? $topic_row['topic_first_post_id'] : ''; + $topic_first_post_id = $topic_row['topic_first_post_id'] ?? ''; $post_id_sql = $req_post_id_sql = array(); @@ -592,7 +592,7 @@ switch ($mode) { case 'ip': $anon = GUEST_UID; - $rdns_ip_num = (isset($_GET['rdns'])) ? $_GET['rdns'] : ""; + $rdns_ip_num = $_GET['rdns'] ?? ""; if (!$post_id) { bb_die($lang['NO_SUCH_POST']); diff --git a/posting.php b/posting.php index f49263339..e0b651937 100644 --- a/posting.php +++ b/posting.php @@ -552,7 +552,7 @@ if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) { } } //bt -$topic_dl_type = (isset($post_info['topic_dl_type'])) ? $post_info['topic_dl_type'] : 0; +$topic_dl_type = $post_info['topic_dl_type'] ?? 0; if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod'])) { $sql = " diff --git a/search.php b/search.php index 8603a6dfd..57f17cdb3 100644 --- a/search.php +++ b/search.php @@ -89,7 +89,7 @@ $tracking_forums = get_tracks('forum'); if ($mode =& $_REQUEST['mode']) { // This handles the simple windowed user search functions called from various other scripts if ($mode == 'searchuser') { - $username = isset($_POST['search_username']) ? $_POST['search_username'] : ''; + $username = $_POST['search_username'] ?? ''; username_search($username); exit; } diff --git a/tracker.php b/tracker.php index f62266a71..8d0a39edb 100644 --- a/tracker.php +++ b/tracker.php @@ -713,8 +713,8 @@ if ($allowed_forums) { $passkey = DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$user_id . " LIMIT 1"); // Build torrents table foreach (DB()->fetch_rowset($sql) as $tor) { - $dl = isset($tor['speed_down']) ? $tor['speed_down'] : 0; - $ul = isset($tor['speed_up']) ? $tor['speed_up'] : 0; + $dl = $tor['speed_down'] ?? 0; + $ul = $tor['speed_up'] ?? 0; $seeds = $tor['seeders']; $leechs = $tor['leechers']; diff --git a/viewforum.php b/viewforum.php index 2b674599b..c118ece44 100644 --- a/viewforum.php +++ b/viewforum.php @@ -99,7 +99,7 @@ $mod_redirect_url = ''; $tor_status = -1; // all by default if ($is_auth['auth_mod']) { - $redirect = isset($_POST['redirect']) ? $_POST['redirect'] : @$_SERVER['REQUEST_URI']; + $redirect = $_POST['redirect'] ?? @$_SERVER['REQUEST_URI']; $redirect = url_arg($redirect, 'mod', 1, '&'); $mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1"; @@ -474,7 +474,7 @@ foreach ($topic_rowset as $topic) { 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', - 'ATTACH' => isset($topic['topic_attachment']) ? $topic['topic_attachment'] : false, + 'ATTACH' => $topic['topic_attachment'] ?? false, 'STATUS' => $topic['topic_status'], 'TYPE' => $topic['topic_type'], 'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker']), diff --git a/viewtopic.php b/viewtopic.php index 4c53ab47e..fbb3884b6 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -195,7 +195,7 @@ $moderation = (!empty($_REQUEST['mod']) && $is_auth['auth_mod']); $mod_redirect_url = ''; if ($is_auth['auth_mod']) { - $redirect = isset($_POST['redirect']) ? $_POST['redirect'] : @$_SERVER['REQUEST_URI']; + $redirect = $_POST['redirect'] ?? @$_SERVER['REQUEST_URI']; $redirect = url_arg($redirect, 'mod', 1, '&'); $mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1"; @@ -818,7 +818,7 @@ foreach ($is_auth as $name => $is) { } $template->assign_vars(array( - 'PG_ROW_CLASS' => isset($pg_row_class) ? $pg_row_class : 'row1', + 'PG_ROW_CLASS' => $pg_row_class ?? 'row1', )); if (IS_ADMIN) {