diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index c7efa9a77..d911e0be1 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -333,7 +333,7 @@ if ($view === 'attachments') { // Are we called from Username ? if ($user_based) { - $sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . intval($uid); + $sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . (int)$uid; if (!($result = DB()->sql_query($sql))) { bb_die('Error getting username'); @@ -343,7 +343,7 @@ if ($view === 'attachments') { DB()->sql_freeresult($result); $username = $row['username']; - $s_hidden = ''; + $s_hidden = ''; $template->assign_block_vars('switch_user_based', array()); @@ -354,7 +354,7 @@ if ($view === 'attachments') { $sql = "SELECT attach_id FROM " . BB_ATTACHMENTS . " - WHERE user_id_1 = " . intval($uid) . " + WHERE user_id_1 = " . (int)$uid . " GROUP BY attach_id"; if (!($result = DB()->sql_query($sql))) { @@ -374,7 +374,7 @@ if ($view === 'attachments') { $attach_id = array(); for ($j = 0; $j < $num_attach_ids; $j++) { - $attach_id[] = intval($attach_ids[$j]['attach_id']); + $attach_id[] = (int)$attach_ids[$j]['attach_id']; } $sql = "SELECT a.* @@ -394,13 +394,13 @@ if ($view === 'attachments') { $attachments = search_attachments($order_by, $total_rows); } - if (sizeof($attachments) > 0) { + if (count($attachments) > 0) { for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) { - $delete_box = ''; + $delete_box = ''; for ($j = 0, $iMax = count($delete_id_list); $j < $iMax; $j++) { if ($delete_id_list[$j] == $attachments[$i]['attach_id']) { - $delete_box = ''; + $delete_box = ''; break; } } @@ -413,7 +413,7 @@ if ($view === 'attachments') { $sql = "SELECT * FROM " . BB_ATTACHMENTS . " - WHERE attach_id = " . intval($attachments[$i]['attach_id']); + WHERE attach_id = " . (int)$attachments[$i]['attach_id']; if (!($result = DB()->sql_query($sql))) { bb_die('Could not query attachments #3'); @@ -427,7 +427,7 @@ if ($view === 'attachments') { if ($ids[$j]['post_id'] != 0) { $sql = "SELECT t.topic_title FROM " . BB_TOPICS . " t, " . BB_POSTS . " p - WHERE p.post_id = " . intval($ids[$j]['post_id']) . " AND p.topic_id = t.topic_id + WHERE p.post_id = " . (int)$ids[$j]['post_id'] . " AND p.topic_id = t.topic_id GROUP BY t.topic_id, t.topic_title"; if (!($result = DB()->sql_query($sql))) { @@ -452,7 +452,7 @@ if ($view === 'attachments') { $post_titles = implode('
', $post_titles); - $hidden_field = ''; + $hidden_field = ''; $template->assign_block_vars('attachrow', array( 'ROW_NUMBER' => $i + (@$_GET['start'] + 1), diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index e15666c83..188657c60 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -30,7 +30,7 @@ if (!empty($setmodules)) { $module['ATTACHMENTS']['QUOTA_LIMITS'] = $filename . '?mode=quota'; return; } -require('./pagestart.php'); +require __DIR__ . '/pagestart.php'; $error = false; @@ -220,7 +220,7 @@ if ($check_upload) { } if (!$error) { - if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) { + if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) { $error = true; $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $attach_config['upload_dir']) . '
'; } else { @@ -248,8 +248,8 @@ if ($mode == 'manage') { 'S_FILESIZE' => $select_size_mode, 'S_FILESIZE_QUOTA' => $select_quota_size_mode, 'S_FILESIZE_PM' => $select_pm_size_mode, - 'S_DEFAULT_UPLOAD_LIMIT' => default_quota_limit_select('default_upload_quota', intval(trim($new_attach['default_upload_quota']))), - 'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', intval(trim($new_attach['default_pm_quota']))), + 'S_DEFAULT_UPLOAD_LIMIT' => default_quota_limit_select('default_upload_quota', (int)trim($new_attach['default_upload_quota'])), + 'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', (int)trim($new_attach['default_pm_quota'])), 'UPLOAD_DIR' => $new_attach['upload_dir'], 'ATTACHMENT_IMG_PATH' => $new_attach['upload_img'], @@ -288,7 +288,7 @@ if ($mode == 'cats') { $row = DB()->sql_fetchrowset($result); DB()->sql_freeresult($result); - for ($i = 0; $i < sizeof($row); $i++) { + for ($i = 0, $iMax = count($row); $i < $iMax; $i++) { if ($row[$i]['cat_id'] == IMAGE_CAT) { $s_assigned_group_images[] = $row[$i]['group_name']; } @@ -375,7 +375,7 @@ if ($check_image_cat) { } if (!$error) { - if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) { + if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) { $error = true; $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $upload_dir) . '
'; } else { @@ -399,7 +399,7 @@ if ($submit && $mode == 'quota') { $allowed_list = array(); - for ($i = 0; $i < sizeof($quota_change_list); $i++) { + 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]); $sql = 'UPDATE ' . BB_QUOTA_LIMITS . " @@ -504,7 +504,7 @@ if ($mode == 'quota') { $rows = DB()->sql_fetchrowset($result); DB()->sql_freeresult($result); - for ($i = 0; $i < sizeof($rows); $i++) { + for ($i = 0, $iMax = count($rows); $i < $iMax; $i++) { $size_format = ($rows[$i]['quota_limit'] >= 1048576) ? 'mb' : (($rows[$i]['quota_limit'] >= 1024) ? 'kb' : 'b'); if ($rows[$i]['quota_limit'] >= 1048576) { diff --git a/admin/admin_disallow.php b/admin/admin_disallow.php index ad86b28fd..c429e0265 100644 --- a/admin/admin_disallow.php +++ b/admin/admin_disallow.php @@ -54,7 +54,7 @@ if (isset($_POST['add_name'])) { bb_die($message); } elseif (isset($_POST['delete_name'])) { - $disallowed_id = (isset($_POST['disallowed_id'])) ? intval($_POST['disallowed_id']) : intval($_GET['disallowed_id']); + $disallowed_id = (isset($_POST['disallowed_id'])) ? (int)$_POST['disallowed_id'] : (int)$_GET['disallowed_id']; $sql = "DELETE FROM " . BB_DISALLOW . " WHERE disallow_id = $disallowed_id"; $result = DB()->sql_query($sql); @@ -87,7 +87,7 @@ $disallow_select = ''; - for ($j = 0; $j < count($simple_auth_types); $j++) { + for ($j = 0, $jMax = count($simple_auth_types); $j < $iMax; $j++) { $selected = ($matched_type == $j) ? ' selected="selected"' : ''; $simple_auth .= ''; } @@ -206,10 +207,10 @@ if (empty($forum_id)) { // Output values of individual // fields // - for ($j = 0; $j < count($forum_auth_fields); $j++) { + for ($j = 0, $jMax = count($forum_auth_fields); $j < $iMax; $j++) { $custom_auth[$j] = ' '; - for ($k = 0; $k < count($forum_auth_levels); $k++) { + for ($k = 0, $kMax = count($forum_auth_levels); $k < $iMax; $k++) { $selected = (!empty($forum_rows) && $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k]) ? ' selected="selected"' : ''; $custom_auth[$j] .= ''; } diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 5db193ece..8c710c553 100644 --- a/admin/admin_forums.php +++ b/admin/admin_forums.php @@ -85,7 +85,7 @@ if ($mode) { $newmode = 'modforum'; $buttonvalue = $lang['UPDATE']; - $forum_id = intval($_GET[POST_FORUM_URL]); + $forum_id = (int)$_GET[POST_FORUM_URL]; $row = get_info('forum', $forum_id); @@ -121,7 +121,7 @@ if ($mode) { } if (isset($_REQUEST['forum_parent'])) { - $forum_parent = intval($_REQUEST['forum_parent']); + $forum_parent = (int)$_REQUEST['forum_parent']; if ($parent = get_forum_data($forum_parent)) { $cat_id = $parent['cat_id']; @@ -179,18 +179,18 @@ if ($mode) { // // Create a forum in the DB // - $cat_id = intval($_POST[POST_CAT_URL]); + $cat_id = (int)$_POST[POST_CAT_URL]; $forum_name = (string)$_POST['forumname']; $forum_desc = (string)$_POST['forumdesc']; - $forum_status = intval($_POST['forumstatus']); + $forum_status = (int)$_POST['forumstatus']; - $prune_days = intval($_POST['prune_days']); + $prune_days = (int)$_POST['prune_days']; - $forum_parent = ($_POST['forum_parent'] != -1) ? intval($_POST['forum_parent']) : 0; - $show_on_index = ($forum_parent) ? intval($_POST['show_on_index']) : 1; + $forum_parent = ($_POST['forum_parent'] != -1) ? (int)$_POST['forum_parent'] : 0; + $show_on_index = ($forum_parent) ? (int)$_POST['show_on_index'] : 1; - $forum_display_sort = intval($_POST['forum_display_sort']); - $forum_display_order = intval($_POST['forum_display_order']); + $forum_display_sort = (int)$_POST['forum_display_sort']; + $forum_display_order = (int)$_POST['forum_display_order']; $forum_tpl_id = (int)$_POST['forum_tpl_select']; $allow_reg_tracker = (int)$_POST['allow_reg_tracker']; @@ -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); @@ -242,18 +242,18 @@ if ($mode) { // // Modify a forum in the DB // - $cat_id = intval($_POST[POST_CAT_URL]); - $forum_id = intval($_POST[POST_FORUM_URL]); + $cat_id = (int)$_POST[POST_CAT_URL]; + $forum_id = (int)$_POST[POST_FORUM_URL]; $forum_name = (string)$_POST['forumname']; $forum_desc = (string)$_POST['forumdesc']; - $forum_status = intval($_POST['forumstatus']); - $prune_days = intval($_POST['prune_days']); + $forum_status = (int)$_POST['forumstatus']; + $prune_days = (int)$_POST['prune_days']; - $forum_parent = ($_POST['forum_parent'] != -1) ? intval($_POST['forum_parent']) : 0; - $show_on_index = ($forum_parent) ? intval($_POST['show_on_index']) : 1; + $forum_parent = ($_POST['forum_parent'] != -1) ? (int)$_POST['forum_parent'] : 0; + $show_on_index = ($forum_parent) ? (int)$_POST['show_on_index'] : 1; - $forum_display_order = intval($_POST['forum_display_order']); - $forum_display_sort = intval($_POST['forum_display_sort']); + $forum_display_order = (int)$_POST['forum_display_order']; + $forum_display_sort = (int)$_POST['forum_display_sort']; $forum_tpl_id = (int)$_POST['forum_tpl_select']; $allow_reg_tracker = (int)$_POST['allow_reg_tracker']; $allow_porno_topic = (int)$_POST['allow_porno_topic']; @@ -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) { @@ -565,8 +565,8 @@ if ($mode) { case 'forum_order': // Change order of forums - $move = intval($_GET['move']); - $forum_id = intval($_GET[POST_FORUM_URL]); + $move = (int)$_GET['move']; + $forum_id = (int)$_GET[POST_FORUM_URL]; $forum_info = get_info('forum', $forum_id); renumber_order('forum', $forum_info['cat_id']); @@ -652,7 +652,7 @@ if ($mode) { break; case 'forum_sync': - sync('forum', intval($_GET['f'])); + sync('forum', (int)$_GET['f']); $datastore->update('cat_forums'); CACHE('bb_cache')->rm(); @@ -746,7 +746,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'], @@ -910,7 +910,7 @@ function get_cat_forums($cat_id = false) $forums = array(); $where_sql = ''; - if ($cat_id = intval($cat_id)) { + if ($cat_id = (int)$cat_id) { $where_sql = "AND f.cat_id = $cat_id"; } @@ -960,7 +960,7 @@ function get_prev_root_forum_id($forums, $curr_forum_order) if (isset($forums[$i]) && !$forums[$i]['forum_parent']) { return $forums[$i]['forum_id']; } - $i = $i - 10; + $i -= 10; } return false; @@ -975,7 +975,7 @@ function get_next_root_forum_id($forums, $curr_forum_order) if (isset($forums[$i]) && !$forums[$i]['forum_parent']) { return $forums[$i]['forum_id']; } - $i = $i + 10; + $i += 10; } return false; @@ -1082,7 +1082,7 @@ function get_max_forum_order($cat_id) WHERE cat_id = $cat_id "); - return intval($row['max_forum_order']); + return (int)$row['max_forum_order']; } function check_name_dup($mode, $name, $die_on_error = true) diff --git a/admin/admin_groups.php b/admin/admin_groups.php index b671bfa87..b6610dbf1 100644 --- a/admin/admin_groups.php +++ b/admin/admin_groups.php @@ -30,8 +30,8 @@ if (!empty($setmodules)) { require __DIR__ . '/pagestart.php'; require INC_DIR . '/functions_group.php'; -$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : 0; -$mode = isset($_REQUEST['mode']) ? strval($_REQUEST['mode']) : ''; +$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : 0; +$mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; attachment_quota_settings('group', isset($_POST['group_update']), $mode); @@ -100,8 +100,8 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) { bb_die($message); } else { - $group_type = isset($_POST['group_type']) ? intval($_POST['group_type']) : GROUP_OPEN; - $release_group = isset($_POST['release_group']) ? intval($_POST['release_group']) : 0; + $group_type = isset($_POST['group_type']) ? (int)$_POST['group_type'] : GROUP_OPEN; + $release_group = isset($_POST['release_group']) ? (int)$_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'] : ''; diff --git a/admin/admin_log.php b/admin/admin_log.php index 3452a403b..db6a6f4a6 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['USERS']['ACTIONS_LOG'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; $datastore->enqueue(array( 'moderators', @@ -94,7 +95,7 @@ $f_data = $forums['f']; unset($forums); // Start -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; // Type $type_selected = array($def_types); @@ -106,7 +107,7 @@ if ($var =& $_REQUEST[$type_key]) { if (in_array($all_types, $type_selected)) { $type_selected = array($all_types); } - $type_csv = join(',', $type_selected); + $type_csv = implode(',', $type_selected); $url = ($type_csv != $def_types) ? url_arg($url, $type_key, $type_csv) : $url; } @@ -120,7 +121,7 @@ if ($var =& $_REQUEST[$user_key]) { if (in_array($all_users, $user_selected)) { $user_selected = array($all_users); } - $user_csv = join(',', $user_selected); + $user_csv = implode(',', $user_selected); $url = ($user_csv != $def_users) ? url_arg($url, $user_key, $user_csv) : $url; } @@ -134,7 +135,7 @@ if ($var =& $_REQUEST[$forum_key]) { if (in_array($all_forums, $forum_selected)) { $forum_selected = array($all_forums); } - $forum_csv = join(',', $forum_selected); + $forum_csv = implode(',', $forum_selected); $url = ($forum_csv != $def_forums) ? url_arg($url, $forum_key, $forum_csv) : $url; } @@ -144,7 +145,7 @@ $topic_csv = ''; if ($var =& $_REQUEST[$topic_key]) { $topic_selected = get_id_ary($var); - $topic_csv = join(',', $topic_selected); + $topic_csv = implode(',', $topic_selected); $url = ($topic_csv) ? url_arg($url, $topic_key, $topic_csv) : $url; } @@ -164,7 +165,7 @@ $datetime_val = $def_datetime; $daysback_val = $def_days; if ($var =& $_REQUEST[$daysback_key] && $var != $def_days) { - $daysback_val = max(intval($var), 1); + $daysback_val = max((int)$var, 1); $url = url_arg($url, $daysback_key, $daysback_val); } if ($var =& $_REQUEST[$datetime_key] && $var != $def_datetime) { diff --git a/admin/admin_mass_email.php b/admin/admin_mass_email.php index 4e6fd805d..7ac3dde06 100644 --- a/admin/admin_mass_email.php +++ b/admin/admin_mass_email.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['MODS']['MASS_EMAIL'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; @set_time_limit(1200); @@ -54,7 +55,7 @@ if (isset($_POST['submit'])) { foreach ($sql as $row) { $user_id_sql[] = ',' . $row['ban_userid']; } - $user_id_sql = join('', $user_id_sql); + $user_id_sql = implode('', $user_id_sql); if ($group_id != -1) { $user_list = DB()->fetch_rowset(" @@ -113,7 +114,7 @@ $template->assign_vars(array( 'MESSAGE' => $message, 'SUBJECT' => $subject, - 'ERROR_MESSAGE' => ($errors) ? join('
', array_unique($errors)) : '', + 'ERROR_MESSAGE' => ($errors) ? implode('
', array_unique($errors)) : '', 'S_USER_ACTION' => 'admin_mass_email.php', 'S_GROUP_SELECT' => build_select(POST_GROUPS_URL, $groups), diff --git a/admin/admin_phpinfo.php b/admin/admin_phpinfo.php index f2a86a541..a88ce9293 100644 --- a/admin/admin_phpinfo.php +++ b/admin/admin_phpinfo.php @@ -27,6 +27,7 @@ if (!empty($setmodules)) { $module['GENERAL']['PHP_INFO'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; phpinfo(); diff --git a/admin/admin_ranks.php b/admin/admin_ranks.php index 75bec2f52..7b7b28e19 100644 --- a/admin/admin_ranks.php +++ b/admin/admin_ranks.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['USERS']['RANKS'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; $_POST['special_rank'] = 1; $_POST['min_posts'] = -1; @@ -52,7 +53,7 @@ if ($mode != '') { // // They want to add a new rank, show the form. // - $rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; + $rank_id = (isset($_GET['id'])) ? (int)$_GET['id'] : 0; $s_hidden_fields = ''; @@ -96,11 +97,11 @@ if ($mode != '') { // Ok, they sent us our info, let's update it. // - $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0; + $rank_id = (isset($_POST['id'])) ? (int)$_POST['id'] : 0; $rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : ''; $rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : ''; $special_rank = ($_POST['special_rank'] == 1) ? true : 0; - $min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1; + $min_posts = (isset($_POST['min_posts'])) ? (int)$_POST['min_posts'] : -1; $rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : ''; if ($rank_title == '') { @@ -159,7 +160,7 @@ if ($mode != '') { // if (isset($_POST['id']) || isset($_GET['id'])) { - $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']); + $rank_id = (isset($_POST['id'])) ? (int)$_POST['id'] : (int)$_GET['id']; } else { $rank_id = 0; } diff --git a/admin/admin_rebuild_search.php b/admin/admin_rebuild_search.php index 538b6da56..89081bcb3 100644 --- a/admin/admin_rebuild_search.php +++ b/admin/admin_rebuild_search.php @@ -70,7 +70,7 @@ if (isset($_REQUEST['cancel_button'])) { } // from which post to start processing -$start = abs(intval(@$_REQUEST['start'])); +$start = abs((int)(@$_REQUEST['start'])); // get the total number of posts in the db $total_posts = get_total_posts(); @@ -86,7 +86,7 @@ $session_posts_processed = ($mode == 'refresh') ? get_processed_posts('session') $total_posts_processing = $total_posts - $total_posts_processed; // how many posts to process in this session -if ($session_posts_processing = @intval($_REQUEST['session_posts_processing'])) { +if ($session_posts_processing = @(int)$_REQUEST['session_posts_processing']) { if ($mode == 'submit') { // check if we passed over total_posts just after submitting if ($session_posts_processing + $total_posts_processed > $total_posts) { @@ -115,21 +115,10 @@ if (isset($_REQUEST['time_limit'])) { $time_limit = $def_time_limit; $time_limit_explain = $lang['TIME_LIMIT_EXPLAIN']; - // check for safe mode timeout - if (ini_get('safe_mode')) { - // get execution time - $max_execution_time = ini_get('max_execution_time'); - $time_limit_explain .= '
' . sprintf($lang['TIME_LIMIT_EXPLAIN_SAFE'], $max_execution_time); - - if ($time_limit > $max_execution_time) { - $time_limit = $max_execution_time; - } - } - // check for webserver timeout (IE returns null) if (isset($_SERVER["HTTP_KEEP_ALIVE"])) { // get webserver timeout - $webserver_timeout = intval($_SERVER["HTTP_KEEP_ALIVE"]); + $webserver_timeout = (int)$_SERVER["HTTP_KEEP_ALIVE"]; $time_limit_explain .= '
' . sprintf($lang['TIME_LIMIT_EXPLAIN_WEBSERVER'], $webserver_timeout); if ($time_limit > $webserver_timeout) { @@ -207,7 +196,7 @@ if ($mode == 'submit' || $mode == 'refresh') { } // find how much time the last cycle took - $last_cycle_time = intval(TIMENOW - $start_time); + $last_cycle_time = (int)(TIMENOW - $start_time); // check if we had any data if ($num_rows != 0) { diff --git a/admin/admin_smilies.php b/admin/admin_smilies.php index 1e69fb524..c84c83860 100644 --- a/admin/admin_smilies.php +++ b/admin/admin_smilies.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['GENERAL']['SMILIES'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; // Check to see what mode we should operate in if (isset($_POST['mode']) || isset($_GET['mode'])) { @@ -78,7 +79,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { $cur_smilies = DB()->sql_fetchrowset($result); - for ($i = 0; $i < count($cur_smilies); $i++) { + for ($i = 0, $iMax = count($cur_smilies); $i < $iMax; $i++) { $k = $cur_smilies[$i]['code']; $smiles[$k] = 1; } @@ -90,10 +91,10 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { bb_die('Could not read smiley pak file'); } - for ($i = 0; $i < count($fcontents); $i++) { + for ($i = 0, $iMax = count($fcontents); $i < $iMax; $i++) { $smile_data = explode($delimeter, trim(addslashes($fcontents[$i]))); - for ($j = 2; $j < count($smile_data); $j++) { + for ($j = 2, $jMax = count($smile_data); $j < $iMax; $j++) { // Replace > and < with the proper html_entities for matching $smile_data[$j] = str_replace('<', '<', $smile_data[$j]); $smile_data[$j] = str_replace('>', '>', $smile_data[$j]); @@ -155,7 +156,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { $resultset = DB()->sql_fetchrowset($result); $smile_pak = ''; - for ($i = 0; $i < count($resultset); $i++) { + for ($i = 0, $iMax = count($resultset); $i < $iMax; $i++) { $smile_pak .= $resultset[$i]['smile_url'] . $delimeter; $smile_pak .= $resultset[$i]['emoticon'] . $delimeter; $smile_pak .= $resultset[$i]['code'] . "\n"; @@ -172,7 +173,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { bb_die(sprintf($lang['EXPORT_SMILES'], '', '') . '

' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } elseif (isset($_POST['add']) || isset($_GET['add'])) { $filename_list = ''; - for ($i = 0; $i < count($smiley_images); $i++) { + for ($i = 0, $iMax = count($smiley_images); $i < $iMax; $i++) { $filename_list .= ''; } @@ -190,7 +191,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { switch ($mode) { case 'delete': $smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id']; - $smiley_id = intval($smiley_id); + $smiley_id = (int)$smiley_id; $sql = "DELETE FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id; $result = DB()->sql_query($sql); @@ -204,7 +205,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { case 'edit': $smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id']; - $smiley_id = intval($smiley_id); + $smiley_id = (int)$smiley_id; $sql = "SELECT * FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id; $result = DB()->sql_query($sql); @@ -214,7 +215,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { $smile_data = DB()->sql_fetchrow($result); $filename_list = ''; - for ($i = 0; $i < count($smiley_images); $i++) { + for ($i = 0, $iMax = count($smiley_images); $i < $iMax; $i++) { if ($smiley_images[$i] == $smile_data['smile_url']) { $smiley_selected = 'selected="selected"'; $smiley_edit_img = $smiley_images[$i]; @@ -244,7 +245,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { $smile_url = (isset($_POST['smile_url'])) ? trim($_POST['smile_url']) : trim($_GET['smile_url']); $smile_url = bb_ltrim(basename($smile_url), "'"); $smile_emotion = (isset($_POST['smile_emotion'])) ? trim($_POST['smile_emotion']) : trim($_GET['smile_emotion']); - $smile_id = (isset($_POST['smile_id'])) ? intval($_POST['smile_id']) : intval($_GET['smile_id']); + $smile_id = (isset($_POST['smile_id'])) ? (int)$_POST['smile_id'] : (int)$_GET['smile_id']; // If no code was entered complain if ($smile_code == '' || $smile_url == '') { @@ -313,7 +314,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) { )); // Loop throuh the rows of smilies setting block vars for the template - for ($i = 0; $i < count($smilies); $i++) { + for ($i = 0, $iMax = count($smilies); $i < $iMax; $i++) { // Replace htmlentites for < and > with actual character $smilies[$i]['code'] = str_replace('<', '<', $smilies[$i]['code']); $smilies[$i]['code'] = str_replace('>', '>', $smilies[$i]['code']); diff --git a/admin/admin_terms.php b/admin/admin_terms.php index ce6a85be1..24d45d582 100644 --- a/admin/admin_terms.php +++ b/admin/admin_terms.php @@ -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']) : '', )); diff --git a/admin/admin_ug_auth.php b/admin/admin_ug_auth.php index 19a0fb1ad..cb96ac37f 100644 --- a/admin/admin_ug_auth.php +++ b/admin/admin_ug_auth.php @@ -82,7 +82,7 @@ if ($submit && $mode == 'user') { $group_id = create_user_group($user_id); } - if (!$group_id || !$user_id || is_null($this_user_level)) { + if (!$group_id || !$user_id || null === $this_user_level) { trigger_error('data missing', E_USER_ERROR); } diff --git a/admin/admin_user_ban.php b/admin/admin_user_ban.php index f1fb850a6..ef195c01f 100644 --- a/admin/admin_user_ban.php +++ b/admin/admin_user_ban.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['USERS']['BAN_MANAGEMENT'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; if (isset($_POST['submit'])) { $user_bansql = ''; @@ -48,7 +49,7 @@ if (isset($_POST['submit'])) { if (isset($_POST['ban_ip'])) { $ip_list_temp = explode(',', $_POST['ban_ip']); - for ($i = 0; $i < count($ip_list_temp); $i++) { + for ($i = 0, $iMax = count($ip_list_temp); $i < $iMax; $i++) { if (preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode)) { $ip_1_counter = $ip_range_explode[1]; $ip_1_end = $ip_range_explode[5]; @@ -99,7 +100,7 @@ if (isset($_POST['submit'])) { } elseif (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i]))) { $ip = gethostbynamel(trim($ip_list_temp[$i])); - for ($j = 0; $j < count($ip); $j++) { + for ($j = 0, $jMax = count($ip); $j < $iMax; $j++) { if (!empty($ip[$j])) { $ip_list[] = encode_ip($ip[$j]); } @@ -114,7 +115,7 @@ if (isset($_POST['submit'])) { if (isset($_POST['ban_email'])) { $email_list_temp = explode(',', $_POST['ban_email']); - for ($i = 0; $i < count($email_list_temp); $i++) { + for ($i = 0, $iMax = count($email_list_temp); $i < $iMax; $i++) { if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i]))) { $email_list[] = trim($email_list_temp[$i]); } @@ -130,9 +131,9 @@ if (isset($_POST['submit'])) { DB()->sql_freeresult($result); $kill_session_sql = ''; - for ($i = 0; $i < count($user_list); $i++) { + for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) { $in_banlist = false; - for ($j = 0; $j < count($current_banlist); $j++) { + for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) { if ($user_list[$i] == $current_banlist[$j]['ban_userid']) { $in_banlist = true; } @@ -148,9 +149,9 @@ if (isset($_POST['submit'])) { } } - for ($i = 0; $i < count($ip_list); $i++) { + for ($i = 0, $iMax = count($ip_list); $i < $iMax; $i++) { $in_banlist = false; - for ($j = 0; $j < count($current_banlist); $j++) { + for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) { if ($ip_list[$i] == $current_banlist[$j]['ban_ip']) { $in_banlist = true; } @@ -180,9 +181,9 @@ if (isset($_POST['submit'])) { } } - for ($i = 0; $i < count($email_list); $i++) { + for ($i = 0, $iMax = count($email_list); $i < $iMax; $i++) { $in_banlist = false; - for ($j = 0; $j < count($current_banlist); $j++) { + for ($j = 0, $jMax = count($current_banlist); $j < $iMax; $j++) { if ($email_list[$i] == $current_banlist[$j]['ban_email']) { $in_banlist = true; } @@ -201,9 +202,9 @@ if (isset($_POST['submit'])) { if (isset($_POST['unban_user'])) { $user_list = $_POST['unban_user']; - for ($i = 0; $i < count($user_list); $i++) { + for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) { if ($user_list[$i] != -1) { - $where_sql .= (($where_sql != '') ? ', ' : '') . intval($user_list[$i]); + $where_sql .= (($where_sql != '') ? ', ' : '') . (int)$user_list[$i]; } } } @@ -211,7 +212,7 @@ if (isset($_POST['submit'])) { if (isset($_POST['unban_ip'])) { $ip_list = $_POST['unban_ip']; - for ($i = 0; $i < count($ip_list); $i++) { + for ($i = 0, $iMax = count($ip_list); $i < $iMax; $i++) { if ($ip_list[$i] != -1) { $where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($ip_list[$i]); } @@ -221,7 +222,7 @@ if (isset($_POST['submit'])) { if (isset($_POST['unban_email'])) { $email_list = $_POST['unban_email']; - for ($i = 0; $i < count($email_list); $i++) { + for ($i = 0, $iMax = count($email_list); $i < $iMax; $i++) { if ($email_list[$i] != -1) { $where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($email_list[$i]); } @@ -259,7 +260,7 @@ if (isset($_POST['submit'])) { DB()->sql_freeresult($result); $select_userlist = ''; - for ($i = 0; $i < count($user_list); $i++) { + for ($i = 0, $iMax = count($user_list); $i < $iMax; $i++) { $select_userlist .= ''; $userban_count++; } @@ -281,7 +282,7 @@ if (isset($_POST['submit'])) { $select_iplist = ''; $select_emaillist = ''; - for ($i = 0; $i < count($banlist); $i++) { + for ($i = 0, $iMax = count($banlist); $i < $iMax; $i++) { $ban_id = $banlist[$i]['ban_id']; if (!empty($banlist[$i]['ban_ip'])) { diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php index 294d51c98..a5b651f06 100644 --- a/admin/admin_user_search.php +++ b/admin/admin_user_search.php @@ -271,7 +271,7 @@ if (!isset($_REQUEST['dosearch'])) { $username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username)))); - if (strstr($username, '%')) { + if (false !== strpos($username, '%')) { $op = 'LIKE'; } else { $op = '='; @@ -292,7 +292,7 @@ if (!isset($_REQUEST['dosearch'])) { $email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email)))); - if (strstr($email, '%')) { + if (false !== strpos($email, '%')) { $op = 'LIKE'; } else { $op = '='; @@ -437,25 +437,25 @@ if (!isset($_REQUEST['dosearch'])) { case 'search_joindate': $base_url .= '&search_joindate=true&date_type=' . rawurlencode($date_type) . '&date_day=' . rawurlencode($date_day) . '&date_month=' . rawurlencode($date_month) . '&date_year=' . rawurlencode(stripslashes($date_year)); - $date_type = trim(strtolower($date_type)); + $date_type = strtolower(trim($date_type)); if ($date_type != 'before' && $date_type != 'after') { bb_die($lang['SEARCH_INVALID_DATE']); } - $date_day = intval($date_day); + $date_day = (int)$date_day; if (!preg_match('/^([1-9]|[0-2][0-9]|3[0-1])$/', $date_day)) { bb_die($lang['SEARCH_INVALID_DAY']); } - $date_month = intval($date_month); + $date_month = (int)$date_month; if (!preg_match('/^(0?[1-9]|1[0-2])$/', $date_month)) { bb_die($lang['SEARCH_INVALID_MONTH']); } - $date_year = intval($date_year); + $date_year = (int)$date_year; if (!preg_match('/^(20[0-9]{2}|19[0-9]{2})$/', $date_year)) { bb_die($lang['SEARCH_INVALID_YEAR']); @@ -476,7 +476,7 @@ if (!isset($_REQUEST['dosearch'])) { break; case 'search_group': - $group_id = intval($group_id); + $group_id = (int)$group_id; $base_url .= '&search_group=true&group_id=' . rawurlencode($group_id); @@ -511,7 +511,7 @@ if (!isset($_REQUEST['dosearch'])) { break; case 'search_rank': - $rank_id = intval($rank_id); + $rank_id = (int)$rank_id; $base_url .= '&search_rank=true&rank_id=' . rawurlencode($rank_id); @@ -543,14 +543,14 @@ if (!isset($_REQUEST['dosearch'])) { break; case 'search_postcount': - $postcount_type = trim(strtolower($postcount_type)); - $postcount_value = trim(strtolower($postcount_value)); + $postcount_type = strtolower(trim($postcount_type)); + $postcount_value = strtolower(trim($postcount_value)); $base_url .= '&search_postcount=true&postcount_type=' . rawurlencode($postcount_type) . '&postcount_value=' . rawurlencode(stripslashes($postcount_value)); switch ($postcount_type) { case 'greater': - $postcount_value = intval($postcount_value); + $postcount_value = (int)$postcount_value; $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_GREATER'], $postcount_value); @@ -563,7 +563,7 @@ if (!isset($_REQUEST['dosearch'])) { AND u.user_id <> " . GUEST_UID; break; case 'lesser': - $postcount_value = intval($postcount_value); + $postcount_value = (int)$postcount_value; $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_LESSER'], $postcount_value); @@ -577,11 +577,11 @@ if (!isset($_REQUEST['dosearch'])) { break; case 'equals': // looking for a - - if (strstr($postcount_value, '-')) { + if (false !== strpos($postcount_value, '-')) { $range = preg_split('/[-\s]+/', $postcount_value); - $range_begin = intval($range[0]); - $range_end = intval($range[1]); + $range_begin = (int)$range[0]; + $range_end = (int)$range[1]; if ($range_begin > $range_end) { bb_die($lang['SEARCH_INVALID_POSTCOUNT']); @@ -599,7 +599,7 @@ if (!isset($_REQUEST['dosearch'])) { AND u.user_posts <= $range_end AND u.user_id <> " . GUEST_UID; } else { - $postcount_value = intval($postcount_value); + $postcount_value = (int)$postcount_value; $text = sprintf($lang['SEARCH_FOR_POSTCOUNT_EQUALS'], $postcount_value); @@ -624,7 +624,7 @@ if (!isset($_REQUEST['dosearch'])) { $userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value)))); - if (strstr($userfield_value, '%')) { + if (false !== strpos($userfield_value, '%')) { $op = 'LIKE'; } else { $op = '='; @@ -634,7 +634,7 @@ if (!isset($_REQUEST['dosearch'])) { bb_die($lang['SEARCH_INVALID_USERFIELD']); } - $userfield_type = trim(strtolower($userfield_type)); + $userfield_type = strtolower(trim($userfield_type)); switch ($userfield_type) { case 'icq': @@ -679,8 +679,8 @@ if (!isset($_REQUEST['dosearch'])) { break; case 'search_lastvisited': - $lastvisited_type = trim(strtolower($lastvisited_type)); - $lastvisited_days = intval($lastvisited_days); + $lastvisited_type = strtolower(trim($lastvisited_type)); + $lastvisited_days = (int)$lastvisited_days; $base_url .= '&search_lastvisited=true&lastvisited_type=' . rawurlencode(stripslashes($lastvisited_type)) . '&lastvisited_days=' . rawurlencode($lastvisited_days); @@ -718,7 +718,7 @@ if (!isset($_REQUEST['dosearch'])) { case 'search_language': $base_url .= '&search_language=true&language_type=' . rawurlencode(stripslashes($language_type)); - $language_type = trim(strtolower(stripslashes($language_type))); + $language_type = strtolower(trim(stripslashes($language_type))); if ($language_type == '') { bb_die($lang['SEARCH_INVALID_LANGUAGE']); @@ -739,7 +739,7 @@ if (!isset($_REQUEST['dosearch'])) { $base_url .= '&search_timezone=true&timezone_type=' . rawurlencode(stripslashes($timezone_type)); $text = sprintf($lang['SEARCH_FOR_TIMEZONE'], strip_tags(htmlspecialchars(stripslashes($timezone_type)))); - $timezone_type = intval($timezone_type); + $timezone_type = (int)$timezone_type; $total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " @@ -752,7 +752,7 @@ if (!isset($_REQUEST['dosearch'])) { case 'search_moderators': $base_url .= '&search_moderators=true&moderators_forum=' . rawurlencode(stripslashes($moderators_forum)); - $moderators_forum = intval($moderators_forum); + $moderators_forum = (int)$moderators_forum; $sql = "SELECT forum_name FROM " . BB_FORUMS . " WHERE forum_id = " . $moderators_forum; @@ -789,7 +789,7 @@ if (!isset($_REQUEST['dosearch'])) { case 'search_misc': default: - $misc = trim(strtolower($misc)); + $misc = strtolower(trim($misc)); $base_url .= '&search_misc=true&misc=' . rawurlencode(stripslashes($misc)); @@ -888,7 +888,7 @@ if (!isset($_REQUEST['dosearch'])) { $select_sql .= " $order"; - $page = (isset($_GET['page'])) ? intval($_GET['page']) : intval(trim(@$_POST['page'])); + $page = (isset($_GET['page'])) ? (int)$_GET['page'] : (int)trim(@$_POST['page']); if ($page < 1) { $page = 1; @@ -904,7 +904,7 @@ if (!isset($_REQUEST['dosearch'])) { $select_sql .= " $limit"; - if (!is_null($total_sql)) { + if (null !== $total_sql) { if (!$result = DB()->sql_query($total_sql)) { bb_die('Could not count users'); } @@ -970,7 +970,7 @@ if (!isset($_REQUEST['dosearch'])) { $banned[$row['user_id']] = true; } - for ($i = 0; $i < count($rowset); $i++) { + for ($i = 0, $iMax = count($rowset); $i < $iMax; $i++) { $row_class = !($i % 2) ? 'row1' : 'row2'; $template->assign_block_vars('userrow', array( diff --git a/admin/admin_words.php b/admin/admin_words.php index 23891efe0..a76ec50bd 100644 --- a/admin/admin_words.php +++ b/admin/admin_words.php @@ -27,7 +27,8 @@ if (!empty($setmodules)) { $module['GENERAL']['WORD_CENSOR'] = basename(__FILE__); return; } -require('./pagestart.php'); + +require __DIR__ . '/pagestart.php'; if (!$bb_cfg['use_word_censor']) { bb_die('Word censor disabled

($bb_cfg[\'use_word_censor\'] in config.php)'); @@ -44,7 +45,7 @@ if (isset($_POST['add'])) { if ($mode != '') { if ($mode == 'edit' || $mode == 'add') { - $word_id = intval(request_var('id', 0)); + $word_id = (int)request_var('id', 0); $s_hidden_fields = $word = $replacement = ''; @@ -72,7 +73,7 @@ if ($mode != '') { 'S_HIDDEN_FIELDS' => $s_hidden_fields, )); } elseif ($mode == 'save') { - $word_id = intval(request_var('id', 0)); + $word_id = (int)request_var('id', 0); $word = trim(request_var('word', '')); $replacement = trim(request_var('replacement', '')); @@ -100,7 +101,7 @@ if ($mode != '') { bb_die($message); } elseif ($mode == 'delete') { - $word_id = intval(request_var('id', 0)); + $word_id = (int)request_var('id', 0); if ($word_id) { $sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id"; diff --git a/admin/index.php b/admin/index.php index 5e838b41a..b356f4b6f 100644 --- a/admin/index.php +++ b/admin/index.php @@ -23,7 +23,7 @@ * SOFTWARE. */ -require('./pagestart.php'); +require __DIR__ . '/pagestart.php'; // Generate relevant output if (isset($_GET['pane']) && $_GET['pane'] == 'left') { @@ -104,11 +104,11 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') { $avatar_dir_size = $lang['NOT_AVAILABLE']; } - if (intval($posts_per_day) > $total_posts) { + if ((int)$posts_per_day > $total_posts) { $posts_per_day = $total_posts; } - if (intval($topics_per_day) > $total_topics) { + if ((int)$topics_per_day > $total_topics) { $topics_per_day = $total_topics; } @@ -130,7 +130,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') { $tabledata_ary = DB()->sql_fetchrowset($result); $dbsize = 0; - for ($i = 0; $i < count($tabledata_ary); $i++) { + for ($i = 0, $iMax = count($tabledata_ary); $i < $iMax; $i++) { if (@$tabledata_ary[$i]['Type'] != 'MRG_MYISAM') { $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; } @@ -192,7 +192,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') { if (count($onlinerow_reg)) { $registered_users = $hidden_users = 0; - for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++) { + for ($i = 0, $iMax = count($onlinerow_reg); $i < $iMax; $i++) { if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary)) { $reg_userid_ary[] = $onlinerow_reg[$i]['user_id']; @@ -226,7 +226,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') { if (count($onlinerow_guest)) { $guest_users = 0; - for ($i = 0; $i < count($onlinerow_guest); $i++) { + for ($i = 0, $iMax = count($onlinerow_guest); $i < $iMax; $i++) { $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip']; $guest_users++; @@ -263,7 +263,7 @@ print_page('index.tpl', 'admin'); // Functions function inarray($needle, $haystack) { - for ($i = 0; $i < sizeof($haystack); $i++) { + for ($i = 0, $iMax = count($haystack); $i < $iMax; $i++) { if ($haystack[$i] == $needle) { return true; } diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index 2e892f4dc..a3e2ec78d 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -36,7 +36,7 @@ if (!IS_ADMIN) { $peers_in_last_minutes = array(30, 15, 5, 1); $peers_in_last_sec_limit = 300; -$announce_interval = intval($bb_cfg['announce_interval']); +$announce_interval = (int)$bb_cfg['announce_interval']; $stat = array(); define('TMP_TRACKER_TABLE', 'tmp_tracker'); @@ -131,11 +131,11 @@ echo "\n \n"; -echo "\n peers: in last " . join(' / ', $peers_in_last_minutes) . " min\n"; -echo "\n" . join(' / ', $peers_in_last_min) . "\n"; +echo "\n peers: in last " . implode(' / ', $peers_in_last_minutes) . " min\n"; +echo "\n" . implode(' / ', $peers_in_last_min) . "\n"; echo "\n peers in last $peers_in_last_sec_limit sec
[ per second, DESC order --> ]
last peer: $stat[last_peer_time] seconds ago
" . date("j M H:i:s [T O]") . " \n"; -echo '
 ' . join(' ', $peers_in_last_sec) . "
\n"; +echo '
 ' . implode(' ', $peers_in_last_sec) . "
\n"; echo ''; diff --git a/ajax.php b/ajax.php index 2f14061d6..8bf17a936 100644 --- a/ajax.php +++ b/ajax.php @@ -129,7 +129,7 @@ class ajax_common 'index_data' => array('guest'), ); - public $action = null; + public $action; /** * Constructor diff --git a/bt/announce.php b/bt/announce.php index 5cc2471bb..1cc50abd6 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -188,8 +188,7 @@ function msg_die($msg) } // Start announcer -define('TR_ROOT', './'); -require(TR_ROOT . 'includes/init_tr.php'); +require __DIR__ . '/includes/init_tr.php'; $seeder = ($left == 0) ? 1 : 0; $stopped = ($event === 'stopped'); @@ -438,7 +437,7 @@ if (!$output) { foreach ($rowset as $peer) { $peers[] = array( 'ip' => decode_ip($peer['ip']), - 'port' => intval($peer['port']), + 'port' => (int)$peer['port'], ); } } diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php index c177255d0..a73ff89c7 100644 --- a/bt/includes/init_tr.php +++ b/bt/includes/init_tr.php @@ -53,7 +53,7 @@ function tracker_exit() $str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_timetotal, $sql_total_perc); $str[] = $DBS->num_queries; $str[] = sprintf('%.1f', sys('la')); - $str = join(LOG_SEPR, $str) . LOG_LF; + $str = implode(LOG_SEPR, $str) . LOG_LF; dbg_log($str, '!!gentime'); } } diff --git a/bt/scrape.php b/bt/scrape.php index d30a6dac9..5d561d327 100644 --- a/bt/scrape.php +++ b/bt/scrape.php @@ -59,8 +59,7 @@ function msg_die($msg) die($output); } -define('TR_ROOT', './'); -require(TR_ROOT . 'includes/init_tr.php'); +require __DIR__ . '/includes/init_tr.php'; $info_hash_sql = rtrim(DB()->escape($info_hash), ' '); diff --git a/callseed.php b/callseed.php index fc8976768..d71714316 100644 --- a/callseed.php +++ b/callseed.php @@ -51,7 +51,7 @@ $sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_u foreach ($sql as $row) { $ban_user_id[] = ',' . $row['ban_userid']; } -$ban_user_id = join('', $ban_user_id); +$ban_user_id = implode('', $ban_user_id); $user_list = DB()->fetch_rowset(" SELECT DISTINCT dl.user_id, u.user_opt, tr.user_id as active_dl diff --git a/common.php b/common.php index 79a13a9c9..4d0257045 100644 --- a/common.php +++ b/common.php @@ -213,7 +213,7 @@ function utime() function bb_log($msg, $file_name) { if (is_array($msg)) { - $msg = join(LOG_LF, $msg); + $msg = implode(LOG_LF, $msg); } $file_name .= (LOG_EXT) ? '.' . LOG_EXT : ''; return file_write($msg, LOG_DIR . '/' . $file_name); @@ -268,9 +268,9 @@ function mkdir_rec($path, $mode) { if (is_dir($path)) { return ($path !== '.' && $path !== '..') ? is_writable($path) : false; - } else { - return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false; } + + return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false; } function verify_id($id, $length) @@ -342,40 +342,42 @@ function bencode($var) { if (is_string($var)) { return strlen($var) . ':' . $var; - } elseif (is_int($var)) { + } + + if (is_int($var)) { return 'i' . $var . 'e'; } elseif (is_float($var)) { return 'i' . sprintf('%.0f', $var) . 'e'; } elseif (is_array($var)) { if (count($var) == 0) { return 'de'; - } else { - $assoc = false; + } - foreach ($var as $key => $val) { - if (!is_int($key)) { - $assoc = true; - break; - } - } + $assoc = false; - if ($assoc) { - ksort($var, SORT_REGULAR); - $ret = 'd'; - - foreach ($var as $key => $val) { - $ret .= bencode($key) . bencode($val); - } - return $ret . 'e'; - } else { - $ret = 'l'; - - foreach ($var as $val) { - $ret .= bencode($val); - } - return $ret . 'e'; + foreach ($var as $key => $val) { + if (!is_int($key)) { + $assoc = true; + break; } } + + if ($assoc) { + ksort($var, SORT_REGULAR); + $ret = 'd'; + + foreach ($var as $key => $val) { + $ret .= bencode($key) . bencode($val); + } + return $ret . 'e'; + } + + $ret = 'l'; + + foreach ($var as $val) { + $ret .= bencode($val); + } + return $ret . 'e'; } else { trigger_error('bencode error: wrong data type', E_USER_ERROR); } @@ -411,7 +413,7 @@ function sys($param) { switch ($param) { case 'la': - return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0; + return function_exists('sys_getloadavg') ? implode(' ', sys_getloadavg()) : 0; break; case 'mem': return function_exists('memory_get_usage') ? memory_get_usage() : 0; @@ -449,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) { @@ -473,7 +475,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true) if (!empty($_POST) && $add_post) { $str[] = "post: " . str_compact(urldecode(http_build_query($_POST))); } - $str = join("\t", $str) . "\n"; + $str = implode("\t", $str) . "\n"; bb_log($str, $file); } @@ -482,7 +484,7 @@ if (defined('IN_FORUM')) { require INC_DIR . '/init_bb.php'; } // Tracker init elseif (defined('IN_TRACKER')) { - define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? intval($_GET['port']) : mt_rand(1000, 65000))); + define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int) $_GET['port'] : mt_rand(1000, 65000))); function dummy_exit($interval = 1800) { diff --git a/cron.php b/cron.php index a6b116cb0..65db74530 100644 --- a/cron.php +++ b/cron.php @@ -24,6 +24,6 @@ */ define('START_CRON', true); -define('BB_ROOT', dirname(__FILE__) . '/'); +define('BB_ROOT', __DIR__ . '/'); require __DIR__ . '/common.php'; diff --git a/dl.php b/dl.php index df1dbbe87..6e8223518 100644 --- a/dl.php +++ b/dl.php @@ -54,7 +54,7 @@ function send_file_to_browser($attachment, $upload_dir) // Correct the mime type - we force application/octet-stream for all files, except images // Please do not change this, it is a security precaution - if (!strstr($attachment['mimetype'], 'image')) { + if (false === strpos($attachment['mimetype'], 'image')) { $attachment['mimetype'] = 'application/octet-stream'; } @@ -131,7 +131,7 @@ $auth_pages = DB()->sql_fetchrowset($result); $num_auth_pages = DB()->num_rows($result); for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++) { - $auth_pages[$i]['post_id'] = intval($auth_pages[$i]['post_id']); + $auth_pages[$i]['post_id'] = (int)$auth_pages[$i]['post_id']; if ($auth_pages[$i]['post_id'] != 0) { $sql = 'SELECT forum_id, topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int)$auth_pages[$i]['post_id']; @@ -178,7 +178,7 @@ if (!in_array($attachment['extension'], $allowed_extensions) && !IS_ADMIN) { bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])); } -$download_mode = intval($download_mode[$attachment['extension']]); +$download_mode = (int)$download_mode[$attachment['extension']]; if ($thumbnail) { $attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename']; diff --git a/dl_list.php b/dl_list.php index f9828ed77..48706c0d5 100644 --- a/dl_list.php +++ b/dl_list.php @@ -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 @@ -128,7 +128,7 @@ if ($mode == 'set_topics_dl_status') { } // Get existing topics -if ($req_topics_sql = join(',', $req_topics_ary)) { +if ($req_topics_sql = implode(',', $req_topics_ary)) { $sql = "SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)"; foreach (DB()->fetch_rowset($sql) as $row) { diff --git a/group.php b/group.php index 8a5961198..0696b53ad 100644 --- a/group.php +++ b/group.php @@ -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']) ? '' . $lang['SEND_PM_TXTB'] . '' : '' . $lang['SEND_PRIVATE_MESSAGE'] . ''; $avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50); @@ -66,8 +66,8 @@ $user->session_start(array('req_login' => true)); set_die_append_msg(); -$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : null; -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $per_page = $bb_cfg['group_members_per_page']; $view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null; $rel_limit = 50; @@ -281,7 +281,7 @@ if (!$group_id) { foreach ($members as $members_id) { $sql_in[] = (int)$members_id; } - if (!$sql_in = join(',', $sql_in)) { + if (!$sql_in = implode(',', $sql_in)) { bb_die($lang['NONE_SELECTED']); } diff --git a/group_edit.php b/group_edit.php index d770940eb..3d1c6bcf9 100644 --- a/group_edit.php +++ b/group_edit.php @@ -34,7 +34,7 @@ $page_cfg['include_bbcode_js'] = true; // Start session management $user->session_start(array('req_login' => true)); -$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : null; +$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null; $group_info = array(); $is_moderator = false; diff --git a/index.php b/index.php index 330a627f9..ed60a32bf 100644 --- a/index.php +++ b/index.php @@ -211,7 +211,7 @@ foreach ($cat_forums as $cid => $c) { )); $template->assign_vars(array( - 'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false, + 'H_C_AL_MESS' => ($hide_cat_opt && !$showhide), )); if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) { @@ -255,7 +255,7 @@ foreach ($cat_forums as $cid => $c) { 'POSTS' => commify($f['forum_posts']), 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, - 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '', + 'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '', 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'], )); @@ -365,7 +365,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { $week_list[] = profile_url($week) . ' (' . birthday_age($week['user_birthday'] - 1) . ')'; } $week_all = ($week_all) ? ' ...' : ''; - $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all; + $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $week_list)) . $week_all; } else { $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']); } @@ -380,7 +380,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { $today_list[] = profile_url($today) . ' (' . birthday_age($today['user_birthday']) . ')'; } $today_all = ($today_all) ? ' ...' : ''; - $today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all; + $today_list = $lang['BIRTHDAY_TODAY'] . implode(', ', $today_list) . $today_all; } else { $today_list = $lang['NOBIRTHDAY_TODAY']; } diff --git a/install/upgrade/r583-convert_avatars.php b/install/upgrade/r583-convert_avatars.php index c7b028607..60b938a42 100644 --- a/install/upgrade/r583-convert_avatars.php +++ b/install/upgrade/r583-convert_avatars.php @@ -80,7 +80,7 @@ if ($confirm) { DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$upload->file_ext_id} WHERE user_id = {$row['user_id']} LIMIT 1"); $avatars_ok++; } else { - echo "{$row['user_id']}: ", join("\n{$row['user_id']}: ", $upload->errors), "\n"; + echo "{$row['user_id']}: ", implode("\n{$row['user_id']}: ", $upload->errors), "\n"; $avatars_err++; } } diff --git a/library/ajax/change_user_rank.php b/library/ajax/change_user_rank.php index 5cfe3aa48..78d3f8174 100644 --- a/library/ajax/change_user_rank.php +++ b/library/ajax/change_user_rank.php @@ -30,9 +30,9 @@ if (!defined('IN_AJAX')) { global $datastore, $lang; $ranks = $datastore->get('ranks'); -$rank_id = intval($this->request['rank_id']); +$rank_id = (int)$this->request['rank_id']; -if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) { +if (!$user_id = (int)$this->request['user_id'] or !$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 12778c893..da4556659 100644 --- a/library/ajax/edit_group_profile.php +++ b/library/ajax/edit_group_profile.php @@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) { global $bb_cfg, $userdata, $lang; -if (!$group_id = intval($this->request['group_id']) or !$group_info = get_group_data($group_id)) { +if (!$group_id = (int)$this->request['group_id'] or !$group_info = get_group_data($group_id)) { $this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']); } if (!$mode = (string)$this->request['mode']) { diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php index 6f78ead49..ed7aeb90c 100644 --- a/library/ajax/edit_user_profile.php +++ b/library/ajax/edit_user_profile.php @@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) { global $bb_cfg, $lang; -if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) { +if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } if (!$field = (string)$this->request['field']) { diff --git a/library/ajax/group_membership.php b/library/ajax/group_membership.php index ed4551dc3..7a54ccb18 100644 --- a/library/ajax/group_membership.php +++ b/library/ajax/group_membership.php @@ -29,7 +29,7 @@ if (!defined('IN_AJAX')) { global $lang, $user; -if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) { +if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { $this->ajax_die("invalid user_id: $user_id"); } @@ -71,7 +71,7 @@ switch ($mode) { } } if ($html) { - $this->response['group_list_html'] = ''; + $this->response['group_list_html'] = ''; } else { $this->response['group_list_html'] = $lang['GROUP_LIST_HIDDEN']; } diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php index 872cac13f..52f76bf25 100644 --- a/library/ajax/index_data.php +++ b/library/ajax/index_data.php @@ -43,7 +43,7 @@ switch ($mode) { foreach ($stats['birthday_week_list'] as $week) { $html[] = profile_url($week) . ' (' . birthday_age($week['user_birthday']) . ')'; } - $html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $html)); + $html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $html)); } else { $html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']); } @@ -59,7 +59,7 @@ switch ($mode) { foreach ($stats['birthday_today_list'] as $today) { $html[] = profile_url($today) . ' (' . birthday_age($today['user_birthday']) . ')'; } - $html = $lang['BIRTHDAY_TODAY'] . join(', ', $html); + $html = $lang['BIRTHDAY_TODAY'] . implode(', ', $html); } else { $html = $lang['NOBIRTHDAY_TODAY']; } @@ -88,7 +88,7 @@ switch ($mode) { } $html = ': '; - $html .= ($moderators) ? join(', ', $moderators) : $lang['NONE']; + $html .= ($moderators) ? implode(', ', $moderators) : $lang['NONE']; unset($moderators, $mod); $datastore->rm('moderators'); break; diff --git a/library/ajax/topic_tpl.php b/library/ajax/topic_tpl.php index f355dce10..97b1feb24 100644 --- a/library/ajax/topic_tpl.php +++ b/library/ajax/topic_tpl.php @@ -103,7 +103,7 @@ switch ($mode) { $this->response['val']['tpl-last-edit-tst'] = $tpl_data['tpl_last_edit_tm']; $this->response['html']['tpl-name-old-save'] = $tpl_data['tpl_name']; $this->response['html']['tpl-last-edit-time'] = bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i'); - $this->response['html']['tpl-last-edit-by'] = get_username(intval($tpl_data['tpl_last_edit_by'])); + $this->response['html']['tpl-last-edit-by'] = get_username((int)$tpl_data['tpl_last_edit_by']); $this->response['tpl_rules_href'] = POST_URL . $tpl_data['tpl_rules_post_id'] . '#' . $tpl_data['tpl_rules_post_id']; break; @@ -137,7 +137,7 @@ switch ($mode) { // сохранение изменений case 'save': if ($tpl_data['tpl_last_edit_tm'] > $this->request['tpl_l_ed_tst'] && $tpl_data['tpl_last_edit_by'] != $userdata['user_id']) { - $last_edit_by_username = get_username(intval($tpl_data['tpl_last_edit_by'])); + $last_edit_by_username = get_username((int)$tpl_data['tpl_last_edit_by']); $msg = "Изменения не были сохранены!\n\n"; $msg .= 'Шаблон был отредактирован: ' . html_entity_decode($last_edit_by_username) . ', ' . delta_time($tpl_data['tpl_last_edit_tm']) . " назад\n\n"; $this->ajax_die($msg); diff --git a/library/attach_mod/displaying.php b/library/attach_mod/displaying.php index 943b5e1e4..6d2b91f44 100644 --- a/library/attach_mod/displaying.php +++ b/library/attach_mod/displaying.php @@ -46,11 +46,11 @@ function init_complete_extensions_data() } $allowed_extensions = array(); - for ($i = 0, $size = sizeof($extension_informations); $i < $size; $i++) { + for ($i = 0, $size = count($extension_informations); $i < $size; $i++) { $extension = strtolower(trim($extension_informations[$i]['extension'])); $allowed_extensions[] = $extension; - $display_categories[$extension] = intval($extension_informations[$i]['cat_id']); - $download_modes[$extension] = intval($extension_informations[$i]['download_mode']); + $display_categories[$extension] = (int)$extension_informations[$i]['cat_id']; + $download_modes[$extension] = (int)$extension_informations[$i]['download_mode']; $upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']); } } @@ -74,7 +74,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop $filename_2 = $template->files[$template_var]; - $str = implode('', @file($filename_2)); + $str = file_get_contents($filename_2); if (empty($str)) { die("Template->loadfile(): File $filename_2 for handle $template_var is empty"); } @@ -83,7 +83,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop } $complete_filename = $filename; - if (substr($complete_filename, 0, 1) != '/') { + if ($complete_filename[0] != '/') { $complete_filename = $template->root . '/' . $complete_filename; } @@ -91,7 +91,7 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop die("Template->make_filename(): Error - file $complete_filename does not exist"); } - $content = implode('', file($complete_filename)); + $content = file_get_contents($complete_filename); if (empty($content)) { die('Template->loadfile(): File ' . $complete_filename . ' is empty'); } @@ -107,7 +107,7 @@ function display_post_attachments($post_id, $switch_attachment) { global $attach_config, $is_auth; - if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) { + if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod']) { return; } @@ -127,7 +127,7 @@ function init_display_post_attachments($switch_attachment) $switch_attachment = $forum_row['topic_attachment']; } - if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view']))) { + if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod'] || (!($is_auth['auth_download'] && $is_auth['auth_view']))) { init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl'); return; } @@ -140,12 +140,12 @@ function init_display_post_attachments($switch_attachment) } } - if (sizeof($post_id_array) == 0) { + if (count($post_id_array) == 0) { return; } $rows = get_attachments_from_post($post_id_array); - $num_rows = sizeof($rows); + $num_rows = count($rows); if ($num_rows == 0) { return; @@ -183,7 +183,7 @@ function display_attachments($post_id) { global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config; - $num_attachments = @sizeof($attachments['_' . $post_id]); + $num_attachments = @count($attachments['_' . $post_id]); if ($num_attachments == 0) { return; @@ -227,14 +227,14 @@ function display_attachments($post_id) $thumbnail = false; $link = false; - if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) { - if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) { + if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && (int)$attach_config['img_display_inlined']) { + if ((int)$attach_config['img_link_width'] != 0 || (int)$attach_config['img_link_height'] != 0) { list($width, $height) = image_getdimension($filename); if ($width == 0 && $height == 0) { $image = true; } else { - if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) { + if ($width <= (int)$attach_config['img_link_width'] && $height <= (int)$attach_config['img_link_height']) { $image = true; } } @@ -243,7 +243,7 @@ function display_attachments($post_id) } } - if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) { + if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) { $thumbnail = true; $image = false; } @@ -304,7 +304,7 @@ function display_attachments($post_id) if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) { include ATTACH_DIR . '/displaying_torrent.php'; } elseif ($link) { - $target_blank = ((@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT)) ? 'target="_blank"' : ''; + $target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : ''; // display attachment $template->assign_block_vars('postrow.attach.attachrow', array( diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 2acd53104..76884d1d2 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -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 = '' . $lang['BT_REG_ON_TRACKER'] . ''; @@ -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']; @@ -297,7 +297,6 @@ if ($tor_reged && $tor_info) { FROM " . BB_BT_TRACKER . " tr, " . BB_USERS . " u WHERE tr.topic_id = $tor_id AND u.user_id = tr.user_id - GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder ORDER BY u.username LIMIT $show_peers_limit"; } else { @@ -308,7 +307,6 @@ if ($tor_reged && $tor_info) { FROM " . BB_BT_TRACKER . " tr LEFT JOIN " . BB_USERS . " u ON u.user_id = tr.user_id WHERE tr.topic_id = $tor_id - GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder ORDER BY $full_mode_order $full_mode_sort_dir LIMIT $show_peers_limit"; } @@ -334,7 +332,7 @@ if ($tor_reged && $tor_info) { $sp_up_tot[$x] += $peer['speed_up']; $sp_down_tot[$x] += $peer['speed_down']; - $guest = ($peer['user_id'] == GUEST_UID || is_null($peer['username'])); + $guest = ($peer['user_id'] == GUEST_UID || null === $peer['username']); $p_max_up = $peer['uploaded']; $p_max_down = $peer['downloaded']; @@ -498,14 +496,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, )); } } diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php index 51280986f..111412187 100644 --- a/library/attach_mod/includes/functions_admin.php +++ b/library/attach_mod/includes/functions_admin.php @@ -106,7 +106,7 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0) */ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0) { - $last_element = sizeof($sort_array) - 1; + $last_element = count($sort_array) - 1; if (!$pre_string_sort) { $string_sort = (!is_numeric(@$sort_array[$last_element - 1][$key])) ? true : false; @@ -121,17 +121,13 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0) // do checks based on key $switch = false; if (!$string_sort) { - if ( - ($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) || - ($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key])) - ) { + if (($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) || + ($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key]))) { $switch = true; } } else { - if ( - ($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) || - ($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0) - ) { + if (($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) || + ($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0)) { $switch = true; } } @@ -209,7 +205,7 @@ function search_attachments($order_by, &$total_rows) $matching_userids = ''; if ($row = DB()->sql_fetchrow($result)) { do { - $matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']); + $matching_userids .= (($matching_userids != '') ? ', ' : '') . $row['user_id']; } while ($row = DB()->sql_fetchrow($result)); DB()->sql_freeresult($result); @@ -260,13 +256,13 @@ function search_attachments($order_by, &$total_rows) // Search Forum $search_forum = get_var('search_forum', ''); if ($search_forum) { - $where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') '; + $where_sql[] = ' (p.forum_id = ' . (int)$search_forum . ') '; } $sql = 'SELECT a.*, t.post_id, p.post_time, p.topic_id FROM ' . BB_ATTACHMENTS . ' t, ' . BB_ATTACHMENTS_DESC . ' a, ' . BB_POSTS . ' p WHERE '; - if (sizeof($where_sql) > 0) { + if (count($where_sql) > 0) { $sql .= implode('AND', $where_sql) . ' AND '; } @@ -309,7 +305,7 @@ function search_attachments($order_by, &$total_rows) function limit_array($array, $start, $pagelimit) { // array from start - start+pagelimit - $limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit; + $limit = (count($array) < ($start + $pagelimit)) ? count($array) : $start + $pagelimit; $limit_array = []; diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index 106d42404..1ebc808ce 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -49,7 +49,9 @@ function base64_pack($number) if ($number > 4096) { return; - } elseif ($number < $base) { + } + + if ($number < $base) { return $chars[$number]; } @@ -81,7 +83,7 @@ function base64_unpack($string) for ($i = 1; $i <= $length; $i++) { $pos = $length - $i; - $operand = strpos($chars, substr($string, $pos, 1)); + $operand = strpos($chars, $string[$pos]); $exponent = pow($base, $i - 1); $decValue = $operand * $exponent; $number += $decValue; @@ -101,8 +103,8 @@ function auth_pack($auth_array) $one_char = $two_char = false; $auth_cache = ''; - for ($i = 0; $i < sizeof($auth_array); $i++) { - $val = base64_pack(intval($auth_array[$i])); + for ($i = 0, $iMax = count($auth_array); $i < $iMax; $i++) { + $val = base64_pack((int)$auth_array[$i]); if (strlen($val) == 1 && !$one_char) { $auth_cache .= $one_char_encoding; $one_char = true; @@ -129,11 +131,13 @@ function auth_unpack($auth_cache) $auth_len = 1; for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { - $forum_auth = substr($auth_cache, $pos, 1); + $forum_auth = $auth_cache[$pos]; if ($forum_auth == $one_char_encoding) { $auth_len = 1; continue; - } elseif ($forum_auth == $two_char_encoding) { + } + + if ($forum_auth == $two_char_encoding) { $auth_len = 2; $pos--; continue; @@ -141,7 +145,7 @@ function auth_unpack($auth_cache) $forum_auth = substr($auth_cache, $pos, $auth_len); $forum_id = base64_unpack($forum_auth); - $auth[] = intval($forum_id); + $auth[] = (int)$forum_id; } return $auth; } @@ -162,11 +166,13 @@ function is_forum_authed($auth_cache, $check_forum_id) $auth_len = 1; for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { - $forum_auth = substr($auth_cache, $pos, 1); + $forum_auth = $auth_cache[$pos]; if ($forum_auth == $one_char_encoding) { $auth_len = 1; continue; - } elseif ($forum_auth == $two_char_encoding) { + } + + if ($forum_auth == $two_char_encoding) { $auth_len = 2; $pos--; continue; @@ -196,9 +202,7 @@ function unlink_attach($filename, $mode = false) $filename = $upload_dir . '/' . $filename; } - $deleted = @unlink($filename); - - return $deleted; + return @unlink($filename); } /** @@ -212,9 +216,9 @@ function attachment_exists($filename) if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename))) { return false; - } else { - return true; } + + return true; } /** @@ -228,9 +232,9 @@ function thumbnail_exists($filename) if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) { return false; - } else { - return true; } + + return true; } /** @@ -255,7 +259,7 @@ function physical_filename_already_stored($filename) $num_rows = DB()->num_rows($result); DB()->sql_freeresult($result); - return ($num_rows == 0) ? false : true; + return $num_rows != 0; } /** @@ -272,7 +276,7 @@ function get_attachments_from_post($post_id_array) return $attachments; } - $post_id = intval($post_id_array); + $post_id = (int)$post_id_array; $post_id_array = array(); $post_id_array[] = $post_id; @@ -284,7 +288,7 @@ function get_attachments_from_post($post_id_array) return $attachments; } - $display_order = (intval($attach_config['display_order']) == 0) ? 'DESC' : 'ASC'; + $display_order = ((int)$attach_config['display_order'] == 0) ? 'DESC' : 'ASC'; $sql = 'SELECT a.post_id, d.* FROM ' . BB_ATTACHMENTS . ' a, ' . BB_ATTACHMENTS_DESC . " d @@ -312,7 +316,7 @@ function get_attachments_from_post($post_id_array) */ function get_total_attach_filesize($attach_ids) { - if (!is_array($attach_ids) || !sizeof($attach_ids)) { + if (!is_array($attach_ids) || !count($attach_ids)) { return 0; } @@ -352,7 +356,7 @@ function get_extension_informations() function attachment_sync_topic($topics) { if (is_array($topics)) { - $topics = join(',', $topics); + $topics = implode(',', $topics); } $posts_without_attach = $topics_without_attach = array(); @@ -368,7 +372,7 @@ function attachment_sync_topic($topics) foreach ($rowset as $row) { $posts_without_attach[] = $row['post_id']; } - if ($posts_sql = join(',', $posts_without_attach)) { + if ($posts_sql = implode(',', $posts_without_attach)) { DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)"); } } @@ -395,7 +399,7 @@ function attachment_sync_topic($topics) foreach ($rowset as $row) { $topics_without_attach[] = $row['topic_id']; } - if ($topics_sql = join(',', $topics_without_attach)) { + if ($topics_sql = implode(',', $topics_without_attach)) { DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)"); } } @@ -406,7 +410,7 @@ function attachment_sync_topic($topics) */ function get_extension($filename) { - if (!stristr($filename, '.')) { + if (false === strstr($filename, '.')) { return ''; } $extension = strrchr(strtolower($filename), '.'); @@ -414,9 +418,9 @@ function get_extension($filename) $extension = strtolower(trim($extension)); if (is_array($extension)) { return ''; - } else { - return $extension; } + + return $extension; } /** @@ -454,11 +458,7 @@ function user_in_group($user_id, $group_id) $num_rows = DB()->num_rows($result); DB()->sql_freeresult($result); - if ($num_rows == 0) { - return false; - } - - return true; + return !($num_rows == 0); } /** @@ -501,11 +501,9 @@ function _set_var(&$result, $var, $type, $multibyte = false) */ function get_var($var_name, $default, $multibyte = false) { - if ( - !isset($_REQUEST[$var_name]) || + if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || - (is_array($default) && !is_array($_REQUEST[$var_name])) - ) { + (is_array($default) && !is_array($_REQUEST[$var_name]))) { return (is_array($default)) ? [] : $default; } @@ -550,9 +548,9 @@ function attach_mod_sql_escape($text) { if (function_exists('mysqli_real_escape_string')) { return DB()->escape_string($text); - } else { - return str_replace("'", "''", str_replace('\\', '\\\\', $text)); } + + return str_replace("'", "''", str_replace('\\', '\\\\', $text)); } /** @@ -573,14 +571,14 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) foreach ($assoc_ary as $key => $var) { $fields[] = $key; - if (is_null($var)) { + if (null === $var) { $values[] = 'NULL'; } elseif (is_string($var)) { $values[] = "'" . attach_mod_sql_escape($var) . "'"; } elseif (is_array($var) && is_string($var[0])) { $values[] = $var[0]; } else { - $values[] = (is_bool($var)) ? intval($var) : $var; + $values[] = (is_bool($var)) ? (int)$var : $var; } } @@ -590,12 +588,12 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) foreach ($assoc_ary as $id => $sql_ary) { $values = array(); foreach ($sql_ary as $key => $var) { - if (is_null($var)) { + if (null === $var) { $values[] = 'NULL'; } elseif (is_string($var)) { $values[] = "'" . attach_mod_sql_escape($var) . "'"; } else { - $values[] = (is_bool($var)) ? intval($var) : $var; + $values[] = (is_bool($var)) ? (int)$var : $var; } } $ary[] = '(' . implode(', ', $values) . ')'; @@ -605,12 +603,12 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) } elseif ($query == 'UPDATE' || $query == 'SELECT') { $values = array(); foreach ($assoc_ary as $key => $var) { - if (is_null($var)) { + if (null === $var) { $values[] = "$key = NULL"; } elseif (is_string($var)) { $values[] = "$key = '" . attach_mod_sql_escape($var) . "'"; } else { - $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var"; + $values[] = (is_bool($var)) ? "$key = " . (int)$var : "$key = $var"; } } $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); diff --git a/library/attach_mod/includes/functions_delete.php b/library/attach_mod/includes/functions_delete.php index 228db7451..d13a2d55b 100644 --- a/library/attach_mod/includes/functions_delete.php +++ b/library/attach_mod/includes/functions_delete.php @@ -41,12 +41,12 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $post_id_array = array(); if (!is_array($attach_id_array)) { - if (strstr($attach_id_array, ', ')) { + if (false !== strpos($attach_id_array, ', ')) { $attach_id_array = explode(', ', $attach_id_array); } elseif (strstr($attach_id_array, ',')) { $attach_id_array = explode(',', $attach_id_array); } else { - $attach_id = intval($attach_id_array); + $attach_id = (int)$attach_id_array; $attach_id_array = array(); $attach_id_array[] = $attach_id; } @@ -72,7 +72,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } while ($row = DB()->sql_fetchrow($result)) { - $post_id_array[] = intval($row[$p_id]); + $post_id_array[] = (int)$row[$p_id]; } DB()->sql_freeresult($result); } @@ -82,19 +82,19 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, return; } - if (strstr($post_id_array, ', ')) { + if (false !== strpos($post_id_array, ', ')) { $post_id_array = explode(', ', $post_id_array); } elseif (strstr($post_id_array, ',')) { $post_id_array = explode(',', $post_id_array); } else { - $post_id = intval($post_id_array); + $post_id = (int)$post_id_array; $post_id_array = array(); $post_id_array[] = $post_id; } } - if (!sizeof($post_id_array)) { + if (!count($post_id_array)) { return; } @@ -127,25 +127,25 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } if (!is_array($attach_id_array)) { - if (strstr($attach_id_array, ', ')) { + if (false !== strpos($attach_id_array, ', ')) { $attach_id_array = explode(', ', $attach_id_array); } elseif (strstr($attach_id_array, ',')) { $attach_id_array = explode(',', $attach_id_array); } else { - $attach_id = intval($attach_id_array); + $attach_id = (int)$attach_id_array; $attach_id_array = array(); $attach_id_array[] = $attach_id; } } - if (!sizeof($attach_id_array)) { + if (!count($attach_id_array)) { return; } $sql_id = 'post_id'; - if (sizeof($post_id_array) && sizeof($attach_id_array)) { + if (count($post_id_array) && count($attach_id_array)) { $sql = 'DELETE FROM ' . BB_ATTACHMENTS . ' WHERE attach_id IN (' . implode(', ', $attach_id_array) . ") AND $sql_id IN (" . implode(', ', $post_id_array) . ')'; @@ -187,7 +187,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } //bt end - for ($i = 0; $i < sizeof($attach_id_array); $i++) { + for ($i = 0, $iMax = count($attach_id_array); $i < $iMax; $i++) { $sql = 'SELECT attach_id FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int)$attach_id_array[$i]; @@ -218,7 +218,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, for ($j = 0; $j < $num_attach; $j++) { unlink_attach($attachments[$j]['physical_filename']); - if (intval($attachments[$j]['thumbnail']) == 1) { + if ((int)$attachments[$j]['thumbnail'] == 1) { unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL); } @@ -236,7 +236,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } // Now Sync the Topic/PM - if (sizeof($post_id_array)) { + if (count($post_id_array)) { $sql = 'SELECT topic_id FROM ' . BB_POSTS . ' WHERE post_id IN (' . implode(', ', $post_id_array) . ') diff --git a/library/attach_mod/includes/functions_filetypes.php b/library/attach_mod/includes/functions_filetypes.php index 7d3ac79d6..4270caf58 100644 --- a/library/attach_mod/includes/functions_filetypes.php +++ b/library/attach_mod/includes/functions_filetypes.php @@ -49,9 +49,7 @@ function read_word($fp) { $data = fread($fp, 2); - $value = ord($data[1]) * 256 + ord($data[0]); - - return $value; + return ord($data[1]) * 256 + ord($data[0]); } /** @@ -61,9 +59,7 @@ function read_byte($fp) { $data = fread($fp, 1); - $value = ord($data); - - return $value; + return ord($data); } /** @@ -179,7 +175,7 @@ function image_getdimension($file) $tmp_str = fread($fp, 4); $w1 = read_word($fp); - if (intval($w1) < 16) { + if ((int)$w1 < 16) { $error = true; } @@ -187,7 +183,7 @@ function image_getdimension($file) $tmp_str = fread($fp, 4); if ($tmp_str == 'JFIF') { $o_byte = fread($fp, 1); - if (intval($o_byte) != 0) { + if ((int)$o_byte != 0) { $error = true; } diff --git a/library/attach_mod/includes/functions_includes.php b/library/attach_mod/includes/functions_includes.php index 35a0f6b0e..1de52403b 100644 --- a/library/attach_mod/includes/functions_includes.php +++ b/library/attach_mod/includes/functions_includes.php @@ -30,7 +30,7 @@ function attach_build_auth_levels($is_auth, &$s_auth_can) { global $lang, $attach_config; - if (intval($attach_config['disable_mod'])) { + if ((int)$attach_config['disable_mod']) { return; } diff --git a/library/attach_mod/includes/functions_selects.php b/library/attach_mod/includes/functions_selects.php index 1a771aa8a..9f7c636dc 100644 --- a/library/attach_mod/includes/functions_selects.php +++ b/library/attach_mod/includes/functions_selects.php @@ -50,7 +50,7 @@ function group_select($select_name, $default_group = 0) $group_name[$num_rows]['group_id'] = 0; $group_name[$num_rows]['group_name'] = $lang['NOT_ASSIGNED']; - for ($i = 0; $i < sizeof($group_name); $i++) { + for ($i = 0, $iMax = count($group_name); $i < $iMax; $i++) { if (!$default_group) { $selected = ($i == 0) ? ' selected="selected"' : ''; } else { @@ -93,7 +93,7 @@ function download_select($select_name, $group_id = 0) $group_select = ''; - for ($i = 0; $i < sizeof($types); $i++) { + for ($i = 0, $iMax = count($types); $i < $iMax; $i++) { if (!$group_id) { $selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : ''; } else { @@ -172,7 +172,7 @@ function size_select($select_name, $size_compare) $select_field = ' mode $select_sort_mode = '