From b5065ae0ac4c1ae08fd902fe986c39b0184942d1 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Fri, 5 May 2017 01:00:38 +0300 Subject: [PATCH] Type casting can be used. --- admin/admin_attach_cp.php | 18 ++++---- admin/admin_attachments.php | 4 +- admin/admin_disallow.php | 2 +- admin/admin_extensions.php | 12 ++--- admin/admin_forum_prune.php | 2 +- admin/admin_forumauth.php | 6 +-- admin/admin_forumauth_list.php | 12 ++--- admin/admin_forums.php | 44 +++++++++---------- admin/admin_groups.php | 8 ++-- admin/admin_log.php | 4 +- admin/admin_ranks.php | 8 ++-- admin/admin_rebuild_search.php | 8 ++-- admin/admin_smilies.php | 6 +-- admin/admin_user_ban.php | 2 +- admin/admin_user_search.php | 28 ++++++------ admin/admin_words.php | 6 +-- admin/index.php | 4 +- admin/stats/tracker.php | 2 +- bt/announce.php | 2 +- common.php | 2 +- dl.php | 4 +- group.php | 4 +- group_edit.php | 2 +- library/ajax/change_user_rank.php | 4 +- library/ajax/edit_group_profile.php | 2 +- library/ajax/edit_user_profile.php | 2 +- library/ajax/group_membership.php | 2 +- library/ajax/topic_tpl.php | 4 +- library/attach_mod/displaying.php | 18 ++++---- .../attach_mod/includes/functions_admin.php | 8 ++-- .../attach_mod/includes/functions_attach.php | 14 +++--- .../attach_mod/includes/functions_delete.php | 10 ++--- .../includes/functions_filetypes.php | 4 +- .../includes/functions_includes.php | 2 +- library/includes/classes/utf8.php | 14 +++--- .../includes/cron/jobs/board_maintenance.php | 2 +- library/includes/cron/jobs/clean_dlstat.php | 2 +- .../cron/jobs/prune_inactive_users.php | 4 +- .../includes/cron/jobs/sessions_cleanup.php | 6 +-- .../cron/jobs/tr_cleanup_and_dlstat.php | 4 +- library/includes/functions.php | 8 ++-- library/includes/functions_admin_torrent.php | 4 +- library/includes/functions_torrent.php | 16 +++---- library/includes/page_header.php | 2 +- library/includes/posting_tpl.php | 2 +- library/includes/sessions.php | 4 +- library/includes/ucp/activate.php | 2 +- library/includes/ucp/email.php | 2 +- library/includes/ucp/topic_watch.php | 2 +- memberlist.php | 2 +- modcp.php | 10 ++--- poll.php | 2 +- posting.php | 2 +- privmsg.php | 16 +++---- search.php | 2 +- tracker.php | 14 +++--- viewforum.php | 6 +-- viewtopic.php | 4 +- 58 files changed, 196 insertions(+), 196 deletions(-) diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index 4e22001a7..6e32a7d17 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.* @@ -396,11 +396,11 @@ if ($view === 'attachments') { 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 b127304f5..f230138a9 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -250,8 +250,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'], diff --git a/admin/admin_disallow.php b/admin/admin_disallow.php index ad86b28fd..36695ec6c 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); diff --git a/admin/admin_extensions.php b/admin/admin_extensions.php index a2f12e9cf..83838a103 100644 --- a/admin/admin_extensions.php +++ b/admin/admin_extensions.php @@ -85,7 +85,7 @@ if ($submit && $mode == 'extensions') { for ($i = 0; $i < count($extension_change_list); $i++) { $extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i]; - $extensions['_' . $extension_change_list[$i]]['group_id'] = intval($group_select_list[$i]); + $extensions['_' . $extension_change_list[$i]]['group_id'] = (int)$group_select_list[$i]; } $sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY ext_id'; @@ -99,7 +99,7 @@ if ($submit && $mode == 'extensions') { if ($num_rows > 0) { for ($i = 0; $i < count($extension_row); $i++) { - if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || intval($extension_row[$i]['group_id']) != intval($extensions['_' . $extension_row[$i]['ext_id']]['group_id'])) { + if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || (int)$extension_row[$i]['group_id'] != (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']) { $sql_ary = array( 'comment' => (string)$extensions['_' . $extension_row[$i]['ext_id']]['comment'], 'group_id' => (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id'] @@ -489,7 +489,7 @@ if (@$add_forum && $e_mode == 'perm' && $group) { if (!$add_all_forums) { $sql = 'SELECT forum_permissions FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . intval($group) . ' + WHERE group_id = ' . (int)$group . ' LIMIT 1'; if (!($result = DB()->sql_query($sql))) { @@ -529,7 +529,7 @@ if (@$delete_forum && $e_mode == 'perm' && $group) { // Get the current Forums $sql = 'SELECT forum_permissions FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . intval($group) . ' + WHERE group_id = ' . (int)$group . ' LIMIT 1'; if (!($result = DB()->sql_query($sql))) { @@ -562,7 +562,7 @@ if (@$delete_forum && $e_mode == 'perm' && $group) { if ($e_mode == 'perm' && $group) { $sql = 'SELECT group_name, forum_permissions FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . intval($group) . ' + WHERE group_id = ' . (int)$group . ' LIMIT 1'; if (!($result = DB()->sql_query($sql))) { @@ -618,7 +618,7 @@ if ($e_mode == 'perm' && $group) { } while ($row = DB()->sql_fetchrow($result)) { - $forum_option_values[intval($row['forum_id'])] = $row['forum_name']; + $forum_option_values[(int)$row['forum_id']] = $row['forum_name']; } DB()->sql_freeresult($result); diff --git a/admin/admin_forum_prune.php b/admin/admin_forum_prune.php index 249e0b9ed..08bd0bcbc 100644 --- a/admin/admin_forum_prune.php +++ b/admin/admin_forum_prune.php @@ -37,7 +37,7 @@ if (isset($_REQUEST['submit'])) { if (!$var =& $_REQUEST['f'] or !$f_selected = get_id_ary($var)) { bb_die('Forum not selected'); } - if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs(intval($var))) { + if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs((int)$var)) { bb_die($lang['NOT_DAYS']); } diff --git a/admin/admin_forumauth.php b/admin/admin_forumauth.php index 34a3f2c9e..c54490b8b 100644 --- a/admin/admin_forumauth.php +++ b/admin/admin_forumauth.php @@ -89,7 +89,7 @@ if (@$_REQUEST[POST_FORUM_URL]) { } if (isset($_GET['adv'])) { - $adv = intval($_GET['adv']); + $adv = (int)$_GET['adv']; } else { unset($adv); } @@ -102,7 +102,7 @@ if (isset($_POST['submit'])) { if (!empty($forum_id)) { if (isset($_POST['simpleauth'])) { - $simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])]; + $simple_ary = $simple_auth_ary[(int)$_POST['simpleauth']]; for ($i = 0; $i < count($simple_ary); $i++) { $sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i]; @@ -113,7 +113,7 @@ if (isset($_POST['submit'])) { } } else { for ($i = 0; $i < count($forum_auth_fields); $i++) { - $value = intval($_POST[$forum_auth_fields[$i]]); + $value = (int)$_POST[$forum_auth_fields[$i]]; if ($forum_auth_fields[$i] == 'auth_vote') { if ($_POST['auth_vote'] == AUTH_ALL) { diff --git a/admin/admin_forumauth_list.php b/admin/admin_forumauth_list.php index 613563f78..d43b6d22e 100644 --- a/admin/admin_forumauth_list.php +++ b/admin/admin_forumauth_list.php @@ -81,7 +81,7 @@ $forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'); $forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN); if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) { - $forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]); + $forum_id = (isset($_POST[POST_FORUM_URL])) ? (int)$_POST[POST_FORUM_URL] : (int)$_GET[POST_FORUM_URL]; $forum_sql = "AND forum_id = $forum_id"; } else { unset($forum_id); @@ -89,7 +89,7 @@ if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) { } if (isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL])) { - $cat_id = (isset($_POST[POST_CAT_URL])) ? intval($_POST[POST_CAT_URL]) : intval($_GET[POST_CAT_URL]); + $cat_id = (isset($_POST[POST_CAT_URL])) ? (int)$_POST[POST_CAT_URL] : (int)$_GET[POST_CAT_URL]; $cat_sql = "AND c.cat_id = $cat_id"; } else { unset($cat_id); @@ -97,7 +97,7 @@ if (isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL])) { } if (isset($_GET['adv'])) { - $adv = intval($_GET['adv']); + $adv = (int)$_GET['adv']; } else { unset($adv); } @@ -110,7 +110,7 @@ if (isset($_POST['submit'])) { if (!empty($forum_id)) { if (isset($_POST['simpleauth'])) { - $simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])]; + $simple_ary = $simple_auth_ary[(int)$_POST['simpleauth']]; for ($i = 0; $i < count($simple_ary); $i++) { $sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i]; @@ -121,7 +121,7 @@ if (isset($_POST['submit'])) { } } else { for ($i = 0; $i < count($forum_auth_fields); $i++) { - $value = intval($_POST[$forum_auth_fields[$i]]); + $value = (int)$_POST[$forum_auth_fields[$i]]; if ($forum_auth_fields[$i] == 'auth_vote') { if ($_POST['auth_vote'] == AUTH_ALL) { @@ -145,7 +145,7 @@ if (isset($_POST['submit'])) { $adv = 0; } elseif (!empty($cat_id)) { for ($i = 0; $i < count($forum_auth_fields); $i++) { - $value = intval($_POST[$forum_auth_fields[$i]]); + $value = (int)$_POST[$forum_auth_fields[$i]]; if ($forum_auth_fields[$i] == 'auth_vote') { if ($_POST['auth_vote'] == AUTH_ALL) { diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 4b0b76171..4cef6b131 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']; @@ -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']; @@ -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']); @@ -656,7 +656,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(); @@ -914,7 +914,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"; } @@ -1086,7 +1086,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 8a51b03b6..74cd18a95 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 = $_POST['username'] ?? ''; diff --git a/admin/admin_log.php b/admin/admin_log.php index ccfbc006f..77e749f73 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -94,7 +94,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); @@ -164,7 +164,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_ranks.php b/admin/admin_ranks.php index ab0dcf1cb..d5510668f 100644 --- a/admin/admin_ranks.php +++ b/admin/admin_ranks.php @@ -52,7 +52,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 +96,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 +159,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 11c7d4eda..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) { @@ -118,7 +118,7 @@ if (isset($_REQUEST['time_limit'])) { // 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) { @@ -196,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 3ccb43b5e..a8e463168 100644 --- a/admin/admin_smilies.php +++ b/admin/admin_smilies.php @@ -190,7 +190,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 +204,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); @@ -244,7 +244,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 == '') { diff --git a/admin/admin_user_ban.php b/admin/admin_user_ban.php index f1fb850a6..85bfee439 100644 --- a/admin/admin_user_ban.php +++ b/admin/admin_user_ban.php @@ -203,7 +203,7 @@ if (isset($_POST['submit'])) { for ($i = 0; $i < count($user_list); $i++) { if ($user_list[$i] != -1) { - $where_sql .= (($where_sql != '') ? ', ' : '') . intval($user_list[$i]); + $where_sql .= (($where_sql != '') ? ', ' : '') . (int)$user_list[$i]; } } } diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php index 6b8febb98..b8ef65f8b 100644 --- a/admin/admin_user_search.php +++ b/admin/admin_user_search.php @@ -443,19 +443,19 @@ if (!isset($_REQUEST['dosearch'])) { 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); @@ -550,7 +550,7 @@ if (!isset($_REQUEST['dosearch'])) { 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); @@ -580,8 +580,8 @@ if (!isset($_REQUEST['dosearch'])) { if (strstr($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); @@ -680,7 +680,7 @@ if (!isset($_REQUEST['dosearch'])) { case 'search_lastvisited': $lastvisited_type = strtolower(trim($lastvisited_type)); - $lastvisited_days = intval($lastvisited_days); + $lastvisited_days = (int)$lastvisited_days; $base_url .= '&search_lastvisited=true&lastvisited_type=' . rawurlencode(stripslashes($lastvisited_type)) . '&lastvisited_days=' . rawurlencode($lastvisited_days); @@ -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; @@ -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; diff --git a/admin/admin_words.php b/admin/admin_words.php index 23891efe0..9fea045f7 100644 --- a/admin/admin_words.php +++ b/admin/admin_words.php @@ -44,7 +44,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 +72,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 +100,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 a4394593e..1e1420849 100644 --- a/admin/index.php +++ b/admin/index.php @@ -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; } diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index cd7a6eb4a..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'); diff --git a/bt/announce.php b/bt/announce.php index 338fac1c2..d357f284d 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -438,7 +438,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/common.php b/common.php index 9282203f3..615929064 100644 --- a/common.php +++ b/common.php @@ -484,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']) : random_int(1000, 65000))); + define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000))); function dummy_exit($interval = 1800) { diff --git a/dl.php b/dl.php index d612915df..f2721aaf2 100644 --- a/dl.php +++ b/dl.php @@ -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/group.php b/group.php index 1858a4976..0696b53ad 100644 --- a/group.php +++ b/group.php @@ -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; 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/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 120308c55..1faff60aa 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 5c99a2534..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"); } 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 bb8f26f00..1b84c2a21 100644 --- a/library/attach_mod/displaying.php +++ b/library/attach_mod/displaying.php @@ -49,8 +49,8 @@ function init_complete_extensions_data() 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']); } } @@ -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; } @@ -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/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php index fd142fc46..7392d0561 100644 --- a/library/attach_mod/includes/functions_admin.php +++ b/library/attach_mod/includes/functions_admin.php @@ -122,8 +122,8 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0) $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])) + ($sort_order == 'DESC' && (int)(@$sort_array[$j][$key]) < (int)(@$sort_array[$j + 1][$key])) || + ($sort_order == 'ASC' && (int)(@$sort_array[$j][$key]) > (int)(@$sort_array[$j + 1][$key])) ) { $switch = true; } @@ -209,7 +209,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 != '') ? ', ' : '') . (int)$row['user_id']; } while ($row = DB()->sql_fetchrow($result)); DB()->sql_freeresult($result); @@ -260,7 +260,7 @@ 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 diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index d129fb874..6898bcf27 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -104,7 +104,7 @@ function auth_pack($auth_array) $auth_cache = ''; for ($i = 0; $i < count($auth_array); $i++) { - $val = base64_pack(intval($auth_array[$i])); + $val = base64_pack((int)$auth_array[$i]); if (strlen($val) == 1 && !$one_char) { $auth_cache .= $one_char_encoding; $one_char = true; @@ -145,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; } @@ -276,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; @@ -288,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 @@ -580,7 +580,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) } 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; } } @@ -595,7 +595,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) } 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) . ')'; @@ -610,7 +610,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) } 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 cee349b4e..20affee97 100644 --- a/library/attach_mod/includes/functions_delete.php +++ b/library/attach_mod/includes/functions_delete.php @@ -46,7 +46,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } 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); } @@ -87,7 +87,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } 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; @@ -132,7 +132,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, } 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; @@ -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); } diff --git a/library/attach_mod/includes/functions_filetypes.php b/library/attach_mod/includes/functions_filetypes.php index aa7e06bef..4270caf58 100644 --- a/library/attach_mod/includes/functions_filetypes.php +++ b/library/attach_mod/includes/functions_filetypes.php @@ -175,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; } @@ -183,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/includes/classes/utf8.php b/library/includes/classes/utf8.php index d514a4c93..bf52cdf6e 100644 --- a/library/includes/classes/utf8.php +++ b/library/includes/classes/utf8.php @@ -3152,8 +3152,8 @@ class utf8 return $s; } - $length = intval($length); - $glue = strval($glue); + $length = (int)$length; + $glue = (string)$glue; if ($length < 1) { $length = 76; } @@ -3632,7 +3632,7 @@ class utf8 return $s; } - $length = ($length === null) ? 1 : intval($length); + $length = ($length === null) ? 1 : (int)$length; if ($length < 1) { return false; } @@ -3766,7 +3766,7 @@ class utf8 #optimization block (speed improve) #{{{ - $ascii_int = intval(self::is_ascii($s)) + intval(self::is_ascii($needle)); + $ascii_int = (int)self::is_ascii($s) + (int)self::is_ascii($needle); if ($ascii_int === 1) { return false; } @@ -4224,13 +4224,13 @@ class utf8 if ($type == STR_PAD_LEFT) { $repeat_num = ceil($pad_len / $pad_str_len); - return self::substr(str_repeat($pad_str, $repeat_num), 0, intval(floor($pad_len))) . $s; + return self::substr(str_repeat($pad_str, $repeat_num), 0, (int)floor($pad_len)) . $s; } if ($type == STR_PAD_BOTH) { $pad_len /= 2; - $pad_amount_left = intval(floor($pad_len)); - $pad_amount_right = intval(ceil($pad_len)); + $pad_amount_left = (int)floor($pad_len); + $pad_amount_right = (int)ceil($pad_len); $repeat_times_left = ceil($pad_amount_left / $pad_str_len); $repeat_times_right = ceil($pad_amount_right / $pad_str_len); diff --git a/library/includes/cron/jobs/board_maintenance.php b/library/includes/cron/jobs/board_maintenance.php index 2a495f804..1221c3219 100644 --- a/library/includes/cron/jobs/board_maintenance.php +++ b/library/includes/cron/jobs/board_maintenance.php @@ -64,6 +64,6 @@ if ($poll_max_days = (int)$bb_cfg['poll_max_days']) { DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400)); // Чистка кеша постов -if ($posts_days = intval($bb_cfg['posts_cache_days_keep'])) { +if ($posts_days = (int)$bb_cfg['posts_cache_days_keep']) { DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)"); } diff --git a/library/includes/cron/jobs/clean_dlstat.php b/library/includes/cron/jobs/clean_dlstat.php index 859fc3a3c..8b7701b02 100644 --- a/library/includes/cron/jobs/clean_dlstat.php +++ b/library/includes/cron/jobs/clean_dlstat.php @@ -67,7 +67,7 @@ DB()->query(" "); // Tor-Stats cleanup -if ($torstat_days_keep = intval($bb_cfg['torstat_days_keep'])) { +if ($torstat_days_keep = (int)$bb_cfg['torstat_days_keep']) { DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)"); } diff --git a/library/includes/cron/jobs/prune_inactive_users.php b/library/includes/cron/jobs/prune_inactive_users.php index f3c5d6379..eb6b92daf 100644 --- a/library/includes/cron/jobs/prune_inactive_users.php +++ b/library/includes/cron/jobs/prune_inactive_users.php @@ -36,7 +36,7 @@ while (true) { $prune_users = $not_activated_users = $not_active_users = array(); - if ($not_activated_days = intval($bb_cfg['user_not_activated_days_keep'])) { + if ($not_activated_days = (int)$bb_cfg['user_not_activated_days_keep']) { $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_level = 0 AND user_lastvisit = 0 @@ -50,7 +50,7 @@ while (true) { } } - if ($not_active_days = intval($bb_cfg['user_not_active_days_keep'])) { + if ($not_active_days = (int)$bb_cfg['user_not_active_days_keep']) { $sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_level = 0 AND user_posts = 0 diff --git a/library/includes/cron/jobs/sessions_cleanup.php b/library/includes/cron/jobs/sessions_cleanup.php index e67aff133..2424120e0 100644 --- a/library/includes/cron/jobs/sessions_cleanup.php +++ b/library/includes/cron/jobs/sessions_cleanup.php @@ -27,10 +27,10 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } -$user_session_expire_time = TIMENOW - intval($bb_cfg['user_session_duration']); -$admin_session_expire_time = TIMENOW - intval($bb_cfg['admin_session_duration']); +$user_session_expire_time = TIMENOW - (int)$bb_cfg['user_session_duration']; +$admin_session_expire_time = TIMENOW - (int)$bb_cfg['admin_session_duration']; -$user_session_gc_time = $user_session_expire_time - intval($bb_cfg['user_session_gc_ttl']); +$user_session_gc_time = $user_session_expire_time - (int)$bb_cfg['user_session_gc_ttl']; $admin_session_gc_time = $admin_session_expire_time; // ############################ Tables LOCKED ################################ diff --git a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php index a261ea667..144106d73 100644 --- a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php +++ b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php @@ -81,8 +81,8 @@ DB()->query(" // Clean peers table if ($tr_cfg['autoclean']) { - $announce_interval = max(intval($bb_cfg['announce_interval']), 60); - $expire_factor = max(floatval($tr_cfg['expire_factor']), 1); + $announce_interval = max((int)$bb_cfg['announce_interval'], 60); + $expire_factor = max((float)$tr_cfg['expire_factor'], 1); $peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor); DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time"); diff --git a/library/includes/functions.php b/library/includes/functions.php index b946f8d45..f2749fe04 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -838,7 +838,7 @@ function declension($int, $expressions, $format = '%1$s %2$s') if (count($expressions) < 3) { $expressions[2] = $expressions[1]; } - $count = intval($int) % 100; + $count = (int)$int % 100; if ($count >= 5 && $count <= 20) { $result = $expressions['2']; @@ -969,7 +969,7 @@ function select_get_val($key, &$val, $options_ary, $default, $num = true) if (isset($_REQUEST[$key]) && is_string($_REQUEST[$key])) { if (isset($options_ary[$_REQUEST[$key]])) { - $val = ($num) ? intval($_REQUEST[$key]) : $_REQUEST[$key]; + $val = ($num) ? (int)$_REQUEST[$key] : $_REQUEST[$key]; } } elseif (isset($previous_settings[$key])) { $val = $previous_settings[$key]; @@ -1100,7 +1100,7 @@ function str_short($text, $max_length, $space = ' ') if ($max_length && mb_strlen($text, 'UTF-8') > $max_length) { $text = mb_substr($text, 0, $max_length, 'UTF-8'); - if ($last_space_pos = $max_length - intval(strpos(strrev($text), $space))) { + if ($last_space_pos = $max_length - (int)strpos(strrev($text), $space)) { if ($last_space_pos > round($max_length * 3 / 4)) { $last_space_pos--; $text = mb_substr($text, 0, $last_space_pos, 'UTF-8'); @@ -1300,7 +1300,7 @@ function get_userdata($u, $force_name = false, $allow_guest = false) return false; } - if (intval($u) == GUEST_UID && $allow_guest) { + if ((int)$u == GUEST_UID && $allow_guest) { if ($u_data = CACHE('bb_cache')->get('guest_userdata')) { return $u_data; } diff --git a/library/includes/functions_admin_torrent.php b/library/includes/functions_admin_torrent.php index 47bc20fb1..219bdc371 100644 --- a/library/includes/functions_admin_torrent.php +++ b/library/includes/functions_admin_torrent.php @@ -43,7 +43,7 @@ function update_table_bool($table_name, $key, $field_name, $field_def_val) $in_sql = array(); foreach ($_POST[$field_name] as $i => $val) { - $in_sql[] = intval($val); + $in_sql[] = (int)$val; } // Update status @@ -109,7 +109,7 @@ function update_config_table($table_name, $default_cfg, $cfg, $type) } elseif ($type == 'bool') { $config_value = ($_POST[$config_name]) ? 1 : 0; } elseif ($type == 'num') { - $config_value = abs(intval($_POST[$config_name])); + $config_value = abs((int)$_POST[$config_name]); } else { return; } diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 4b7a83395..040b6f807 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -31,7 +31,7 @@ function get_torrent_info($attach_id) { global $lang; - $attach_id = intval($attach_id); + $attach_id = (int)$attach_id; $sql = " SELECT @@ -162,7 +162,7 @@ function delete_torrent($attach_id, $mode = '') { global $lang, $reg_mode, $topic_id; - $attach_id = intval($attach_id); + $attach_id = (int)$attach_id; $reg_mode = $mode; if (!$torrent = get_torrent_info($attach_id)) { @@ -223,7 +223,7 @@ function change_tor_type($attach_id, $tor_status_gold) } $topic_id = $torrent['topic_id']; - $tor_status_gold = intval($tor_status_gold); + $tor_status_gold = (int)$tor_status_gold; $info_hash = null; DB()->query("UPDATE " . BB_BT_TORRENTS . " SET tor_type = $tor_status_gold WHERE topic_id = $topic_id LIMIT 1"); @@ -241,7 +241,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED { global $bb_cfg, $lang, $reg_mode, $tr_cfg; - $attach_id = intval($attach_id); + $attach_id = (int)$attach_id; $reg_mode = $mode; if (!$torrent = get_torrent_info($attach_id)) { @@ -462,7 +462,7 @@ function send_torrent_with_passkey($filename) bb_die('This is not a bencoded file'); } - $announce = $bb_cfg['ocelot']['enabled'] ? strval($bb_cfg['ocelot']['url'] . $passkey_val . "/announce") : strval($ann_url . "?$passkey_key=$passkey_val"); + $announce = $bb_cfg['ocelot']['enabled'] ? (string)($bb_cfg['ocelot']['url'] . $passkey_val . "/announce") : (string)($ann_url . "?$passkey_key=$passkey_val"); // Replace original announce url with tracker default if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) { @@ -494,13 +494,13 @@ function send_torrent_with_passkey($filename) $publisher_name = $bb_cfg['server_name']; $publisher_url = make_url(TOPIC_URL . $topic_id); - $tor['publisher'] = strval($publisher_name); + $tor['publisher'] = (string)$publisher_name; unset($tor['publisher.utf-8']); - $tor['publisher-url'] = strval($publisher_url); + $tor['publisher-url'] = (string)$publisher_url; unset($tor['publisher-url.utf-8']); - $tor['comment'] = strval($publisher_url); + $tor['comment'] = (string)$publisher_url; unset($tor['comment.utf-8']); // Send torrent diff --git a/library/includes/page_header.php b/library/includes/page_header.php index 4b261829a..c1e23e9ab 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -152,7 +152,7 @@ $template->assign_vars(array( 'FULL_URL' => FULL_URL, 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)), - 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', floatval($bb_cfg['board_timezone']))])), + 'S_TIMEZONE' => preg_replace('/\(.*?\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', (float)$bb_cfg['board_timezone'])])), 'BOARD_TIMEZONE' => $bb_cfg['board_timezone'], 'PM_INFO' => $pm_info, diff --git a/library/includes/posting_tpl.php b/library/includes/posting_tpl.php index 0cf8e54b8..63e41ed5b 100644 --- a/library/includes/posting_tpl.php +++ b/library/includes/posting_tpl.php @@ -90,7 +90,7 @@ if ($edit_tpl_mode) { 'TPL_COMMENT' => $tpl_data['tpl_comment'], 'TPL_RULES_POST_ID' => $tpl_data['tpl_rules_post_id'], 'TPL_LAST_EDIT_TIME' => bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i'), - 'TPL_LAST_EDIT_USER' => get_username(intval($tpl_data['tpl_last_edit_by'])), + 'TPL_LAST_EDIT_USER' => get_username((int)$tpl_data['tpl_last_edit_by']), 'TPL_LAST_EDIT_TIMESTAMP' => $tpl_data['tpl_last_edit_tm'], )); } diff --git a/library/includes/sessions.php b/library/includes/sessions.php index 0491e881c..1dc22a07f 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -183,7 +183,7 @@ class user_common $login = false; $user_id = ($bb_cfg['allow_autologin'] && $this->sessiondata['uk'] && $this->sessiondata['uid']) ? $this->sessiondata['uid'] : GUEST_UID; - if ($userdata = get_userdata(intval($user_id), false, true)) { + if ($userdata = get_userdata((int)$user_id, false, true)) { if ($userdata['user_id'] != GUEST_UID && $userdata['user_active']) { if (verify_id($this->sessiondata['uk'], LOGIN_KEY_LENGTH) && $this->verify_autologin_id($userdata, true, false)) { $login = ($userdata['autologin_id'] && $this->sessiondata['uk'] === $userdata['autologin_id']); @@ -433,7 +433,7 @@ class user_common } // user_id if (!empty($sd_resv['uid'])) { - $this->sessiondata['uid'] = intval($sd_resv['uid']); + $this->sessiondata['uid'] = (int)$sd_resv['uid']; } // sid if (!empty($sd_resv['sid']) && verify_id($sd_resv['sid'], SID_LENGTH)) { diff --git a/library/includes/ucp/activate.php b/library/includes/ucp/activate.php index 4320822a2..588571dd7 100644 --- a/library/includes/ucp/activate.php +++ b/library/includes/ucp/activate.php @@ -33,7 +33,7 @@ if (empty($_GET['u']) || empty($_GET['act_key'])) { $sql = "SELECT user_active, user_id, username, user_email, user_newpasswd, user_lang, user_actkey FROM " . BB_USERS . " - WHERE user_id = " . intval($_GET[POST_USERS_URL]); + WHERE user_id = " . (int)$_GET[POST_USERS_URL]; if (!($result = DB()->sql_query($sql))) { bb_die('Could not obtain user information'); } diff --git a/library/includes/ucp/email.php b/library/includes/ucp/email.php index 0059089e9..1b89d4fa0 100644 --- a/library/includes/ucp/email.php +++ b/library/includes/ucp/email.php @@ -35,7 +35,7 @@ if (!$bb_cfg['board_email_form']) { set_die_append_msg(); if (!empty($_GET[POST_USERS_URL]) || !empty($_POST[POST_USERS_URL])) { - $user_id = (!empty($_GET[POST_USERS_URL])) ? intval($_GET[POST_USERS_URL]) : intval($_POST[POST_USERS_URL]); + $user_id = (!empty($_GET[POST_USERS_URL])) ? (int)$_GET[POST_USERS_URL] : (int)$_POST[POST_USERS_URL]; } else { bb_die($lang['NO_USER_SPECIFIED']); } diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php index 73e5f6411..97180a529 100644 --- a/library/includes/ucp/topic_watch.php +++ b/library/includes/ucp/topic_watch.php @@ -32,7 +32,7 @@ $page_cfg['include_bbcode_js'] = true; $tracking_topics = get_tracks('topic'); $user_id = $userdata['user_id']; -$start = isset($_GET['start']) ? abs(intval($_GET['start'])) : 0; +$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0; $per_page = $bb_cfg['topics_per_page']; if (isset($_POST['topic_id_list'])) { diff --git a/memberlist.php b/memberlist.php index c84d7e6cd..4a2793188 100644 --- a/memberlist.php +++ b/memberlist.php @@ -32,7 +32,7 @@ $page_cfg['use_tablesorter'] = true; $user->session_start(array('req_login' => true)); -$start = abs(intval(request_var('start', 0))); +$start = abs((int)request_var('start', 0)); $mode = (string)request_var('mode', 'joined'); $sort_order = (request_var('order', 'ASC') == 'ASC') ? 'ASC' : 'DESC'; $username = request_var('username', ''); diff --git a/modcp.php b/modcp.php index cfc8a08f9..ce9d44c27 100644 --- a/modcp.php +++ b/modcp.php @@ -93,7 +93,7 @@ $forum_id = $_REQUEST['f'] ?? 0; $topic_id = $_REQUEST['t'] ?? 0; $post_id = $_REQUEST['p'] ?? 0; -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $confirmed = isset($_POST['confirm']); $mode = $topic_title = ''; @@ -398,7 +398,7 @@ switch ($mode) { if (($split || $delete_posts) && ($posts && $topic_id && $forum_id && $topic_first_post_id) && $confirmed) { foreach ($posts as $post_id) { - if ($pid = intval($post_id)) { + if ($pid = (int)$post_id) { $req_post_id_sql[] = $pid; } } @@ -441,8 +441,8 @@ switch ($mode) { $user_id_sql = ''; $post_id_sql = ''; do { - $user_id_sql .= (($user_id_sql != '') ? ', ' : '') . intval($row['poster_id']); - $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']); + $user_id_sql .= (($user_id_sql != '') ? ', ' : '') . (int)$row['poster_id']; + $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . (int)$row['post_id']; } while ($row = DB()->sql_fetchrow($result)); $post_subject = clean_title($_POST['subject']); @@ -450,7 +450,7 @@ switch ($mode) { bb_die($lang['EMPTY_SUBJECT']); } - $new_forum_id = intval($_POST['new_forum_id']); + $new_forum_id = (int)$_POST['new_forum_id']; $topic_time = TIMENOW; $sql = 'SELECT forum_id FROM ' . BB_FORUMS . ' WHERE forum_id = ' . $new_forum_id; diff --git a/poll.php b/poll.php index 614cb21d0..79652d1de 100644 --- a/poll.php +++ b/poll.php @@ -34,7 +34,7 @@ $forum_id = (int)@$_POST['forum_id']; $vote_id = (int)@$_POST['vote_id']; $return_topic_url = TOPIC_URL . $topic_id; -$return_topic_url .= !empty($_POST['start']) ? "&start=" . intval($_POST['start']) : ''; +$return_topic_url .= !empty($_POST['start']) ? "&start=" . (int)$_POST['start'] : ''; set_die_append_msg($forum_id, $topic_id); diff --git a/posting.php b/posting.php index e0b651937..1d009d889 100644 --- a/posting.php +++ b/posting.php @@ -281,7 +281,7 @@ execute_posting_attachment_handling(); $topic_has_new_posts = false; if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' || $mode == 'reply') && isset($_COOKIE[COOKIE_TOPIC])) { - if ($topic_last_read = max(intval(@$tracking_topics[$topic_id]), intval(@$tracking_forums[$forum_id]))) { + if ($topic_last_read = max((int)(@$tracking_topics[$topic_id]), (int)(@$tracking_forums[$forum_id]))) { $sql = "SELECT p.*, pt.post_text, u.username, u.user_rank FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u WHERE p.topic_id = " . (int)$topic_id . " diff --git a/privmsg.php b/privmsg.php index e0115af93..12dac9eb8 100644 --- a/privmsg.php +++ b/privmsg.php @@ -100,10 +100,10 @@ if ($cancel) { // // Var definitions // -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; if (isset($_POST[POST_POST_URL]) || isset($_GET[POST_POST_URL])) { - $privmsg_id = (isset($_POST[POST_POST_URL])) ? intval($_POST[POST_POST_URL]) : intval($_GET[POST_POST_URL]); + $privmsg_id = (isset($_POST[POST_POST_URL])) ? (int)$_POST[POST_POST_URL] : (int)$_GET[POST_POST_URL]; } else { $privmsg_id = ''; } @@ -126,7 +126,7 @@ $template->assign_var('POSTING_SUBJECT'); if ($mode == 'read') { if (!empty($_GET[POST_POST_URL])) { - $privmsgs_id = intval($_GET[POST_POST_URL]); + $privmsgs_id = (int)$_GET[POST_POST_URL]; } else { bb_die($lang['NO_PM_ID']); } @@ -463,7 +463,7 @@ if ($mode == 'read') { if (!$delete_all) { for ($i = 0; $i < count($mark_list); $i++) { - $delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . intval($mark_list[$i]); + $delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . (int)$mark_list[$i]; } $delete_sql_id = "AND privmsgs_id IN ($delete_sql_id)"; } @@ -505,7 +505,7 @@ if ($mode == 'read') { if (count($mark_list)) { $delete_sql_id = ''; for ($i = 0; $i < count($mark_list); $i++) { - $delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . intval($mark_list[$i]); + $delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . (int)$mark_list[$i]; } if ($folder == 'inbox' || $folder == 'outbox') { @@ -664,7 +664,7 @@ if ($mode == 'read') { $saved_sql_id = ''; for ($i = 0; $i < count($mark_list); $i++) { - $saved_sql_id .= (($saved_sql_id != '') ? ', ' : '') . intval($mark_list[$i]); + $saved_sql_id .= (($saved_sql_id != '') ? ', ' : '') . (int)$mark_list[$i]; } // Process request @@ -992,7 +992,7 @@ if ($mode == 'read') { } if (!empty($_GET[POST_USERS_URL])) { - $user_id = intval($_GET[POST_USERS_URL]); + $user_id = (int)$_GET[POST_USERS_URL]; $sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id AND user_id <> " . GUEST_UID; if (!($result = DB()->sql_query($sql))) { @@ -1277,7 +1277,7 @@ if ($mode == 'read') { // Show messages over previous x days/months // if ($submit_msgdays && (!empty($_POST['msgdays']) || !empty($_GET['msgdays']))) { - $msg_days = (!empty($_POST['msgdays'])) ? intval($_POST['msgdays']) : intval($_GET['msgdays']); + $msg_days = (!empty($_POST['msgdays'])) ? (int)$_POST['msgdays'] : (int)$_GET['msgdays']; $min_msg_time = TIMENOW - ($msg_days * 86400); $limit_msg_time_total = " AND privmsgs_date > $min_msg_time"; diff --git a/search.php b/search.php index 57f17cdb3..fa1c9ab66 100644 --- a/search.php +++ b/search.php @@ -103,7 +103,7 @@ $max_forum_name_len = 60; // inside forum select box $text_match_max_len = 60; $poster_name_max_len = 25; -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $url = basename(__FILE__); $anon_id = GUEST_UID; diff --git a/tracker.php b/tracker.php index 8d0a39edb..bb13ef19c 100644 --- a/tracker.php +++ b/tracker.php @@ -59,7 +59,7 @@ $date_format = 'j-M-y'; $row_class_1 = 'row1'; $row_class_2 = 'row2'; -$start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; +$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $set_default = isset($_GET['def']); $user_id = $userdata['user_id']; @@ -402,7 +402,7 @@ if (!$set_default) { $req_poster_id = ''; if (isset($_GET[$poster_id_key]) && !$search_id) { - $req_poster_id = intval($_GET[$poster_id_key]); + $req_poster_id = (int)$_GET[$poster_id_key]; } elseif (isset($_POST[$poster_name_key]) && !$search_id) { if ($req_poster_name = clean_username($_POST[$poster_name_key])) { $poster_name_sql = str_replace("\\'", "''", $req_poster_name); @@ -416,7 +416,7 @@ if (!$set_default) { } } } elseif ($search_id && $previous_settings[$poster_id_key]) { - $poster_id_val = intval($previous_settings[$poster_id_key]); + $poster_id_val = (int)$previous_settings[$poster_id_key]; $poster_name_val = ($previous_settings[$poster_name_key]) ?: ''; } @@ -470,10 +470,10 @@ $poster_id = (bool)$poster_id_val; $title_match = (bool)$title_match_sql; $tor_type = (bool)$tor_type_val; -$hide_cat = intval(!$show_cat_val); -$hide_forum = intval(!$show_forum_val); -$hide_author = intval(!$show_author_val); -$hide_speed = intval(!$show_speed_val); +$hide_cat = (int)(!$show_cat_val); +$hide_forum = (int)(!$show_forum_val); +$hide_author = (int)(!$show_author_val); +$hide_speed = (int)(!$show_speed_val); $only_new = ($new_val && !IS_GUEST); $only_active = ($active_val || $seed_exist); diff --git a/viewforum.php b/viewforum.php index c118ece44..ec7cda9aa 100644 --- a/viewforum.php +++ b/viewforum.php @@ -42,7 +42,7 @@ $page_cfg['load_tpl_vars'] = array( // Init request vars $forum_id = (int)request_var('f', ''); -$start = abs(intval(request_var('start', ''))); +$start = abs((int)request_var('start', '')); $mark_read = (request_var('mark', '') === 'topics'); $anon = GUEST_UID; @@ -233,7 +233,7 @@ $topics_per_page = $bb_cfg['topics_per_page']; $select_tpp = ''; if ($is_auth['auth_mod']) { - if ($req_tpp = abs(intval(@$_REQUEST['tpp'])) and in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) { + if ($req_tpp = abs((int)(@$_REQUEST['tpp'])) and in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) { $topics_per_page = $req_tpp; } @@ -259,7 +259,7 @@ $sel_previous_days = array( ); if (!empty($_REQUEST['topicdays'])) { - if ($req_topic_days = abs(intval($_REQUEST['topicdays'])) and isset($sel_previous_days[$req_topic_days])) { + if ($req_topic_days = abs((int)$_REQUEST['topicdays']) and isset($sel_previous_days[$req_topic_days])) { $sql = " SELECT COUNT(*) AS forum_topics FROM " . BB_TOPICS . " diff --git a/viewtopic.php b/viewtopic.php index fbb3884b6..9bcd8c1fd 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -40,7 +40,7 @@ $page_cfg['load_tpl_vars'] = array( ); $newest = $next_topic_id = 0; -$start = isset($_GET['start']) ? abs(intval($_GET['start'])) : 0; +$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0; $topic_id = isset($_GET[POST_TOPIC_URL]) ? (int)$_GET[POST_TOPIC_URL] : 0; $post_id = (!$topic_id && isset($_GET[POST_POST_URL])) ? (int)$_GET[POST_POST_URL] : 0; @@ -54,7 +54,7 @@ $posts_per_page = $bb_cfg['posts_per_page']; $select_ppp = ''; if ($userdata['session_admin']) { - if ($req_ppp = abs(intval(@$_REQUEST['ppp'])) and in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) { + if ($req_ppp = abs((int)(@$_REQUEST['ppp'])) and in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) { $posts_per_page = $req_ppp; }