From c09b6737d9f734484bb2aa4ae1324b69cd262496 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 9 May 2026 14:19:36 +0000 Subject: [PATCH] chore: apply final provisioning review cleanups Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/a39ca073-858c-4e1e-978f-09caabb0f029 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- modules/billing/create_servers.php | 13 +++++++++++-- modules/gamemanager/server_monitor.php | 2 ++ modules/user_games/add_home.php | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/billing/create_servers.php b/modules/billing/create_servers.php index 6d99c5d5..036aefcd 100644 --- a/modules/billing/create_servers.php +++ b/modules/billing/create_servers.php @@ -48,6 +48,13 @@ if (!function_exists('billing_should_regenerate_provision_password')) { } } +if (!function_exists('billing_agent_offline_reason')) { + function billing_agent_offline_reason(int $remote_server_id, array $home_info): string + { + return "Agent is offline for remote server #{$remote_server_id} (" . ($home_info['agent_ip'] ?? 'unknown') . ":" . ($home_info['agent_port'] ?? 'unknown') . ")."; + } +} + if (!function_exists('billing_invoke_provision')) { function billing_invoke_provision(array $options = array()) { @@ -486,6 +493,8 @@ function exec_ogp_module() $order_failure_reason = "Could not create server_homes row for order #{$order_id}."; } if (!$order_failed) { + // Billing storefront defaults to FTP enabled for newly provisioned homes + // so panel/account flows remain consistent immediately after checkout. $db->changeFtpStatus('enabled', intval($home_id)); } @@ -589,7 +598,7 @@ function exec_ogp_module() } if (empty($autoInstall['ok'])) { if (stripos((string)($autoInstall['message'] ?? ''), 'Agent is offline') !== false) { - $order_failure_reason = "Agent is offline for remote server #{$remote_server_id} (" . ($home_info['agent_ip'] ?? 'unknown') . ":" . ($home_info['agent_port'] ?? 'unknown') . ")."; + $order_failure_reason = billing_agent_offline_reason(intval($remote_server_id), (array)$home_info); } $order_failed = true; $order_failure_reason = $order_failure_reason !== '' ? $order_failure_reason : ("Server files have not been installed yet. " . ($autoInstall['message'] ?? 'Auto install could not be started.')); @@ -706,7 +715,7 @@ function exec_ogp_module() } if (empty($autoInstall['ok'])) { if (stripos((string)($autoInstall['message'] ?? ''), 'Agent is offline') !== false) { - $order_failure_reason = "Agent is offline for remote server #{$remote_server_id} (" . ($home_info['agent_ip'] ?? 'unknown') . ":" . ($home_info['agent_port'] ?? 'unknown') . ")."; + $order_failure_reason = billing_agent_offline_reason(intval($remote_server_id), (array)$home_info); } $order_failed = true; $order_failure_reason = $order_failure_reason !== '' ? $order_failure_reason : ("Server files have not been installed yet. " . ($autoInstall['message'] ?? 'Auto install could not be started.')); diff --git a/modules/gamemanager/server_monitor.php b/modules/gamemanager/server_monitor.php index dc6cbb4c..fe9e74d8 100644 --- a/modules/gamemanager/server_monitor.php +++ b/modules/gamemanager/server_monitor.php @@ -449,6 +449,8 @@ echo "getHomeIpPorts(intval($server_home['home_id'])); if (!empty($home_ip_ports) && is_array($home_ip_ports)) { + // Preference order: exact mod-specific mapping, generic force_mod_id=0 mapping, + // then first available mapping so newly provisioned homes always show an endpoint. $fallback_ip_port = null; foreach ((array)$home_ip_ports as $ip_port_row) { if (intval($ip_port_row['force_mod_id'] ?? 0) === intval($server_home['mod_id'] ?? 0)) { diff --git a/modules/user_games/add_home.php b/modules/user_games/add_home.php index 45c784c5..bae8f953 100644 --- a/modules/user_games/add_home.php +++ b/modules/user_games/add_home.php @@ -173,6 +173,8 @@ function exec_ogp_module() billing_invoke_provision(array( 'order_ids' => array(intval($billing_order_id)), 'user_id' => intval($web_user_id), + // Trusted internal panel flow; allows admin-context provisioning + // without requiring a customer session/login redirect trigger. 'is_admin' => true )); }