fixed missign config file and added check if xmlrpc istnt installed

This commit is contained in:
Frank Harris 2025-11-23 14:42:37 -05:00
parent 70e05e57d8
commit 5f5008b377
21 changed files with 115 additions and 42 deletions

View file

@ -24,6 +24,24 @@
require_once("Crypt/XXTEA.php");
if (!defined('GSP_XMLRPC_READY')) {
if (!function_exists('xmlrpc_encode_request') || !function_exists('xmlrpc_decode')) {
$message = "GSP requires the PHP xmlrpc extension for agent communication.\n".
"Install the php-xmlrpc package for your PHP version (example: sudo apt install php8.3-xmlrpc on Ubuntu 24.04 or use PECL).\n".
"See https://www.php.net/manual/en/book.xmlrpc.php for installation instructions.";
if (PHP_SAPI === 'cli') {
fwrite(STDERR, $message . PHP_EOL);
} else {
if (!headers_sent()) {
header('Content-Type: text/plain; charset=UTF-8', true, 500);
}
echo nl2br(htmlentities($message));
}
exit(1);
}
define('GSP_XMLRPC_READY', true);
}
// Screen type for servers
define("OGP_SCREEN_TYPE_HOME","HOME");
define("OGP_SCREEN_TYPE_UPDATE","UPDATE");

View file

@ -1,7 +1,7 @@
<?php
// Admin landing page
require_once(__DIR__ . '/includes/admin_auth.php');
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
include(__DIR__ . '/includes/top.php');
include(__DIR__ . '/includes/menu.php');

View file

@ -1,7 +1,7 @@
<?php
// Admin config editor — lightweight editor for _website/includes/config.inc.php
require_once(__DIR__ . '/includes/admin_auth.php');
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
include(__DIR__ . '/includes/top.php');
include(__DIR__ . '/includes/menu.php');

View file

@ -1,7 +1,7 @@
<?php
// Admin coupon management page - standalone billing module
require_once(__DIR__ . '/includes/admin_auth.php');
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
// Variables from config.inc.php (helps IDEs understand scope)
/** @var string $db_host Database host */

View file

@ -1,7 +1,7 @@
<?php
// Admin payments viewer — lists persisted PayPal webhook JSON files
$session_name = session_name(); session_start();
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
require_once(__DIR__ . '/includes/admin_auth.php');
$dataDir = (isset($SITE_DATA_DIR) && $SITE_DATA_DIR) ? $SITE_DATA_DIR : realpath(__DIR__ . '/') . DIRECTORY_SEPARATOR . 'data';

View file

@ -5,7 +5,7 @@
* Standalone billing module - uses only standard PHP mysqli
*/
require_once(__DIR__ . '/../includes/config.inc.php');
require_once(__DIR__ . '/../includes/config_loader.php');
// Prevent any output before JSON
ob_start();

View file

@ -8,7 +8,7 @@
ini_set('display_errors', '0');
error_reporting(E_ALL);
require_once(__DIR__ . '/../includes/config.inc.php');
require_once(__DIR__ . '/../includes/config_loader.php');
// create_order for PayPal — adapted to run from _website/api
$sandbox = true; // flip to false for Live
$client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c';

View file

@ -5,14 +5,7 @@
// Ensure session sync with panel happens first
require_once __DIR__ . '/includes/session_bridge.php';
// Load configuration (includes/config.inc.php) if present
$config_path = __DIR__ . '/includes/config.inc.php';
if (file_exists($config_path)) {
require_once $config_path;
} else {
trigger_error('Billing config not found: ' . $config_path, E_USER_WARNING);
}
require_once __DIR__ . '/includes/config_loader.php';
// Ensure $table_prefix exists (fallback to empty string)
if (!isset($table_prefix)) {

View file

@ -21,15 +21,19 @@ echo "Session status (after start): " . session_status() . "\n";
echo "Session id: " . session_id() . "\n";
echo "Session variables: \n" . print_r($_SESSION, true) . "\n";
// Check config file readability
$cfg = __DIR__ . '/includes/config.inc.php';
echo "Config file: " . $cfg . " exists=" . (file_exists($cfg) ? 'yes' : 'no') . " readable=" . (is_readable($cfg) ? 'yes' : 'no') . "\n";
if (file_exists($cfg)) {
echo "Config contents (first 200 chars):\n" . substr(file_get_contents($cfg),0,200) . "\n";
// Check config file readability (panel root first, module local second)
$panelCfgRoot = realpath(__DIR__ . '/../../..');
$panelCfg = $panelCfgRoot ? $panelCfgRoot . '/includes/config.inc.php' : __DIR__ . '/../../..' . '/includes/config.inc.php';
$localCfg = __DIR__ . '/includes/config.inc.php';
echo "Panel config: " . $panelCfg . " exists=" . (file_exists($panelCfg) ? 'yes' : 'no') . " readable=" . (is_readable($panelCfg) ? 'yes' : 'no') . "\n";
echo "Local config: " . $localCfg . " exists=" . (file_exists($localCfg) ? 'yes' : 'no') . " readable=" . (is_readable($localCfg) ? 'yes' : 'no') . "\n";
require_once(__DIR__ . '/includes/config_loader.php');
echo "Active config source: " . (defined('BILLING_CONFIG_PATH') ? BILLING_CONFIG_PATH : '(unknown)') . "\n";
if (defined('BILLING_CONFIG_PATH') && is_readable(BILLING_CONFIG_PATH)) {
echo "Active config preview (first 200 chars):\n" . substr(file_get_contents(BILLING_CONFIG_PATH), 0, 200) . "\n";
}
// Attempt DB connection using site config (if readable)
if (file_exists($cfg)) require_once($cfg);
echo "Trying DB connection...\n";
$ok = false;
if (isset($db_host)) {

View file

@ -11,7 +11,7 @@ if (session_status() === PHP_SESSION_NONE) {
}
// Include config
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
// Set the docs directory
$docsDir = __DIR__ . '/docs';

View file

@ -1,6 +1,6 @@
<?php
require_once(__DIR__ . '/../includes/admin_auth.php');
require_once(__DIR__ . '/../includes/config.inc.php');
require_once(__DIR__ . '/../includes/config_loader.php');
include(__DIR__ . '/../includes/top.php');
include(__DIR__ . '/../includes/menu.php');

View file

@ -20,8 +20,7 @@ if (empty($_SESSION['website_user_id'])) {
}
// Require DB config and check role live from panel DB
require_once(__DIR__ . '/config.inc.php');
require_once(__DIR__ . '/config_loader.php');
// Variables from config.inc.php (helps IDEs understand scope)
/** @var string $db_host Database host */

View file

@ -0,0 +1,64 @@
<?php
/**
* 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.
*/
if (defined('BILLING_CONFIG_LOADED')) {
return;
}
$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;
if (!defined('BILLING_CONFIG_PATH')) {
define('BILLING_CONFIG_PATH', $panelConfig);
}
define('BILLING_CONFIG_LOADED', true);
return;
}
$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";
foreach ($attempted as $path) {
if (!$path) {
continue;
}
$message .= " - " . $path . "\n";
}
$message .= "\nCopy your panel's includes/config.inc.php into modules/billing/includes/config.inc.php ";
$message .= "or ensure the panel config is readable so the billing pages can load database settings.\n";
if (!headers_sent()) {
header('Content-Type: text/plain; charset=UTF-8', true, 500);
}
echo $message;
exit(1);

View file

@ -22,7 +22,7 @@ if (isset($_SESSION['website_username']) && !empty($_SESSION['website_username']
$is_admin = false;
if ($is_logged_in) {
// load DB credentials
require_once(__DIR__ . '/config.inc.php');
require_once(__DIR__ . '/config_loader.php');
// Variables from config.inc.php (helps IDEs understand scope)
/** @var string $db_host Database host */

View file

@ -12,14 +12,8 @@
* process_payment_record($record);
*/
// Include the module-local config (must be present in the module includes folder).
// Use ONLY `config.inc.php` — do NOT fall back to other filenames.
$moduleConfig = __DIR__ . '/config.inc.php';
if (is_file($moduleConfig)) {
require_once $moduleConfig;
} else {
error_log('[payment_processor] Module config not found: expected ' . $moduleConfig);
}
// Load panel config first, falling back to a module-local copy if needed.
require_once __DIR__ . '/config_loader.php';
// Variables from config.inc.php (helps IDEs understand scope)
/** @var string $db_host Database host */
@ -226,3 +220,4 @@ function process_payment_record(array $record) {
}
?>

View file

@ -1,7 +1,7 @@
<?php
// User invoice history (reads payments/data/*.json)
$session_name = session_name(); session_start();
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
// Intentionally do not require login here; invoices should be viewable (or filtered) without forcing a login.
// try to get logged-in user's email for matching

View file

@ -6,7 +6,7 @@
session_start();
require_once(__DIR__ . '/includes/header.php');
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
$invoice_ref = isset($_GET['invoice']) ? $_GET['invoice'] : '';

View file

@ -5,7 +5,7 @@
* Standalone billing module - uses only standard PHP mysqli
*/
session_start();
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
// Variables from config.inc.php (helps IDEs understand scope)
/** @var string $db_host Database host */
@ -223,4 +223,4 @@ if ($db && $user_id > 0) {
</div>
</div>
</body>
</html>
</html>

View file

@ -1,5 +1,5 @@
<?php
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
$dataDir = (isset($SITE_DATA_DIR) && $SITE_DATA_DIR) ? $SITE_DATA_DIR : realpath(__DIR__ . '/') . DIRECTORY_SEPARATOR . 'data';
$invoice = $_GET['invoice'] ?? '';

View file

@ -1,5 +1,5 @@
<?php
require_once(__DIR__ . '/../includes/config.inc.php');
require_once(__DIR__ . '/../includes/config_loader.php');
$db = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$db) {
echo "DB connect failed: " . mysqli_connect_error() . PHP_EOL;
@ -27,4 +27,4 @@ if (mysqli_num_rows($res) === 0) {
echo "pass_hash(db)=" . ($row['users_pass_hash'] ?? '') . "\n";
}
mysqli_close($db);
?>
?>

View file

@ -1,5 +1,5 @@
<?php
require_once(__DIR__ . '/includes/config.inc.php');
require_once(__DIR__ . '/includes/config_loader.php');
if (is_file(__DIR__ . '/includes/log.php')) require_once(__DIR__ . '/includes/log.php');
$config = [