Apply automated PHP8 safety transforms
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/89922108-1604-44ae-949d-358d32b9d70a Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
aca850b6cd
commit
e44519c030
465 changed files with 1716 additions and 1716 deletions
|
|
@ -43,7 +43,7 @@ function smarty_block_textformat($params, $content, &$smarty)
|
|||
$wrap_cut = false;
|
||||
$assign = null;
|
||||
|
||||
foreach ($params as $_key => $_val) {
|
||||
foreach ((array)$params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'style':
|
||||
case 'indent_char':
|
||||
|
|
@ -75,7 +75,7 @@ function smarty_block_textformat($params, $content, &$smarty)
|
|||
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
|
||||
$_output = '';
|
||||
|
||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
for($_x = 0, $_y = count((array)$_paragraphs); $_x < $_y; $_x++) {
|
||||
if ($_paragraphs[$_x] == '') {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ function smarty_function_cycle($params, &$smarty)
|
|||
}
|
||||
|
||||
if($advance) {
|
||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||
if ( $cycle_vars[$name]['index'] >= count((array)$cycle_array) -1 ) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index']++;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
foreach ((array)$params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
|
|
@ -168,7 +168,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
foreach ((array)$extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header."\r\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ((array)$params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
|
|
@ -103,12 +103,12 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ((array)$options as $_key=>$_val)
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
|
||||
|
||||
} else {
|
||||
foreach ($values as $_i=>$_key) {
|
||||
foreach ((array)$values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function smarty_function_html_image($params, &$smarty)
|
|||
$path_prefix = '';
|
||||
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
|
||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ((array)$params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function smarty_function_html_options($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ((array)$params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'name':
|
||||
$$_key = (string)$_val;
|
||||
|
|
@ -75,12 +75,12 @@ function smarty_function_html_options($params, &$smarty)
|
|||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ((array)$options as $_key=>$_val)
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
|
||||
} else {
|
||||
|
||||
foreach ($values as $_i=>$_key) {
|
||||
foreach ((array)$values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
|
|||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
foreach ((array)$values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
|
||||
}
|
||||
$optgroup_html .= "</optgroup>\n";
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
$output = null;
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
foreach ((array)$params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
|
|
@ -107,12 +107,12 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ((array)$options as $_key=>$_val)
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
|
||||
} else {
|
||||
|
||||
foreach ($values as $_i=>$_key) {
|
||||
foreach ((array)$values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
$year_empty = null;
|
||||
$extra_attrs = '';
|
||||
|
||||
foreach ($params as $_key=>$_value) {
|
||||
foreach ((array)$params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'prefix':
|
||||
case 'time':
|
||||
|
|
@ -135,7 +135,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
|
||||
if (preg_match('!^-\d+$!', $time)) {
|
||||
// negative timestamp, use date()
|
||||
$time = date('Y-m-d', $time);
|
||||
$time = date('Y-m-d', is_numeric($time) ? (int)$time : strtotime($time));
|
||||
}
|
||||
// If $time is not in format yyyy-mm-dd
|
||||
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
$second_extra = null;
|
||||
$meridian_extra = null;
|
||||
|
||||
foreach ($params as $_key=>$_value) {
|
||||
foreach ((array)$params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'prefix':
|
||||
case 'time':
|
||||
|
|
@ -84,7 +84,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
if ($display_hours) {
|
||||
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
|
||||
$hour_fmt = $use_24_hours ? '%H' : '%I';
|
||||
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
|
||||
for ($i = 0, $for_max = count((array)$hours); $i < $for_max; $i++)
|
||||
$hours[$i] = sprintf('%02d', $hours[$i]);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
|
|
@ -109,7 +109,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
|
||||
if ($display_minutes) {
|
||||
$all_minutes = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
|
||||
for ($i = 0, $for_max = count((array)$all_minutes); $i < $for_max; $i+= $minute_interval)
|
||||
$minutes[] = sprintf('%02d', $all_minutes[$i]);
|
||||
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
|
||||
$html_result .= '<select name=';
|
||||
|
|
@ -136,7 +136,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
|
||||
if ($display_seconds) {
|
||||
$all_seconds = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
|
||||
for ($i = 0, $for_max = count((array)$all_seconds); $i < $for_max; $i+= $second_interval)
|
||||
$seconds[] = sprintf('%02d', $all_seconds[$i]);
|
||||
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
|
||||
$html_result .= '<select name=';
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function smarty_function_html_table($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $_key=>$_value) {
|
||||
foreach ((array)$params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'loop':
|
||||
$$_key = (array)$_value;
|
||||
|
|
@ -74,10 +74,10 @@ function smarty_function_html_table($params, &$smarty)
|
|||
case 'cols':
|
||||
if (is_array($_value) && !empty($_value)) {
|
||||
$cols = $_value;
|
||||
$cols_count = count($_value);
|
||||
$cols_count = count((array)$_value);
|
||||
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
|
||||
$cols = explode(',', $_value);
|
||||
$cols_count = count($cols);
|
||||
$cols_count = count((array)$cols);
|
||||
} elseif (!empty($_value)) {
|
||||
$cols_count = (int)$_value;
|
||||
} else {
|
||||
|
|
@ -106,7 +106,7 @@ function smarty_function_html_table($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
$loop_count = count($loop);
|
||||
$loop_count = count((array)$loop);
|
||||
if (empty($params['rows'])) {
|
||||
/* no rows specified */
|
||||
$rows = ceil($loop_count/$cols_count);
|
||||
|
|
@ -165,7 +165,7 @@ function smarty_function_html_table_cycle($name, $var, $no) {
|
|||
if(!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[$no % count($var)];
|
||||
$ret = $var[$no % count((array)$var)];
|
||||
}
|
||||
|
||||
return ($ret) ? ' '.$ret : '';
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function smarty_function_mailto($params, &$smarty)
|
|||
$search = array('%40', '%2C');
|
||||
$replace = array('@', ',');
|
||||
$mail_parms = array();
|
||||
foreach ($params as $var=>$value) {
|
||||
foreach ((array)$params as $var=>$value) {
|
||||
switch ($var) {
|
||||
case 'cc':
|
||||
case 'bcc':
|
||||
|
|
@ -88,7 +88,7 @@ function smarty_function_mailto($params, &$smarty)
|
|||
}
|
||||
|
||||
$mail_parm_vals = '';
|
||||
for ($i=0; $i<count($mail_parms); $i++) {
|
||||
for ($i=0; $i<count((array)$mail_parms); $i++) {
|
||||
$mail_parm_vals .= (0==$i) ? '?' : '&';
|
||||
$mail_parm_vals .= $mail_parms[$i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function smarty_function_math($params, $template)
|
|||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
|
||||
|
||||
foreach ($match[ 1 ] as $curr_var) {
|
||||
foreach ((array)$match[ 1 ] as $curr_var) {
|
||||
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
||||
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ function smarty_function_math($params, $template)
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
foreach ((array)$params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val) == 0) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
function smarty_function_popup($params, &$smarty)
|
||||
{
|
||||
$append = '';
|
||||
foreach ($params as $_key=>$_value) {
|
||||
foreach ((array)$params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'text':
|
||||
case 'trigger':
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function smarty_modifier_count_words($string)
|
|||
// count matches that contain alphanumerics
|
||||
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
|
||||
|
||||
return count($word_count);
|
||||
return count((array)$word_count);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_da
|
|||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
if (strpos($format, '%e') !== false) {
|
||||
$_win_from[] = '%e';
|
||||
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
||||
$_win_to[] = sprintf('%\' 2d', date('j', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
|
||||
}
|
||||
if (strpos($format, '%l') !== false) {
|
||||
$_win_from[] = '%l';
|
||||
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
|
||||
$_win_to[] = sprintf('%\' 2d', date('h', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
|
||||
}
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results = '<b>Array (' . count((array)$var) . ')</b>';
|
||||
foreach ((array)$var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
|
|
@ -40,8 +40,8 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
break;
|
||||
case 'object' :
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count((array)$object_vars) . ')</b>';
|
||||
foreach ((array)$object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s)
|
||||
foreach ((array)$search as $idx => $s)
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ function smarty_outputfilter_trimwhitespace($source, &$smarty)
|
|||
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
|
||||
$_len = strlen($search_str);
|
||||
$_pos = 0;
|
||||
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
|
||||
for ($_i=0, $_count=count((array)$replace); $_i<$_count; $_i++)
|
||||
if (($_pos=strpos($subject, $search_str, $_pos))!==false)
|
||||
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue