Fix deprecation warnings in PHP 8.2

This commit is contained in:
Kijin Sung 2023-01-16 22:42:04 +09:00
parent f7f20a0825
commit e0a041bb3d
5 changed files with 10 additions and 7 deletions

View file

@ -185,6 +185,7 @@ function clean_path($path)
*/
function escape($str, $double_escape = true, $except_lang_code = false)
{
$str = (string)$str;
if ($except_lang_code && preg_match('/^\$user_lang->userLang[0-9]+$/', $str))
{
return $str;
@ -204,7 +205,7 @@ function escape($str, $double_escape = true, $except_lang_code = false)
*/
function escape_css($str)
{
return preg_replace('/[^a-zA-Z0-9_.#\/-]/', '', $str);
return preg_replace('/[^a-zA-Z0-9_.#\/-]/', '', (string)$str);
}
/**
@ -229,7 +230,7 @@ function escape_js($str)
*/
function escape_sqstr($str)
{
return str_replace(array('\\0', '\\"'), array('', '"'), addslashes($str));
return str_replace(array('\\0', '\\"'), array('', '"'), addslashes((string)$str));
}
/**
@ -241,7 +242,7 @@ function escape_sqstr($str)
*/
function escape_dqstr($str)
{
return str_replace(array('\\0', "\\'", '$'), array('', "'", '\\$'), addslashes($str));
return str_replace(array('\\0', "\\'", '$'), array('', "'", '\\$'), addslashes((string)$str));
}
/**
@ -258,6 +259,7 @@ function escape_dqstr($str)
function explode_with_escape($delimiter, $str, $limit = 0, $escape_char = '\\')
{
if ($limit < 1) $limit = 0;
$str = (string)$str;
$result = array();
$split = preg_split('/(?<!' . preg_quote($escape_char, '/') . ')' . preg_quote($delimiter, '/') . '/', $str, $limit);
foreach ($split as $piece)