From 147d61169abbe01252e9fb815da97292c304a783 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Thu, 12 May 2016 21:44:34 +0300 Subject: [PATCH] Logical operators should be avoided The or operator does not have the same precedence as ||. This could lead to unexpected behavior, use || instead. The and operator does not have the same precedence as &&. This could lead to unexpected behavior, use && instead. --- admin/admin_forum_prune.php | 4 ++-- admin/admin_log.php | 6 +++--- admin/admin_rebuild_search.php | 2 +- admin/admin_ug_auth.php | 4 ++-- bt/includes/init_tr.php | 11 +++++++---- group_edit.php | 2 +- index.php | 4 ++-- install/upgrade/r583-convert_avatars.php | 2 +- library/ajax/avatar.php | 2 +- library/ajax/change_user_opt.php | 2 +- library/ajax/change_user_rank.php | 2 +- library/ajax/edit_group_profile.php | 2 +- library/ajax/edit_user_profile.php | 4 ++-- library/ajax/group_membership.php | 2 +- library/ajax/posts.php | 2 +- library/config.php | 10 ++++++++++ library/includes/datastore/build_cat_forums.php | 4 ++-- library/includes/functions_admin.php | 8 ++++---- library/includes/functions_post.php | 2 +- library/includes/posting_tpl.php | 6 +++--- library/includes/ucp/register.php | 8 ++++---- library/includes/ucp/viewprofile.php | 2 +- modcp.php | 2 +- posting.php | 2 +- search.php | 4 ++-- styles/templates/default/tpl_config.php | 2 +- tracker.php | 2 +- viewforum.php | 6 +++--- viewtopic.php | 4 ++-- 29 files changed, 63 insertions(+), 50 deletions(-) diff --git a/admin/admin_forum_prune.php b/admin/admin_forum_prune.php index 86e8968e3..2a9c7c619 100644 --- a/admin/admin_forum_prune.php +++ b/admin/admin_forum_prune.php @@ -13,11 +13,11 @@ $prune_performed = false; if (isset($_REQUEST['submit'])) { - if (!$var =& $_REQUEST['f'] OR !$f_selected = get_id_ary($var)) + if (!($var =& $_REQUEST['f']) || !($f_selected = get_id_ary($var))) { bb_die('Forum not selected'); } - if (!$var =& $_REQUEST['prunedays'] OR !$prunedays = abs(intval($var))) + if (!($var =& $_REQUEST['prunedays']) || !($prunedays = abs(intval($var)))) { bb_die($lang['NOT_DAYS']); } diff --git a/admin/admin_log.php b/admin/admin_log.php index 9d5285681..023cebb7b 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -138,7 +138,7 @@ if ($var =& $_REQUEST[$topic_key]) // Sort $sort_val = $def_sort; -if ($var =& $_REQUEST[$sort_key] AND $var != $def_sort) +if (($var =& $_REQUEST[$sort_key]) && ($var != $def_sort)) { $sort_val = ($var == $sort_asc) ? $sort_asc : $sort_desc; $url = url_arg($url, $sort_key, $sort_val); @@ -148,12 +148,12 @@ if ($var =& $_REQUEST[$sort_key] AND $var != $def_sort) $datetime_val = $def_datetime; $daysback_val = $def_days; -if ($var =& $_REQUEST[$daysback_key] AND $var != $def_days) +if (($var =& $_REQUEST[$daysback_key]) && ($var != $def_days)) { $daysback_val = max(intval($var), 1); $url = url_arg($url, $daysback_key, $daysback_val); } -if ($var =& $_REQUEST[$datetime_key] AND $var != $def_datetime) +if (($var =& $_REQUEST[$datetime_key]) && ($var != $def_datetime)) { $tz = TIMENOW + (3600 * $bb_cfg['board_timezone']); if (($tmp_timestamp = strtotime($var, $tz)) > 0) diff --git a/admin/admin_rebuild_search.php b/admin/admin_rebuild_search.php index abc0663a2..6bfb3ea5e 100644 --- a/admin/admin_rebuild_search.php +++ b/admin/admin_rebuild_search.php @@ -177,7 +177,7 @@ if ($mode == 'submit' || $mode == 'refresh') $timer_expired = false; $words_sql = array(); - while ($row = DB()->fetch_next($result) AND !$timer_expired) + while (($row = DB()->fetch_next($result)) && !$timer_expired) { set_time_limit(600); $start_post_id = ($num_rows == 0) ? $row['post_id'] : $start_post_id; diff --git a/admin/admin_ug_auth.php b/admin/admin_ug_auth.php index 3fd305d5c..b098c7075 100644 --- a/admin/admin_ug_auth.php +++ b/admin/admin_ug_auth.php @@ -215,7 +215,7 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) 'CAT_HREF' => "$base_url&c=$c_id", )); - if (!$c =& $_REQUEST['c'] OR !in_array($c, array('all', $c_id)) OR empty($c_data['forums'])) + if (!($c =& $_REQUEST['c']) || !in_array($c, array('all', $c_id)) || empty($c_data['forums'])) { continue; } @@ -343,7 +343,7 @@ else if ($mode == 'group' && $group_id) 'CAT_HREF' => "$base_url&c=$c_id", )); - if (!$c =& $_REQUEST['c'] OR !in_array($c, array('all', $c_id)) OR empty($c_data['forums'])) + if (!($c =& $_REQUEST['c']) || !in_array($c, array('all', $c_id)) || empty($c_data['forums'])) { continue; } diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php index 1ae4d5cbe..7f3040725 100644 --- a/bt/includes/init_tr.php +++ b/bt/includes/init_tr.php @@ -221,7 +221,7 @@ class sql_db { $num_rows = false; - if ($result OR $result = $this->result) + if ($result || ($result = $this->result)) { $num_rows = is_resource($result) ? mysql_num_rows($result) : false; } @@ -368,13 +368,16 @@ class sql_db $info[] = "$num rows"; } - if (is_resource($this->link) AND $ext = mysql_info($this->link)) + if (is_resource($this->link) && ($ext = mysql_info($this->link))) { $info[] = "$ext"; } - elseif (!$num && ($aff = $this->affected_rows($this->result) AND $aff != -1)) + elseif (!$num && ($aff = $this->affected_rows($this->result))) { - $info[] = "$aff rows"; + if ($aff != -1) + { + $info[] = "$aff rows"; + } } return join(', ', $info); diff --git a/group_edit.php b/group_edit.php index 11eb2002d..4b1daa07c 100644 --- a/group_edit.php +++ b/group_edit.php @@ -39,7 +39,7 @@ if ($is_moderator) require(INC_DIR .'functions_upload.php'); $upload = new upload_common(); - 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']) && $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) { $avatar_ext_id = (int) $upload->file_ext_id; } diff --git a/index.php b/index.php index a3246e96e..44580d6c2 100644 --- a/index.php +++ b/index.php @@ -78,7 +78,7 @@ $excluded_forums_csv = $user->get_excluded_forums(AUTH_VIEW); $only_new = $user->opt_js['only_new']; // Validate requested category id -if ($viewcat AND !$viewcat =& $forums['c'][$viewcat]['cat_id']) +if ($viewcat && !($viewcat =& $forums['c'][$viewcat]['cat_id'])) { redirect("index.php"); } @@ -136,7 +136,7 @@ $cache_name = 'index_sql_' . md5($sql); if (!$cache->has($cache_name)) { $cat_forums = []; foreach (DB()->fetch_rowset($sql) as $row) { - if (!$cat_id = $row['cat_id'] OR !$forum_id = $row['forum_id']) { + if (!($cat_id = $row['cat_id']) || !($forum_id = $row['forum_id'])) { continue; } diff --git a/install/upgrade/r583-convert_avatars.php b/install/upgrade/r583-convert_avatars.php index 0a318fbc9..10377534e 100644 --- a/install/upgrade/r583-convert_avatars.php +++ b/install/upgrade/r583-convert_avatars.php @@ -50,7 +50,7 @@ if ($confirm) { ); $upload = new upload_common(); - if ($upload->init($bb_cfg['avatars'], $FILE, false) AND $upload->store('avatar', $row)) { + if ($upload->init($bb_cfg['avatars'], $FILE, false) && $upload->store('avatar', $row)) { DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$upload->file_ext_id} WHERE user_id = {$row['user_id']} LIMIT 1"); $avatars_ok++; } else { diff --git a/library/ajax/avatar.php b/library/ajax/avatar.php index ef61deacf..97ec004e0 100644 --- a/library/ajax/avatar.php +++ b/library/ajax/avatar.php @@ -7,7 +7,7 @@ global $bb_cfg, $lang, $user; $mode = (string) $this->request['mode']; $user_id = (int) $this->request['user_id']; -if (!$user_id OR !$u_data = get_userdata($user_id)) +if (!$user_id || !($u_data = get_userdata($user_id))) { $this->ajax_die('Invalid user_id'); } diff --git a/library/ajax/change_user_opt.php b/library/ajax/change_user_opt.php index 5c8981022..f6f9be670 100644 --- a/library/ajax/change_user_opt.php +++ b/library/ajax/change_user_opt.php @@ -7,7 +7,7 @@ global $bf, $lang; $user_id = (int) $this->request['user_id']; $new_opt = \Zend\Json\Json::decode($this->request['user_opt'], \Zend\Json\Json::TYPE_ARRAY); -if (!$user_id OR !$u_data = get_userdata($user_id)) +if (!$user_id || !($u_data = get_userdata($user_id))) { $this->ajax_die('invalid user_id'); } diff --git a/library/ajax/change_user_rank.php b/library/ajax/change_user_rank.php index a6d283aa0..08342b420 100644 --- a/library/ajax/change_user_rank.php +++ b/library/ajax/change_user_rank.php @@ -7,7 +7,7 @@ global $datastore, $lang; $ranks = $datastore->get('ranks'); $rank_id = intval($this->request['rank_id']); -if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id)) +if (!($user_id = intval($this->request['user_id'])) || !($profiledata = get_userdata($user_id))) { $this->ajax_die("invalid user_id: $user_id"); } diff --git a/library/ajax/edit_group_profile.php b/library/ajax/edit_group_profile.php index 5c0cc9e54..8621f75fc 100644 --- a/library/ajax/edit_group_profile.php +++ b/library/ajax/edit_group_profile.php @@ -4,7 +4,7 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $bb_cfg, $userdata, $lang; -if (!$group_id = intval($this->request['group_id']) OR !$group_info = get_group_data($group_id)) +if (!($group_id = intval($this->request['group_id'])) || !($group_info = get_group_data($group_id))) { $this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']); } diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php index 04e11f890..d9b37fd96 100644 --- a/library/ajax/edit_user_profile.php +++ b/library/ajax/edit_user_profile.php @@ -4,7 +4,7 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $bb_cfg, $lang; -if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id)) +if (!($user_id = intval($this->request['user_id'])) || !($profiledata = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } @@ -112,7 +112,7 @@ switch ($field) case 'user_regdate': case 'user_lastvisit': $tz = TIMENOW + (3600 * $bb_cfg['board_timezone']); - if (($value = strtotime($value, $tz)) < $bb_cfg['board_startdate'] OR $value > TIMENOW) + if ((($value = strtotime($value, $tz)) < $bb_cfg['board_startdate']) || ($value > TIMENOW)) { $this->ajax_die($lang['INVALID_DATE'] . $this->request['value']); } diff --git a/library/ajax/group_membership.php b/library/ajax/group_membership.php index 78b9c3071..8457f60fb 100644 --- a/library/ajax/group_membership.php +++ b/library/ajax/group_membership.php @@ -4,7 +4,7 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $lang, $user; -if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id)) +if (!($user_id = intval($this->request['user_id'])) || !($profiledata = get_userdata($user_id))) { $this->ajax_die("invalid user_id: $user_id"); } diff --git a/library/ajax/posts.php b/library/ajax/posts.php index e8e8c8bae..e518f305b 100644 --- a/library/ajax/posts.php +++ b/library/ajax/posts.php @@ -253,7 +253,7 @@ switch($this->request['type']) $where_sql = (IS_GUEST) ? "p.poster_ip = '". USER_IP ."'" : "p.poster_id = {$userdata['user_id']}"; $sql = "SELECT MAX(p.post_time) AS last_post_time FROM ". BB_POSTS ." p WHERE $where_sql"; - if ($row = DB()->fetch_row($sql) AND $row['last_post_time']) + if (($row = DB()->fetch_row($sql)) && $row['last_post_time']) { if ($userdata['user_level'] == USER) { diff --git a/library/config.php b/library/config.php index c8cd529a5..2d37eda86 100644 --- a/library/config.php +++ b/library/config.php @@ -26,6 +26,16 @@ $config = [ 'directory' => __DIR__ . '/../internal_data/cache', ], ], + /*'cache' => [ + 'adapter' => \TorrentPier\Cache\MemoryAdapter::class, + 'options' => [ + 'servers' => [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'weight' => 100, + ], + ], + ],*/ ], // Database diff --git a/library/includes/datastore/build_cat_forums.php b/library/includes/datastore/build_cat_forums.php index c4ca1a7cd..32d9d5dfe 100644 --- a/library/includes/datastore/build_cat_forums.php +++ b/library/includes/datastore/build_cat_forums.php @@ -128,7 +128,7 @@ $this->store('viewtopic_forum_select', $data); // // latest_news // -if ($bb_cfg['show_latest_news'] AND $news_forum_ids = $bb_cfg['latest_news_forum_id']) +if ($bb_cfg['show_latest_news'] && ($news_forum_ids = $bb_cfg['latest_news_forum_id'])) { $news_count = max($bb_cfg['latest_news_count'], 1); @@ -147,7 +147,7 @@ if ($bb_cfg['show_latest_news'] AND $news_forum_ids = $bb_cfg['latest_news_forum // // Network_news // -if ($bb_cfg['show_network_news'] AND $net_forum_ids = $bb_cfg['network_news_forum_id']) +if ($bb_cfg['show_network_news'] && ($net_forum_ids = $bb_cfg['network_news_forum_id'])) { $net_count = max($bb_cfg['network_news_count'], 1); diff --git a/library/includes/functions_admin.php b/library/includes/functions_admin.php index a2d54e5b4..05e9661d7 100644 --- a/library/includes/functions_admin.php +++ b/library/includes/functions_admin.php @@ -73,7 +73,7 @@ function sync ($type, $id) $all_topics = ($id === 'all'); - if (!$all_topics AND !$topic_csv = get_id_csv($id)) + if (!$all_topics && !($topic_csv = get_id_csv($id))) { break; } @@ -137,7 +137,7 @@ function sync ($type, $id) $all_users = ($id === 'all'); - if (!$all_users AND !$user_csv = get_id_csv($id)) + if (!$all_users && !($user_csv = get_id_csv($id))) { break; } @@ -192,7 +192,7 @@ function topic_delete ($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pr $prune = ($mode_or_topic_id === 'prune'); - if (!$prune AND !$topic_csv = get_id_csv($mode_or_topic_id)) + if (!$prune && !($topic_csv = get_id_csv($mode_or_topic_id))) { return false; } @@ -409,7 +409,7 @@ function topic_move ($topic_id, $to_forum_id, $from_forum_id = null, $leave_shad } } - if (!$topics OR !$topic_csv = get_id_csv(array_keys($topics))) + if (!$topics || !($topic_csv = get_id_csv(array_keys($topics)))) { return false; } diff --git a/library/includes/functions_post.php b/library/includes/functions_post.php index 3d6af1f22..f2a32672e 100644 --- a/library/includes/functions_post.php +++ b/library/includes/functions_post.php @@ -83,7 +83,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ { $sql = "SELECT MAX(p.post_time) AS last_post_time FROM ". BB_POSTS ." p WHERE $where_sql"; - if ($row = DB()->fetch_row($sql) AND $row['last_post_time']) + if (($row = DB()->fetch_row($sql)) && $row['last_post_time']) { if ($userdata['user_level'] == USER) { diff --git a/library/includes/posting_tpl.php b/library/includes/posting_tpl.php index 10a608a03..7ee21264c 100644 --- a/library/includes/posting_tpl.php +++ b/library/includes/posting_tpl.php @@ -8,15 +8,15 @@ $edit_tpl_mode = ($can_edit_tpl && !empty($_REQUEST['edit_tpl'])); // forum_data $sql = "SELECT forum_name, allow_reg_tracker, forum_tpl_id FROM ". BB_FORUMS ." WHERE forum_id = $forum_id LIMIT 1"; -if (!$forum_id OR !$f_data = DB()->fetch_row($sql)) +if (!$forum_id || !($f_data = DB()->fetch_row($sql))) { bb_die($lang['FORUM_NOT_EXIST']); } // tpl_data -$tpl_data = array(); +$tpl_data = []; $sql = "SELECT * FROM ". BB_TOPIC_TPL ." WHERE tpl_id = {$f_data['forum_tpl_id']} LIMIT 1"; -if (!$f_data['forum_tpl_id'] OR !$tpl_data = DB()->fetch_row($sql)) +if (!$f_data['forum_tpl_id'] || !($tpl_data = DB()->fetch_row($sql))) { if (!$edit_tpl_mode) { diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php index 87a348e9c..966c0da45 100644 --- a/library/includes/ucp/register.php +++ b/library/includes/ucp/register.php @@ -187,7 +187,7 @@ foreach ($profile_fields as $field => $can_edit) if ($submit) { $err = validate_username($username); - if (!$errors AND $err && $mode == 'register') + if (!$errors && $err && ($mode == 'register')) { $errors[] = $err; } @@ -263,7 +263,7 @@ foreach ($profile_fields as $field => $can_edit) { $errors[] = $lang['CHOOSE_E_MAIL']; } - if (!$errors AND $err = validate_email($email)) + if (!$errors && ($err = validate_email($email))) { $errors[] = $err; } @@ -275,7 +275,7 @@ foreach ($profile_fields as $field => $can_edit) { $errors[] = $lang['CONFIRM_PASSWORD_EXPLAIN']; } - if (!$errors AND $err = validate_email($email)) + if (!$errors && ($err = validate_email($email))) { $errors[] = $err; } @@ -414,7 +414,7 @@ foreach ($profile_fields as $field => $can_edit) require(INC_DIR .'functions_upload.php'); $upload = new upload_common(); - if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) AND $upload->store('avatar', $pr_data)) + if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) && $upload->store('avatar', $pr_data)) { $pr_data['avatar_ext_id'] = $upload->file_ext_id; $db_data['avatar_ext_id'] = (int) $upload->file_ext_id; diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php index 11fa79cc6..b59bd5980 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -29,7 +29,7 @@ if (!$ranks = $datastore->get('ranks')) } $poster_rank = $rank_image= $rank_style = $rank_select = ''; -if ($user_rank = $profiledata['user_rank'] AND isset($ranks[$user_rank])) +if (($user_rank = $profiledata['user_rank']) && isset($ranks[$user_rank])) { $rank_image = ($ranks[$user_rank]['rank_image']) ? '' : ''; $poster_rank = $ranks[$user_rank]['rank_title']; diff --git a/modcp.php b/modcp.php index 8ca09ec5a..432dd4594 100644 --- a/modcp.php +++ b/modcp.php @@ -224,7 +224,7 @@ switch ($mode) $req_topics = isset($_POST['topic_id_list']) ? $_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)) + if (!$req_topics || !($topic_csv = get_id_csv($req_topics))) { bb_die($lang['NONE_SELECTED']); } diff --git a/posting.php b/posting.php index 0c9b80dbf..3a463a775 100644 --- a/posting.php +++ b/posting.php @@ -402,7 +402,7 @@ elseif ( ($submit || $confirm) && !$topic_has_new_posts ) require(INC_DIR .'functions_upload.php'); $upload = new upload_common(); - if ($upload->init($bb_cfg['attach'], $_FILES['attach']) AND $upload->store('attach', array('topic_id' => $topic_id))) + if ($upload->init($bb_cfg['attach'], $_FILES['attach']) && $upload->store('attach', array('topic_id' => $topic_id))) { DB()->query(" UPDATE ". BB_TOPICS ." SET diff --git a/search.php b/search.php index 389052a9f..e91ebaabf 100644 --- a/search.php +++ b/search.php @@ -27,7 +27,7 @@ if (isset($_POST['del_my_post'])) '. $lang['INDEX_RETURN'] .' '); - if (empty($_POST['topic_id_list']) OR !$topic_csv = get_id_csv($_POST['topic_id_list'])) + if (empty($_POST['topic_id_list']) || !($topic_csv = get_id_csv($_POST['topic_id_list']))) { bb_die($lang['NONE_SELECTED']); } @@ -916,7 +916,7 @@ function prevent_huge_searches ($SQL) $SQL['ORDER BY'] = array(); $SQL['LIMIT'] = array('0'); - if (DB()->query($SQL) AND $row = DB()->fetch_row("SELECT FOUND_ROWS() AS rows_count")) + if (DB()->query($SQL) && ($row = DB()->fetch_row("SELECT FOUND_ROWS() AS rows_count"))) { if ($row['rows_count'] > $bb_cfg['limit_max_search_results']) { diff --git a/styles/templates/default/tpl_config.php b/styles/templates/default/tpl_config.php index 86bbb8564..c019d94d3 100644 --- a/styles/templates/default/tpl_config.php +++ b/styles/templates/default/tpl_config.php @@ -128,7 +128,7 @@ $template->assign_vars(array( )); // post_buttons -if (!empty($page_cfg['load_tpl_vars']) AND $vars = array_flip($page_cfg['load_tpl_vars'])) +if (!empty($page_cfg['load_tpl_vars']) && ($vars = array_flip($page_cfg['load_tpl_vars']))) { if (isset($vars['post_buttons'])) { diff --git a/tracker.php b/tracker.php index e0b8a1833..5e25577ba 100644 --- a/tracker.php +++ b/tracker.php @@ -462,7 +462,7 @@ if (!$set_default) hash_search($_REQUEST[$hash_key]); } - if ($tm =& $_REQUEST[$title_match_key] AND is_string($tm)) + if (($tm =& $_REQUEST[$title_match_key]) && is_string($tm)) { if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len)) { diff --git a/viewforum.php b/viewforum.php index 0df7d4e02..a8891c2ad 100644 --- a/viewforum.php +++ b/viewforum.php @@ -50,7 +50,7 @@ if (!$forums = $datastore->get('cat_forums')) $datastore->update('cat_forums'); $forums = $datastore->get('cat_forums'); } -if (!$forum_id OR !$forum_data = $forums['forum'][$forum_id]) +if (!$forum_id || !($forum_data = $forums['forum'][$forum_id])) { bb_die($lang['FORUM_NOT_EXIST']); } @@ -241,7 +241,7 @@ $select_tpp = ''; if ($is_auth['auth_mod']) { - if ($req_tpp = $di->request->query->getInt('tpp') AND in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) + if (($req_tpp = $di->request->query->getInt('tpp')) && in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) { $topics_per_page = $req_tpp; } @@ -270,7 +270,7 @@ $sel_previous_days = array( if (!empty($_REQUEST['topicdays'])) { - if ($req_topic_days = $di->request->query->getInt('topicdays') AND isset($sel_previous_days[$req_topic_days])) + if (($req_topic_days = $di->request->query->getInt('topicdays')) && isset($sel_previous_days[$req_topic_days])) { $sql = " SELECT COUNT(*) AS forum_topics diff --git a/viewtopic.php b/viewtopic.php index a627011bf..2aa87b87f 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -33,7 +33,7 @@ $select_ppp = ''; if ($userdata['session_admin']) { - if ($req_ppp = $di->request->query->getInt('ppp') AND in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) + if (($req_ppp = $di->request->query->getInt('ppp')) && in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) { $posts_per_page = $req_ppp; } @@ -595,7 +595,7 @@ for($i = 0; $i < $total_posts; $i++) $poster_rank = $rank_image = ''; $user_rank = $postrow[$i]['user_rank']; - if (!$user->opt_js['h_rnk_i'] AND isset($ranks[$user_rank])) + if (!$user->opt_js['h_rnk_i'] && isset($ranks[$user_rank])) { $rank_image = ($bb_cfg['show_rank_image'] && $ranks[$user_rank]['rank_image']) ? '' : ''; $poster_rank = ($bb_cfg['show_rank_text']) ? $ranks[$user_rank]['rank_title'] : '';