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>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-09 14:17:28 +00:00 committed by GitHub
parent 2a6c8440aa
commit 75fea8e3d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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'];