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

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