Elvis operator can be used.

This commit is contained in:
Yuriy Pikhtarev 2017-05-05 00:58:40 +03:00
parent 891ef417bc
commit 6a3bf7cea6
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
16 changed files with 33 additions and 33 deletions

View file

@ -207,7 +207,7 @@ if ($mode) {
}
$cat_id = $parent['cat_id'];
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_parent = ($parent['forum_parent']) ?: $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
} else {
$max_order = get_max_forum_order($cat_id);
@ -273,7 +273,7 @@ if ($mode) {
}
$cat_id = $parent['cat_id'];
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_parent = ($parent['forum_parent']) ?: $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
if ($forum_id == $forum_parent) {
@ -750,7 +750,7 @@ if (!$mode || $show_main_page) {
'FORUM_DESC' => htmlCHR($forum_rows[$j]['forum_desc']),
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
'NUM_POSTS' => $forum_rows[$j]['forum_posts'],
'PRUNE_DAYS' => ($forum_rows[$j]['prune_days']) ? $forum_rows[$j]['prune_days'] : '-',
'PRUNE_DAYS' => ($forum_rows[$j]['prune_days']) ?: '-',
'ORDER' => $forum_rows[$j]['forum_order'],
'FORUM_ID' => $forum_rows[$j]['forum_id'],

View file

@ -38,7 +38,7 @@ if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) {
$template->assign_vars(array(
'S_ACTION' => 'admin_terms.php',
'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'],
'MESSAGE' => ($bb_cfg['terms']) ? $bb_cfg['terms'] : '',
'MESSAGE' => ($bb_cfg['terms']) ?: '',
'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($_POST['message']) : '',
));

View file

@ -451,7 +451,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
{
global $user;
$file = ($file) ? $file : 'req/' . date('m-d');
$file = ($file) ?: 'req/' . date('m-d');
$str = array();
$str[] = date('m-d H:i:s');
if ($prepend_str !== false) {

View file

@ -57,10 +57,10 @@ $full_url = isset($_POST['full_url']) ? str_replace('&', '&', htmlspecialcha
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search') {
$redirect_type = "search.php";
$redirect = ($full_url) ? $full_url : "$dl_key=1";
$redirect = ($full_url) ?: "$dl_key=1";
} else {
$redirect_type = (!$topic_id) ? "viewforum.php" : "viewtopic.php";
$redirect = ($full_url) ? $full_url : ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
$redirect = ($full_url) ?: ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
}
// Start session management

View file

@ -42,7 +42,7 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
$from = (!empty($row['user_from'])) ? $row['user_from'] : '';
$joined = bb_date($row['user_regdate']);
$user_time = (!empty($row['user_time'])) ? bb_date($row['user_time']) : $lang['NONE'];
$posts = ($row['user_posts']) ? $row['user_posts'] : 0;
$posts = ($row['user_posts']) ?: 0;
$pm = ($bb_cfg['text_buttons']) ? '<a class="txtb" href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $lang['SEND_PM_TXTB'] . '</a>' : '<a href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>';
$avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);

View file

@ -94,7 +94,7 @@ $tor_auth_del = ($tor_auth && $tor_reged);
$tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO'];
$download_link = DOWNLOAD_URL . $attach_id;
$description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $display_name);
$description = ($comment) ?: preg_replace("#.torrent$#i", '', $display_name);
if ($tor_auth_reg || $tor_auth_del) {
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'reg\'}); return false;">' . $lang['BT_REG_ON_TRACKER'] . '</a>';
@ -155,7 +155,7 @@ if ($tor_auth) {
}
if ($tor_reged && $tor_info) {
$tor_size = ($tor_info['size']) ? $tor_info['size'] : 0;
$tor_size = ($tor_info['size']) ?: 0;
$tor_id = $tor_info['topic_id'];
$tor_type = $tor_info['tor_type'];
@ -498,14 +498,14 @@ if ($tor_reged && $tor_info) {
$seeders[strlen($seeders) - 9] = ' ';
$template->assign_vars(array(
'SEED_LIST' => $seeders,
'SEED_COUNT' => ($seed_count) ? $seed_count : 0,
'SEED_COUNT' => ($seed_count) ?: 0,
));
}
if ($s_mode != 'full' && $leechers) {
$leechers[strlen($leechers) - 9] = ' ';
$template->assign_vars(array(
'LEECH_LIST' => $leechers,
'LEECH_COUNT' => ($leech_count) ? $leech_count : 0,
'LEECH_COUNT' => ($leech_count) ?: 0,
));
}
}

View file

@ -778,7 +778,7 @@ class attach_parent
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$allowed_filesize = $row['max_filesize'] ? $row['max_filesize'] : $attach_config['max_filesize'];
$allowed_filesize = $row['max_filesize'] ?: $attach_config['max_filesize'];
$cat_id = (int) $row['cat_id'];
$auth_cache = trim($row['forum_permissions']);

View file

@ -102,7 +102,7 @@ foreach ($cron_jobs as $job) {
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
if ($cron_runtime_log) {
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . '/' . basename($runtime_log_file));
}
}

View file

@ -72,7 +72,7 @@ function get_tracks($type)
trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR);
}
$tracks = !empty($_COOKIE[$c_name]) ? @unserialize($_COOKIE[$c_name]) : false;
return ($tracks) ? $tracks : array();
return ($tracks) ?: array();
}
function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW)
@ -1158,7 +1158,7 @@ function show_bt_userdata($user_id)
'USER_RATIO' => get_bt_ratio($btu),
'MIN_DL_FOR_RATIO' => humn_size(MIN_DL_FOR_RATIO),
'MIN_DL_BYTES' => MIN_DL_FOR_RATIO,
'AUTH_KEY' => ($btu['auth_key']) ? $btu['auth_key'] : $lang['NONE'],
'AUTH_KEY' => ($btu['auth_key']) ?: $lang['NONE'],
'TD_DL' => humn_size($btu['down_today']),
'TD_UL' => humn_size($btu['up_today']),
@ -1723,7 +1723,7 @@ function bb_realpath($path)
function login_redirect($url = '')
{
redirect(LOGIN_URL . '?redirect=' . (($url) ? $url : (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/')));
redirect(LOGIN_URL . '?redirect=' . (($url) ?: (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/')));
}
function meta_refresh($url, $time = 5)

View file

@ -124,9 +124,9 @@ function fixSqlLog() {
echo '</div><!-- / sqlLogHead -->';
if ($sql_log) {
echo '<div class="sqlLog" id="sqlLog">' . ($sql_log ? $sql_log : '') . '</div><!-- / sqlLog --><br clear="all" />';
echo '<div class="sqlLog" id="sqlLog">' . ($sql_log ?: '') . '</div><!-- / sqlLog --><br clear="all" />';
}
?>
<script type="text/javascript">
$(document).ready(fixSqlLog);
</script>
</script>

View file

@ -53,7 +53,7 @@ if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain watch topic information #2');
}
$row = DB()->sql_fetchrow($result);
$watch_count = ($row['watch_count']) ? $row['watch_count'] : 0;
$watch_count = ($row['watch_count']) ?: 0;
DB()->sql_freeresult($result);
if ($watch_count > 0) {

View file

@ -74,8 +74,8 @@ if ($releasing) {
'U_VIEW_FORUM' => FORUM_URL . $row['forum_id'],
'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'],
'TOR_TYPE' => is_gold($row['tor_type']),
'TOPIC_SEEDERS' => ($row['seeders']) ? $row['seeders'] : 0,
'TOPIC_LEECHERS' => ($row['leechers']) ? $row['leechers'] : 0,
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_UP' => ($row['speed_up']) ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-',
));
@ -94,8 +94,8 @@ if ($seeding) {
'U_VIEW_FORUM' => FORUM_URL . $row['forum_id'],
'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'],
'TOR_TYPE' => is_gold($row['tor_type']),
'TOPIC_SEEDERS' => ($row['seeders']) ? $row['seeders'] : 0,
'TOPIC_LEECHERS' => ($row['leechers']) ? $row['leechers'] : 0,
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_UP' => ($row['speed_up']) ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-',
));
@ -117,8 +117,8 @@ if ($leeching) {
'U_VIEW_TOPIC' => TOPIC_URL . $row['topic_id'],
'COMPL_PERC' => $compl_perc,
'TOR_TYPE' => is_gold($row['tor_type']),
'TOPIC_SEEDERS' => ($row['seeders']) ? $row['seeders'] : 0,
'TOPIC_LEECHERS' => ($row['leechers']) ? $row['leechers'] : 0,
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_DOWN' => ($row['speed_down']) ? humn_size($row['speed_down'], 0, 'KB') . '/s' : '-',
));

View file

@ -643,7 +643,7 @@ $template->assign_vars(array(
'MESSAGE' => $message,
'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
'ATTACH_RG_SIG' => ($switch_rg_sig) ? $switch_rg_sig : false,
'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false,
'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc" : '',

View file

@ -1389,7 +1389,7 @@ if ($mode == 'read') {
'INBOX_LIMIT_IMG_WIDTH' => max(4, $box_limit_img_length),
'INBOX_LIMIT_PERCENT' => $box_limit_percent,
'BOX_SIZE_STATUS' => ($l_box_size_status) ? $l_box_size_status : '',
'BOX_SIZE_STATUS' => ($l_box_size_status) ?: '',
'L_FROM_OR_TO' => ($folder == 'inbox' || $folder == 'savebox') ? $lang['FROM'] : $lang['TO'],

View file

@ -417,7 +417,7 @@ if (!$set_default) {
}
} elseif ($search_id && $previous_settings[$poster_id_key]) {
$poster_id_val = intval($previous_settings[$poster_id_key]);
$poster_name_val = ($previous_settings[$poster_name_key]) ? $previous_settings[$poster_name_key] : '';
$poster_name_val = ($previous_settings[$poster_name_key]) ?: '';
}
if ($req_poster_id) {
@ -764,10 +764,10 @@ if ($allowed_forums) {
'TOR_SIZE' => humn_size($size),
'UL_SPEED' => $ul_sp,
'DL_SPEED' => $dl_sp,
'SEEDS' => ($seeds) ? $seeds : 0,
'SEEDS' => ($seeds) ?: 0,
'SEEDS_TITLE' => ($seeds) ? $lang['SEEDERS'] : ($lang['SEED_NOT_SEEN'] . ":\n " . (($s_last) ? bb_date($s_last, $date_format) : $lang['NEVER'])),
'LEECHS' => ($leechs) ? $leechs : 0,
'COMPLETED' => ($compl) ? $compl : 0,
'LEECHS' => ($leechs) ?: 0,
'COMPLETED' => ($compl) ?: 0,
'REPLIES' => $tor['topic_replies'],
'VIEWS' => $tor['topic_views'],
'ADDED_RAW' => $tor['reg_time'],

View file

@ -606,7 +606,7 @@ for ($i = 0; $i < $total_posts; $i++) {
$mc_comment = $postrow[$i]['mc_comment'];
$mc_user_id = profile_url(array('username' => $postrow[$i]['mc_username'], 'user_id' => $postrow[$i]['mc_user_id'], 'user_rank' => $postrow[$i]['mc_user_rank']));
$rg_id = ($postrow[$i]['poster_rg_id']) ? $postrow[$i]['poster_rg_id'] : 0;
$rg_id = ($postrow[$i]['poster_rg_id']) ?: 0;
$rg_avatar = get_avatar(GROUP_AVATAR_MASK . $rg_id, $postrow[$i]['rg_avatar_id']);
$rg_name = ($postrow[$i]['group_name']) ? htmlCHR($postrow[$i]['group_name']) : '';
$rg_signature = ($postrow[$i]['group_signature']) ? bbcode2html(htmlCHR($postrow[$i]['group_signature'])) : '';