fixed debug level
This commit is contained in:
parent
b5e550cb5c
commit
49451d9ebb
8 changed files with 96 additions and 23 deletions
5
home.php
5
home.php
|
|
@ -59,6 +59,11 @@ $settings = $db->getSettings();
|
||||||
@$GLOBALS['panel_language'] = $settings['panel_language'];
|
@$GLOBALS['panel_language'] = $settings['panel_language'];
|
||||||
ogpLang();
|
ogpLang();
|
||||||
|
|
||||||
|
// Apply debug level from panel settings (overrides the DEBUG_LEVEL constant)
|
||||||
|
if (defined('DEBUG_MODE') && DEBUG_MODE && function_exists('gsp_apply_debug_level')) {
|
||||||
|
gsp_apply_debug_level((int)($settings['debug_level'] ?? DEBUG_LEVEL));
|
||||||
|
}
|
||||||
|
|
||||||
require_once("includes/view.php");
|
require_once("includes/view.php");
|
||||||
$view = new OGPView();
|
$view = new OGPView();
|
||||||
$view->setCharset(get_lang('lang_charset'));
|
$view->setCharset(get_lang('lang_charset'));
|
||||||
|
|
|
||||||
|
|
@ -2191,7 +2191,7 @@ class OGPDatabaseMySQL extends OGPDatabase
|
||||||
return $this->listQuery($query);
|
return $this->listQuery($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIpPorts_limit($ip_id = 0,$page_dashboardlist,$limit_dashboardlist) {
|
public function getIpPorts_limit($ip_id = 0, $page_dashboardlist = 1, $limit_dashboardlist = 25) {
|
||||||
$ip_id = $this->realEscapeSingle($ip_id);
|
$ip_id = $this->realEscapeSingle($ip_id);
|
||||||
$user_request_page = ($page_dashboardlist - 1) * $limit_dashboardlist;
|
$user_request_page = ($page_dashboardlist - 1) * $limit_dashboardlist;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,21 @@
|
||||||
* GSP – Global Debug System
|
* GSP – Global Debug System
|
||||||
* -------------------------
|
* -------------------------
|
||||||
* Loaded early in every request (after config.inc.php defines DEBUG_MODE).
|
* Loaded early in every request (after config.inc.php defines DEBUG_MODE).
|
||||||
* Controlled by the DEBUG_MODE constant. Set to false (or leave undefined)
|
|
||||||
* in production to disable ALL output and keep standard error suppression.
|
|
||||||
*
|
*
|
||||||
* Activation:
|
* Constants (set in includes/config.inc.php):
|
||||||
* In includes/config.inc.php add: define('DEBUG_MODE', true);
|
* DEBUG_MODE – true/false master switch.
|
||||||
* In production set it to false or remove the line entirely.
|
* DEBUG_LEVEL – 0=off, 1=fatal only, 2=errors+warnings, 3=all (default 1)
|
||||||
|
*
|
||||||
|
* The panel Settings page exposes a "debug_level" dropdown that overrides
|
||||||
|
* DEBUG_LEVEL at runtime (applied in home.php after the DB is ready).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DEBUG_MODE')) {
|
if (!defined('DEBUG_MODE')) {
|
||||||
define('DEBUG_MODE', false);
|
define('DEBUG_MODE', false);
|
||||||
}
|
}
|
||||||
|
if (!defined('DEBUG_LEVEL')) {
|
||||||
|
define('DEBUG_LEVEL', 1); // fatal errors only by default
|
||||||
|
}
|
||||||
|
|
||||||
if (!DEBUG_MODE) {
|
if (!DEBUG_MODE) {
|
||||||
// Production: suppress all output, only log to server error log
|
// Production: suppress all output, only log to server error log
|
||||||
|
|
@ -26,14 +30,52 @@ if (!DEBUG_MODE) {
|
||||||
|
|
||||||
// ── Development mode ──────────────────────────────────────────────────────────
|
// ── Development mode ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
ini_set('log_errors', '1');
|
ini_set('log_errors', '1');
|
||||||
|
|
||||||
|
// Apply the initial level from the constant; may be overridden from DB later.
|
||||||
|
gsp_apply_debug_level(DEBUG_LEVEL);
|
||||||
|
|
||||||
// Accumulated non-fatal errors collected by the custom handler
|
// Accumulated non-fatal errors collected by the custom handler
|
||||||
$GLOBALS['_gsp_debug_errors'] = [];
|
$GLOBALS['_gsp_debug_errors'] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply an error-reporting level for GSP debug mode.
|
||||||
|
*
|
||||||
|
* Level map:
|
||||||
|
* 0 = off – suppress everything
|
||||||
|
* 1 = fatal only – E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR
|
||||||
|
* 2 = errors+warnings – adds E_WARNING, E_USER_ERROR, E_USER_WARNING
|
||||||
|
* 3 = all – E_ALL
|
||||||
|
*
|
||||||
|
* Safe to call multiple times (e.g. once from config, once after DB load).
|
||||||
|
*/
|
||||||
|
function gsp_apply_debug_level(int $level): void
|
||||||
|
{
|
||||||
|
switch ($level) {
|
||||||
|
case 0:
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR);
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR
|
||||||
|
| E_RECOVERABLE_ERROR | E_WARNING | E_USER_ERROR | E_USER_WARNING);
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
default:
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom error handler – captures E_WARNING, E_NOTICE, E_DEPRECATED, etc.
|
* Custom error handler – captures E_WARNING, E_NOTICE, E_DEPRECATED, etc.
|
||||||
* Fatal errors (E_ERROR, E_PARSE …) are handled by the shutdown function.
|
* Fatal errors (E_ERROR, E_PARSE …) are handled by the shutdown function.
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,20 @@ define("DEFAULT_REFRESH_TIME","2");
|
||||||
|
|
||||||
class OGPView {
|
class OGPView {
|
||||||
|
|
||||||
private $meta;
|
private string $meta = '';
|
||||||
private $title;
|
private string $title = 'Open Game Panel';
|
||||||
|
private string $header_code = '';
|
||||||
|
|
||||||
private $refreshTime;
|
private $refreshTime;
|
||||||
private $refreshUrl;
|
private $refreshUrl;
|
||||||
|
|
||||||
|
public string $logo = 'home.php?m=dashboard&p=dashboard';
|
||||||
|
public string $bg_wrapper = '';
|
||||||
|
public string $charset = 'utf-8';
|
||||||
|
public string $time_zone = 'America/Chicago';
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
ob_start();
|
ob_start();
|
||||||
$this->logo = "home.php?m=dashboard&p=dashboard";
|
|
||||||
$this->bg_wrapper = "";
|
|
||||||
$this->title = "Open Game Panel";
|
|
||||||
$this->charset = "utf-8";
|
|
||||||
$this->refreshTime = DEFAULT_REFRESH_TIME;
|
$this->refreshTime = DEFAULT_REFRESH_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,9 +136,9 @@ class OGPView {
|
||||||
{
|
{
|
||||||
$global_js_file = 'js/' . MODULES . "{$m['folder']}_global.js";
|
$global_js_file = 'js/' . MODULES . "{$m['folder']}_global.js";
|
||||||
if(is_readable($path . $global_js_file)) // Priority to the theme's js
|
if(is_readable($path . $global_js_file)) // Priority to the theme's js
|
||||||
$javascript .= "<script type=\"text/javascript\" src=\"${path}${global_js_file}\"></script>\n";
|
$javascript .= "<script type=\"text/javascript\" src=\"{$path}{$global_js_file}\"></script>\n";
|
||||||
elseif(is_readable($global_js_file))
|
elseif(is_readable($global_js_file))
|
||||||
$javascript .= "<script type=\"text/javascript\" src=\"${global_js_file}\"></script>\n";
|
$javascript .= "<script type=\"text/javascript\" src=\"{$global_js_file}\"></script>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,15 +147,15 @@ class OGPView {
|
||||||
{
|
{
|
||||||
$subpage = (isset($_GET['p']) and !empty($_GET['p']))?$_GET['p']:$_GET['m'];
|
$subpage = (isset($_GET['p']) and !empty($_GET['p']))?$_GET['p']:$_GET['m'];
|
||||||
$fc = array(
|
$fc = array(
|
||||||
$path . MODULES . "{$_GET['m']}/${subpage}.css",
|
$path . MODULES . "{$_GET['m']}/{$subpage}.css",
|
||||||
$path . MODULES . "{$_GET['m']}/{$_GET['m']}.css",
|
$path . MODULES . "{$_GET['m']}/{$_GET['m']}.css",
|
||||||
MODULES . "{$_GET['m']}/${subpage}.css",
|
MODULES . "{$_GET['m']}/{$subpage}.css",
|
||||||
MODULES . "{$_GET['m']}/{$_GET['m']}.css"
|
MODULES . "{$_GET['m']}/{$_GET['m']}.css"
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ((array)$fc as $file_check){
|
foreach ((array)$fc as $file_check){
|
||||||
if(is_readable($file_check)){
|
if(is_readable($file_check)){
|
||||||
$stylesheet .= "<link rel=\"stylesheet\" href=\"${file_check}\">\n";
|
$stylesheet .= "<link rel=\"stylesheet\" href=\"{$file_check}\">\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +167,7 @@ class OGPView {
|
||||||
|
|
||||||
foreach ((array)$fc as $file_check){
|
foreach ((array)$fc as $file_check){
|
||||||
if(is_readable($file_check)){
|
if(is_readable($file_check)){
|
||||||
$javascript .= "<script type=\"text/javascript\" src=\"${file_check}\"></script>\n";
|
$javascript .= "<script type=\"text/javascript\" src=\"{$file_check}\"></script>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,11 @@ $settings = $db->getSettings();
|
||||||
@$GLOBALS['panel_language'] = $settings['panel_language'];
|
@$GLOBALS['panel_language'] = $settings['panel_language'];
|
||||||
ogpLang();
|
ogpLang();
|
||||||
|
|
||||||
|
// Apply debug level from panel settings (overrides the DEBUG_LEVEL constant)
|
||||||
|
if (defined('DEBUG_MODE') && DEBUG_MODE && function_exists('gsp_apply_debug_level')) {
|
||||||
|
gsp_apply_debug_level((int)($settings['debug_level'] ?? DEBUG_LEVEL));
|
||||||
|
}
|
||||||
|
|
||||||
require_once("includes/view.php");
|
require_once("includes/view.php");
|
||||||
$view = new OGPView();
|
$view = new OGPView();
|
||||||
$view->setCharset( get_lang('lang_charset') );
|
$view->setCharset( get_lang('lang_charset') );
|
||||||
|
|
|
||||||
|
|
@ -145,4 +145,11 @@ define('OGP_LANG_reset_game_server_order', "Reset Game Server Ordering");
|
||||||
define('OGP_LANG_reset_game_server_order_info', "Resets game server ordering back to the default of using the server ID");
|
define('OGP_LANG_reset_game_server_order_info', "Resets game server ordering back to the default of using the server ID");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Debug level
|
||||||
|
define('OGP_LANG_debug_level', "Panel Debug Level");
|
||||||
|
define('OGP_LANG_debug_off', "Off (production)");
|
||||||
|
define('OGP_LANG_debug_fatal_only', "Fatal errors only (page-breaking)");
|
||||||
|
define('OGP_LANG_debug_errors_warnings', "Errors & Warnings");
|
||||||
|
define('OGP_LANG_debug_all', "All (verbose - E_ALL)");
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
|
||||||
parent::__destruct();
|
parent::__destruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function connect($db_host, $db_user, $db_pass, $db_name, $table_prefix = NULL) {
|
public function connect($db_host, $db_user, $db_pass, $db_name, $table_prefix = NULL, $db_port = NULL) {
|
||||||
if ( !extension_loaded("mysqli") )
|
if ( !extension_loaded("mysqli") )
|
||||||
return -99;
|
return -99;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,9 @@ function exec_ogp_module()
|
||||||
// Discord Integration
|
// Discord Integration
|
||||||
"discord_invite_url" => $_REQUEST['discord_invite_url'],
|
"discord_invite_url" => $_REQUEST['discord_invite_url'],
|
||||||
"discord_webhook_main" => $_REQUEST['discord_webhook_main'],
|
"discord_webhook_main" => $_REQUEST['discord_webhook_main'],
|
||||||
"discord_webhook_admin" => $_REQUEST['discord_webhook_admin']
|
"discord_webhook_admin" => $_REQUEST['discord_webhook_admin'],
|
||||||
|
// Debug
|
||||||
|
"debug_level" => $_REQUEST['debug_level'] ?? '1'
|
||||||
);
|
);
|
||||||
|
|
||||||
$db->setSettings($settings);
|
$db->setSettings($settings);
|
||||||
|
|
@ -201,6 +203,16 @@ function exec_ogp_module()
|
||||||
$ft->add_field('string','discord_webhook_main',@$row['discord_webhook_main']);
|
$ft->add_field('string','discord_webhook_main',@$row['discord_webhook_main']);
|
||||||
$ft->add_field('string','discord_webhook_admin',@$row['discord_webhook_admin']);
|
$ft->add_field('string','discord_webhook_admin',@$row['discord_webhook_admin']);
|
||||||
|
|
||||||
|
// Debug level
|
||||||
|
$debug_level_options = array(
|
||||||
|
'0' => get_lang('debug_off'),
|
||||||
|
'1' => get_lang('debug_fatal_only'),
|
||||||
|
'2' => get_lang('debug_errors_warnings'),
|
||||||
|
'3' => get_lang('debug_all'),
|
||||||
|
);
|
||||||
|
$ft->add_custom_field('debug_level',
|
||||||
|
create_drop_box_from_array($debug_level_options, 'debug_level', @$row['debug_level'] ?? '1', false));
|
||||||
|
|
||||||
// Add option to reset game server order to default
|
// Add option to reset game server order to default
|
||||||
$ft->add_field('checkbox','reset_game_server_order','0');
|
$ft->add_field('checkbox','reset_game_server_order','0');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue