From 75fea8e3d64c305f27a9c353cef20ee740d1313c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 9 May 2026 14:17:28 +0000 Subject: [PATCH] refactor: fix provisioning password validation/generation consistency 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/billing/create_servers.php b/modules/billing/create_servers.php index e9c9308e..3bff31c0 100644 --- a/modules/billing/create_servers.php +++ b/modules/billing/create_servers.php @@ -14,9 +14,9 @@ if (!defined('BILLING_NICE_DEFAULT')) { } if (!function_exists('billing_generate_provision_password')) { - function billing_generate_provision_password(int $length = 6) + function billing_generate_provision_password() { - $length = max(6, $length); + $length = 6; $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $alphabetLen = strlen($alphabet); $password = ''; @@ -41,6 +41,13 @@ if (!function_exists('billing_is_valid_provision_password')) { } } +if (!function_exists('billing_should_regenerate_provision_password')) { + function billing_should_regenerate_provision_password($value): bool + { + return !billing_is_valid_provision_password($value) || strcasecmp((string)$value, 'ChangeMe') === 0; + } +} + if (!function_exists('billing_invoke_provision')) { function billing_invoke_provision(array $options = array()) { @@ -308,10 +315,10 @@ function exec_ogp_module() $home_name = $order['home_name']; $remote_control_password = $order['remote_control_password']; $ftp_password = $order['ftp_password']; - if (!billing_is_valid_provision_password($remote_control_password) || strcasecmp((string)$remote_control_password, 'ChangeMe') === 0) { + if (billing_should_regenerate_provision_password($remote_control_password)) { $remote_control_password = billing_generate_provision_password(); } - if (!billing_is_valid_provision_password($ftp_password) || strcasecmp((string)$ftp_password, 'ChangeMe') === 0) { + if (billing_should_regenerate_provision_password($ftp_password)) { $ftp_password = billing_generate_provision_password(); } $ip = $order['ip'];