site changes by codex
This commit is contained in:
parent
f0b7f96987
commit
dc24d43921
34 changed files with 1736 additions and 247 deletions
|
|
@ -1,9 +1,6 @@
|
|||
<?php
|
||||
// Admin authorization include — include early (before output) on admin pages
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_name("gameservers_website");
|
||||
session_start();
|
||||
}
|
||||
require_once(__DIR__ . '/session_bridge.php');
|
||||
|
||||
// If not logged in, redirect to login
|
||||
if (empty($_SESSION['website_user_id'])) {
|
||||
|
|
@ -66,3 +63,5 @@ if (strtolower($role) !== 'admin') {
|
|||
|
||||
// If we reach here, user is an admin
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_name("gameservers_website");
|
||||
session_start();
|
||||
}
|
||||
require_once(__DIR__ . '/session_bridge.php');
|
||||
|
||||
// Debugging mode: do not enforce login redirects. Pages can load without authentication.
|
||||
// If you later want to re-enable, restore the original redirect behavior.
|
||||
// (This file intentionally left as a no-op during debugging.)
|
||||
return;
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,7 @@
|
|||
* This file provides a consistent navigation menu across all website pages
|
||||
*/
|
||||
|
||||
// Start the website session to check if user is logged in (if not already started)
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_name("gameservers_website");
|
||||
session_start();
|
||||
}
|
||||
require_once(__DIR__ . '/session_bridge.php');
|
||||
|
||||
// Check login status
|
||||
// Primary check uses website_user_id, but some remote deployments may only set website_username.
|
||||
|
|
@ -122,3 +118,4 @@ if ($is_logged_in) {
|
|||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
97
modules/billing/includes/panel_bridge.php
Normal file
97
modules/billing/includes/panel_bridge.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* Panel bridge helpers for the storefront.
|
||||
* Provides access to the native OGPDatabase layer, settings, and XML parsers
|
||||
* without duplicating the panel bootstrap logic in each script.
|
||||
*/
|
||||
|
||||
if (!function_exists('billing_panel_bootstrap')) {
|
||||
/**
|
||||
* Initialize the panel runtime and return shared context.
|
||||
*
|
||||
* @return array{db:OGPDatabase|null, settings:array, table_prefix:string}|null
|
||||
*/
|
||||
function billing_panel_bootstrap()
|
||||
{
|
||||
static $context = null;
|
||||
if ($context !== null) {
|
||||
return $context;
|
||||
}
|
||||
|
||||
$root = realpath(__DIR__ . '/../../');
|
||||
if ($root === false) {
|
||||
error_log('billing_panel_bootstrap: unable to resolve project root');
|
||||
return null;
|
||||
}
|
||||
|
||||
// Define panel constants if they are not already defined (panel runtime does this for us).
|
||||
if (!defined('INCLUDES')) {
|
||||
define('INCLUDES', 'includes/');
|
||||
}
|
||||
if (!defined('MODULES')) {
|
||||
define('MODULES', 'modules/');
|
||||
}
|
||||
|
||||
// Load panel helpers that provisioning logic depends on.
|
||||
require_once $root . '/includes/functions.php';
|
||||
require_once $root . '/includes/helpers.php';
|
||||
require_once $root . '/includes/lib_remote.php';
|
||||
require_once $root . '/modules/config_games/server_config_parser.php';
|
||||
|
||||
// Load panel configuration (db credentials, prefix, etc.)
|
||||
$configFile = $root . '/includes/config.inc.php';
|
||||
if (!file_exists($configFile)) {
|
||||
error_log('billing_panel_bootstrap: missing config file ' . $configFile);
|
||||
return null;
|
||||
}
|
||||
require $configFile;
|
||||
|
||||
// Ensure required variables exist before attempting to connect.
|
||||
if (!isset($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix)) {
|
||||
error_log('billing_panel_bootstrap: config variables not initialized');
|
||||
return null;
|
||||
}
|
||||
|
||||
$panelDb = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
|
||||
if (!($panelDb instanceof OGPDatabase)) {
|
||||
error_log('billing_panel_bootstrap: failed to connect to panel database');
|
||||
return null;
|
||||
}
|
||||
|
||||
$settings = $panelDb->getSettings();
|
||||
|
||||
$context = [
|
||||
'db' => $panelDb,
|
||||
'settings' => is_array($settings) ? $settings : [],
|
||||
'table_prefix' => $table_prefix,
|
||||
];
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_get_panel_db')) {
|
||||
/**
|
||||
* Convenience wrapper to fetch the shared OGPDatabase handle.
|
||||
*
|
||||
* @return OGPDatabase|null
|
||||
*/
|
||||
function billing_get_panel_db()
|
||||
{
|
||||
$ctx = billing_panel_bootstrap();
|
||||
return $ctx['db'] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_get_panel_settings')) {
|
||||
/**
|
||||
* Convenience wrapper to fetch panel settings (time zone, steam creds, etc.).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function billing_get_panel_settings()
|
||||
{
|
||||
$ctx = billing_panel_bootstrap();
|
||||
return $ctx['settings'] ?? [];
|
||||
}
|
||||
}
|
||||
32
modules/billing/includes/session_bridge.php
Normal file
32
modules/billing/includes/session_bridge.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Session bridge to keep panel + storefront logins in sync.
|
||||
* Always call this before rendering billing pages.
|
||||
*/
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_name('opengamepanel_web');
|
||||
session_start();
|
||||
}
|
||||
|
||||
// If the panel session is populated, mirror into website-specific keys.
|
||||
if (!empty($_SESSION['user_id']) && empty($_SESSION['website_user_id'])) {
|
||||
$_SESSION['website_user_id'] = (int)$_SESSION['user_id'];
|
||||
if (!empty($_SESSION['users_login'])) {
|
||||
$_SESSION['website_username'] = $_SESSION['users_login'];
|
||||
}
|
||||
if (!empty($_SESSION['users_group'])) {
|
||||
$_SESSION['website_user_role'] = $_SESSION['users_group'];
|
||||
}
|
||||
}
|
||||
|
||||
// If the website session is populated but the panel keys are missing, mirror back.
|
||||
if (!empty($_SESSION['website_user_id']) && empty($_SESSION['user_id'])) {
|
||||
$_SESSION['user_id'] = (int)$_SESSION['website_user_id'];
|
||||
if (!empty($_SESSION['website_username'])) {
|
||||
$_SESSION['users_login'] = $_SESSION['website_username'];
|
||||
}
|
||||
if (!empty($_SESSION['website_user_role'])) {
|
||||
$_SESSION['users_group'] = $_SESSION['website_user_role'];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue