Type casting can be used.

(cherry picked from commit b5065ae)
This commit is contained in:
Yuriy Pikhtarev 2017-05-05 01:00:38 +03:00 committed by Vasily Komrakov
commit 21c8e7d48a
No known key found for this signature in database
GPG key ID: 558236680C20A69A
58 changed files with 226 additions and 228 deletions

View file

@ -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(

View file

@ -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,7 +256,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

View file

@ -102,7 +102,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;
@ -141,7 +141,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;
}
@ -270,7 +270,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;
@ -282,7 +282,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
@ -574,7 +574,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;
}
}
@ -589,7 +589,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) . ')';
@ -604,7 +604,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);

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}