From 38dfb056fb3635c22edd8c5b304dcd16b16dd25a Mon Sep 17 00:00:00 2001 From: Frank Harris Date: Thu, 20 Nov 2025 16:56:32 -0500 Subject: [PATCH] config servers udpate --- modules/config_games/config_servers.php | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/modules/config_games/config_servers.php b/modules/config_games/config_servers.php index b828c8a3..5e09b632 100644 --- a/modules/config_games/config_servers.php +++ b/modules/config_games/config_servers.php @@ -30,6 +30,13 @@ function config_games_normalize_path($path) return ltrim($clean, '/'); } +function config_games_next_form_key(): string +{ + static $counter = 0; + $counter++; + return 'node_' . $counter; +} + function config_games_print_editor_css() { static $printed = false; @@ -73,6 +80,8 @@ function config_games_render_node(SimpleXMLElement $node, array $ancestors, arra $value = (string)$node; $safeLabel = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); $safePath = htmlspecialchars($path, ENT_QUOTES, 'UTF-8'); + $nodeKey = config_games_next_form_key(); + $safeNodeKey = htmlspecialchars($nodeKey, ENT_QUOTES, 'UTF-8'); $displayPath = htmlspecialchars(str_replace('[', '[', $rawPath), ENT_QUOTES, 'UTF-8'); $isScript = in_array(strtolower($name), ['pre_install','post_install','precmd','postcmd','cli_template']); @@ -80,22 +89,22 @@ function config_games_render_node(SimpleXMLElement $node, array $ancestors, arra $actionId = 'node_action_' . substr(md5($safePath . $index), 0, 8); $html .= "
{$safeLabel}
{$displayPath}
"; $html .= "
"; - $html .= ""; + $html .= ""; $html .= "
"; $html .= "
"; - $html .= ""; - $html .= ""; + $html .= ""; + $html .= ""; if (!$hasChildren || $isScript) { $safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); if ($isScript || strlen($value) > 120) { - $html .= ""; + $html .= ""; } else { - $html .= ""; + $html .= ""; } } elseif (trim($value) !== '') { $safeValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); - $html .= ""; + $html .= ""; $html .= "

This element contains nested tags; clearing the text does not remove children.

"; } @@ -105,12 +114,12 @@ function config_games_render_node(SimpleXMLElement $node, array $ancestors, arra foreach ($attributes as $attrName => $attrValue) { $attrSafe = htmlspecialchars($attrName, ENT_QUOTES, 'UTF-8'); $valSafe = htmlspecialchars((string)$attrValue, ENT_QUOTES, 'UTF-8'); - $html .= "
{$attrSafe}
"; + $html .= "
{$attrSafe}
"; } - $html .= "
"; + $html .= "
"; $html .= "
"; } else { - $html .= "
"; + $html .= "
"; } if ($hasChildren) { @@ -149,11 +158,13 @@ function config_games_save_xml($db, $home_cfg_id, array $nodesPayload) return false; } $nodes = []; - foreach ($nodesPayload as $path => $data) { - $cleanPath = config_games_normalize_path($path); + foreach ($nodesPayload as $key => $data) { + $rawPath = isset($data['path']) ? (string)$data['path'] : (string)$key; + $cleanPath = config_games_normalize_path($rawPath); if ($cleanPath === '') { continue; } + $data['path'] = $cleanPath; $nodes[$cleanPath] = $data; } if (empty($nodes)) {