[index] Simplify debug mode detection

This removes superfluous variables and if-statements when checking
whether the debug mode is active or not.
This commit is contained in:
logmanoriginal 2017-08-05 15:35:47 +02:00
parent f19d34a5a1
commit f2d02a4187
1 changed files with 9 additions and 14 deletions

View File

@ -30,23 +30,18 @@ define('WHITELIST_FILE', __DIR__ . '/whitelist.txt');
/* /*
Create a file named 'DEBUG' for enabling debug mode. Create a file named 'DEBUG' for enabling debug mode.
For further security, you may put whitelisted IP addresses For further security, you may put whitelisted IP addresses in the file,
in the 'DEBUG' file, one IP per line. Empty file allows anyone(!). one IP per line. Empty file allows anyone(!).
Debugging allows displaying PHP error messages and bypasses the cache: this can allow a malicious Debugging allows displaying PHP error messages and bypasses the cache: this
client to retrieve data about your server and hammer a provider throught your rss-bridge instance. can allow a malicious client to retrieve data about your server and hammer
a provider throught your rss-bridge instance.
*/ */
if(file_exists('DEBUG')) { if(file_exists('DEBUG')) {
$debug_enabled = true;
$debug_whitelist = trim(file_get_contents('DEBUG')); $debug_whitelist = trim(file_get_contents('DEBUG'));
if(strlen($debug_whitelist) > 0) {
$debug_enabled = false; $debug_enabled = empty($debug_whitelist)
foreach(explode("\n", $debug_whitelist) as $allowed_ip) { || in_array($_SERVER['REMOTE_ADDR'], explode("\n", $debug_whitelist));
if(trim($allowed_ip) === $_SERVER['REMOTE_ADDR']) {
$debug_enabled = true;
break;
}
}
}
if($debug_enabled) { if($debug_enabled) {
ini_set('display_errors', '1'); ini_set('display_errors', '1');
error_reporting(E_ALL); error_reporting(E_ALL);