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:
copilot-swe-agent[bot] 2026-04-23 14:01:37 +00:00 committed by GitHub
parent aca850b6cd
commit e44519c030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
465 changed files with 1716 additions and 1716 deletions

View file

@ -117,9 +117,9 @@ function config_games_render_node(SimpleXMLElement $node, array $ancestors, arra
}
$attributes = $node->attributes();
if ($attributes && count($attributes) > 0) {
if ($attributes && count((array)$attributes) > 0) {
$html .= "<div class='xml-node__attributes'><strong>Attributes</strong>";
foreach ($attributes as $attrName => $attrValue) {
foreach ((array)$attributes as $attrName => $attrValue) {
$attrSafe = htmlspecialchars($attrName, ENT_QUOTES, 'UTF-8');
$valSafe = htmlspecialchars((string)$attrValue, ENT_QUOTES, 'UTF-8');
$html .= "<div class='attr-row'><span>{$attrSafe}</span><input type='text' name=\"nodes[{$safeNodeKey}][attributes][{$attrSafe}]\" value=\"{$valSafe}\" placeholder='Leave blank to remove'></div>";
@ -166,7 +166,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
return false;
}
$nodes = [];
foreach ($nodesPayload as $key => $data) {
foreach ((array)$nodesPayload as $key => $data) {
$rawPath = isset($data['path']) ? (string)$data['path'] : (string)$key;
$cleanPath = config_games_normalize_path($rawPath);
if ($cleanPath === '') {
@ -188,7 +188,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
uksort($nodes, function ($a, $b) {
return substr_count($b, '/') <=> substr_count($a, '/');
});
foreach ($nodes as $path => $nodeData) {
foreach ((array)$nodes as $path => $nodeData) {
$query = '/' . $path;
$nodeList = @$xpath->query($query);
if (!$nodeList || $nodeList->length === 0) {
@ -203,7 +203,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
continue;
}
$hasChildren = !empty($nodeData['has_children']);
if (array_key_exists('value', $nodeData)) {
if (array_key_exists('value', (array)$nodeData)) {
$normalizedValue = config_games_normalize_newlines($nodeData['value']);
while ($domNode->firstChild) {
$domNode->removeChild($domNode->firstChild);
@ -217,7 +217,7 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload)
}
}
if (isset($nodeData['attributes']) && is_array($nodeData['attributes'])) {
foreach ($nodeData['attributes'] as $attrName => $attrValue) {
foreach ((array)$nodeData['attributes'] as $attrName => $attrValue) {
$attrNameClean = preg_replace('/[^A-Za-z0-9_\\-:]/', '', (string)$attrName);
if ($attrNameClean === '') {
continue;
@ -298,7 +298,7 @@ function exec_ogp_module() {
$db->clearGameCfgs($clear_old);
foreach ( $files as $config_file )
foreach ((array)$files as $config_file)
{
$config = read_server_config($config_file);
@ -342,7 +342,7 @@ function exec_ogp_module() {
<td class='left'>\n
<select name='home_cfg_id' onchange=".'"this.form.submit()"'.">\n
<option style='background:black;color:white;' value=''>".get_lang('select_game')."</option>\n";
foreach ( $game_cfgs as $row )
foreach ((array)$game_cfgs as $row)
{
if ( preg_match( "/_win/", $row['game_key'] ) )
$os = "(Windows)";

View file

@ -123,7 +123,7 @@ function exec_ogp_module() {
$_SESSION['mods'][1]['mod_installer_name'] = $key_name;
}
$mods = $_SESSION['mods'];
foreach($mods as $mod)
foreach ((array)$mods as $mod)
{
$template .= "
<mod key='".$mod['mod_key']."'>
@ -139,7 +139,7 @@ function exec_ogp_module() {
$template .= "
<server_params>";
$params = $_SESSION['params'];
foreach($params as $param)
foreach ((array)$params as $param)
{
$template .= "
<param key='".$param['param_key']."' type='".$param['param_type']."'>

View file

@ -72,7 +72,7 @@ if (!function_exists('ogp_format_libxml_errors')) {
return "No additional libxml details are available.";
}
$messages = array();
foreach ($errors as $error) {
foreach ((array)$errors as $error) {
$messages[] = trim($error->message) . " (Line {$error->line}, Column {$error->column})";
}
libxml_clear_errors();

View file

@ -92,7 +92,7 @@ function exec_ogp_module() {
$template = "";
if ($mods)
{
foreach($mods as $mod)
foreach ((array)$mods as $mod)
{
$template .= " ";
$template .= $mod['mod_name'];

View file

@ -97,7 +97,7 @@ function exec_ogp_module() {
if ($params)
{
$template = "";
foreach($params as $param)
foreach ((array)$params as $param)
{
$template .= $param['param_key'];
}

View file

@ -32,7 +32,7 @@ function exec_ogp_module()
require_once 'protocol/lgsl/lgsl_protocol.php';
$lgsl_type_list = lgsl_type_list();
asort($lgsl_type_list);
foreach ($lgsl_type_list as $type => $description) {
foreach ((array)$lgsl_type_list as $type => $description) {
$queryChoices[$type] = $description;
}
$queryLabel = 'LGSL Query Name';
@ -58,7 +58,7 @@ function exec_ogp_module()
}
unset($dir);
ksort($protocols);
foreach ($protocols as $gameq => $info) {
foreach ((array)$protocols as $gameq => $info) {
$queryChoices[$gameq] = $info['name'];
}
$queryLabel = 'GameQ Query Name';
@ -95,7 +95,7 @@ CSS;
'lgsl' => 'LGSL',
'gameq' => 'GameQ',
);
foreach ($protocolOptions as $value => $label) {
foreach ((array)$protocolOptions as $value => $label) {
$safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$safeLabel = htmlspecialchars($label, ENT_QUOTES, 'UTF-8');
$selected = ($selectedProtocol === $value) ? "selected='selected'" : '';
@ -115,7 +115,7 @@ CSS;
$label = htmlspecialchars($queryLabel, ENT_QUOTES, 'UTF-8');
echo "<label for='query_name'>{$label}</label>";
echo "<select id='query_name' name='query_name'>";
foreach ($queryChoices as $value => $labelText) {
foreach ((array)$queryChoices as $value => $labelText) {
$safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$safeLabelText = htmlspecialchars($labelText, ENT_QUOTES, 'UTF-8');
echo "<option value='{$safeValue}'>{$safeLabelText}</option>";