fix: harden billing module for standalone portability
- config_loader.php: prefer local billing config FIRST (root cause fix) - was: panel config loaded first, overriding local config with wrong db name - now: local modules/billing/includes/config.inc.php always wins when present - config.inc.php: add $db_port="3306" - config.example.php: new example config with all variables documented - menu.php: add $db_port to mysqli_connect - admin_auth.php: add $db_port; remove hardcoded /_website path detection - bootstrap.php billing_get_db(): add $db_port - login.php: fix /_website path detection - adminserverlist.php: add $db_port; fix hardcoded /modules/billing/ URL - All other mysqli_connect calls: add isset($db_port) port parameter (my_servers, forgot_password, serverlist, server_status, order, register, reset_password, payment_success, my_account, admin_invoices, admin_payments, diag_remote, admin_coupons, test_db_connection, tools/check_db_user, renew_server) - timestamp.txt: updated Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/a3e1e4bb-8eb1-4e6e-b1f8-7f3952301231 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
834d56a506
commit
1247e5e7ca
25 changed files with 105 additions and 70 deletions
|
|
@ -2,27 +2,44 @@
|
|||
/**
|
||||
* Billing config loader
|
||||
*
|
||||
* Attempts to load the main panel config file first (../includes/config.inc.php).
|
||||
* If that file is not readable, falls back to a module-local config.inc.php copy.
|
||||
* When neither file exists, output a plain-text error and stop execution so that
|
||||
* the admin knows to copy the config locally.
|
||||
* Priority order (standalone-first):
|
||||
* 1. modules/billing/includes/config.inc.php (local billing config — always wins when present)
|
||||
* 2. <panel_root>/includes/config.inc.php (panel config — fallback when no local config)
|
||||
*
|
||||
* This ensures that copying modules/billing/ to any web root works correctly
|
||||
* after editing its own config.inc.php, without being overridden by a parent
|
||||
* panel installation that may have a different database name.
|
||||
*/
|
||||
if (defined('BILLING_CONFIG_LOADED')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$localConfig = __DIR__ . '/config.inc.php';
|
||||
$attempted = [];
|
||||
|
||||
// Always prefer the local billing config so the module is self-contained.
|
||||
if (is_readable($localConfig)) {
|
||||
$attempted[] = $localConfig;
|
||||
require_once $localConfig;
|
||||
if (!defined('BILLING_CONFIG_PATH')) {
|
||||
define('BILLING_CONFIG_PATH', $localConfig);
|
||||
}
|
||||
define('BILLING_CONFIG_LOADED', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$attempted[] = $localConfig;
|
||||
|
||||
// Fallback: try to load the panel's config (useful when running embedded inside the panel
|
||||
// and no local copy has been made yet).
|
||||
$panelConfig = null;
|
||||
$projectRoot = realpath(__DIR__ . '/../../..');
|
||||
if ($projectRoot !== false) {
|
||||
$panelConfig = $projectRoot . '/includes/config.inc.php';
|
||||
} else {
|
||||
// Fallback relative path without resolving symlinks
|
||||
$panelConfig = __DIR__ . '/../../..' . '/includes/config.inc.php';
|
||||
}
|
||||
|
||||
$localConfig = __DIR__ . '/config.inc.php';
|
||||
$attempted = [];
|
||||
|
||||
if ($panelConfig && is_readable($panelConfig)) {
|
||||
$attempted[] = $panelConfig;
|
||||
require_once $panelConfig;
|
||||
|
|
@ -34,17 +51,6 @@ if ($panelConfig && is_readable($panelConfig)) {
|
|||
}
|
||||
|
||||
$attempted[] = $panelConfig;
|
||||
if (is_readable($localConfig)) {
|
||||
$attempted[] = $localConfig;
|
||||
require_once $localConfig;
|
||||
if (!defined('BILLING_CONFIG_PATH')) {
|
||||
define('BILLING_CONFIG_PATH', $localConfig);
|
||||
}
|
||||
define('BILLING_CONFIG_LOADED', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$attempted[] = $localConfig;
|
||||
|
||||
$message = "GSP Billing module cannot find config.inc.php.\n";
|
||||
$message .= "Looked in:\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue