2018-11-10 20:03:03 +01:00
|
|
|
<?php
|
2022-07-01 15:10:30 +02:00
|
|
|
|
2018-11-10 20:03:03 +01:00
|
|
|
class Debug
|
|
|
|
{
|
2018-11-10 20:44:23 +01:00
|
|
|
/**
|
2023-06-02 20:22:09 +02:00
|
|
|
* Convenience function for Configuration::getConfig('system', 'enable_debug_mode')
|
2018-11-10 20:44:23 +01:00
|
|
|
*/
|
2023-06-02 20:22:09 +02:00
|
|
|
public static function isEnabled(): bool
|
2018-11-10 20:44:23 +01:00
|
|
|
{
|
2023-07-15 21:16:23 +02:00
|
|
|
$ip = $_SERVER['REMOTE_ADDR'] ?? 'x.y.z.1';
|
2023-06-02 20:22:09 +02:00
|
|
|
$enableDebugMode = Configuration::getConfig('system', 'enable_debug_mode');
|
|
|
|
$debugModeWhitelist = Configuration::getConfig('system', 'debug_mode_whitelist') ?: [];
|
|
|
|
if ($enableDebugMode && ($debugModeWhitelist === [] || in_array($ip, $debugModeWhitelist))) {
|
|
|
|
return true;
|
2018-11-10 20:44:23 +01:00
|
|
|
}
|
2023-06-02 20:22:09 +02:00
|
|
|
return false;
|
2018-11-10 20:44:23 +01:00
|
|
|
}
|
2018-11-10 20:03:03 +01:00
|
|
|
}
|