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