From b08f6e898b18c649da476a4b5cca382977d9b6ed Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Sun, 24 Jun 2018 15:23:40 +0300 Subject: [PATCH] Type casting can be used Signed-off-by: Yuriy Pikhtarev --- admin/admin_user_search.php | 2 +- library/attach_mod/displaying_torrent.php | 4 ++-- library/includes/bbcode.php | 6 +++--- search.php | 6 +++--- src/Legacy/LogAction.php | 2 +- src/Legacy/SqlDb.php | 4 ++-- src/Legacy/Template.php | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php index 68e799717..d9530856f 100644 --- a/admin/admin_user_search.php +++ b/admin/admin_user_search.php @@ -313,7 +313,7 @@ if (!isset($_REQUEST['dosearch'])) { $where_sql = ''; $where_sql .= ($ip_in_sql != '') ? "poster_ip IN ($ip_in_sql)" : ''; - $where_sql .= ($ip_like_sql != '') ? ($where_sql != '') ? " OR $ip_like_sql" : "$ip_like_sql" : ''; + $where_sql .= ($ip_like_sql != '') ? ($where_sql != '') ? " OR $ip_like_sql" : (string)$ip_like_sql : ''; if (!$where_sql) { bb_die('invalid request'); diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index d14b1ee84..950dced75 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -384,7 +384,7 @@ if ($tor_reged && $tor_info) { define('SEEDER_EXIST', true); $seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders"; - $template->assign_block_vars("$x_full", array( + $template->assign_block_vars((string)$x_full, array( 'SEED_ORD_ACT' => $seed_order_action, 'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s' )); @@ -406,7 +406,7 @@ if ($tor_reged && $tor_info) { define('LEECHER_EXIST', true); $leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#leechers"; - $template->assign_block_vars("$x_full", array( + $template->assign_block_vars((string)$x_full, array( 'LEECH_ORD_ACT' => $leech_order_action, 'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s', 'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s' diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index ab392026b..fc88b7a10 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -200,7 +200,7 @@ function strip_quotes($text) do { $pos = strpos($lowertext, '[quote', $curpos); if ($pos !== false) { - $start_pos["$pos"] = 'start'; + $start_pos[(string)$pos] = 'start'; $curpos = $pos + 6; } } while ($pos !== false); @@ -215,7 +215,7 @@ function strip_quotes($text) do { $pos = strpos($lowertext, '[/quote', $curpos); if ($pos !== false) { - $end_pos["$pos"] = 'end'; + $end_pos[(string)$pos] = 'end'; $curpos = $pos + 8; } } while ($pos !== false); @@ -259,7 +259,7 @@ function strip_quotes($text) // recursion. if ($stack) { foreach ($stack as $pos) { - unset($pos_list["$pos"]); + unset($pos_list[(string)$pos]); } } } while ($stack); diff --git a/search.php b/search.php index a80fd6a8b..4123c23f0 100644 --- a/search.php +++ b/search.php @@ -517,7 +517,7 @@ if ($post_mode) { $SQL['GROUP BY'][] = "item_id"; $SQL['ORDER BY'][] = ($new_posts && $join_p) ? "p.topic_id ASC, p.post_time ASC" : "$order $sort"; - $SQL['LIMIT'][] = "$search_limit"; + $SQL['LIMIT'][] = (string)$search_limit; $items_display = fetch_search_ids($SQL); } elseif (!$items_display = array_slice($items_found, $start, $per_page)) { @@ -726,7 +726,7 @@ else { } $SQL['GROUP BY'][] = "item_id"; - $SQL['LIMIT'][] = "$search_limit"; + $SQL['LIMIT'][] = (string)$search_limit; if ($egosearch) { $SQL['ORDER BY'][] = 'max_post_time DESC'; @@ -767,7 +767,7 @@ else { $SQL['WHERE'][] = "t.forum_id NOT IN($excluded_forums_csv)"; } - $SQL['LIMIT'][] = "$per_page"; + $SQL['LIMIT'][] = (string)$per_page; // Fetch topics data $topic_rows = array(); diff --git a/src/Legacy/LogAction.php b/src/Legacy/LogAction.php index 26b083b0f..066ed063b 100644 --- a/src/Legacy/LogAction.php +++ b/src/Legacy/LogAction.php @@ -70,7 +70,7 @@ class LogAction } $sql_ary = [ - 'log_type_id' => (int)$this->log_type["$type_name"], + 'log_type_id' => (int)$this->log_type[(string)$type_name], 'log_user_id' => (int)$user_id, 'log_user_ip' => (string)$session_ip, 'log_forum_id' => (int)$forum_id, diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index cca3af01d..3550ef186 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -392,7 +392,7 @@ class SqlDb case is_string($v): return "'" . $this->escape_string($v) . "'"; case is_int($v): - return "$v"; + return (string)$v; case is_bool($v): return ($v) ? '1' : '0'; case is_float($v): @@ -733,7 +733,7 @@ class SqlDb } if ($this->link and $ext = mysqli_info($this->link)) { - $info[] = "$ext"; + $info[] = (string)$ext; } elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) { $info[] = "$aff rows"; } diff --git a/src/Legacy/Template.php b/src/Legacy/Template.php index 51ec50111..cca10229c 100644 --- a/src/Legacy/Template.php +++ b/src/Legacy/Template.php @@ -864,9 +864,9 @@ class Template } elseif (!empty($m[4])) { $token = ($tokens_cnt == 1) ? "!empty(\$V['{$m[4]}'])" : "\$V['{$m[4]}']"; } elseif (!empty($m[5])) { - $token = ($tokens_cnt == 1) ? "!empty({$m[5]})" : "{$m[5]}"; + $token = ($tokens_cnt == 1) ? "!empty({$m[5]})" : (string)($m[5]); } elseif (!empty($m[7])) { - $token = ($tokens_cnt == 1) ? "defined('{$m[7]}') && {$m[7]}" : "{$m[7]}"; + $token = ($tokens_cnt == 1) ? "defined('{$m[7]}') && {$m[7]}" : (string)($m[7]); } } break;