core: Add Debug::isEnabled() and Debug::isSecure()
Also adds documentation to Debug.php! * Debug::isEnabled() Checks if the DEBUG file exists on disk on the first call (stored in memory for the duration of the instance). Returns true if debug mode is enabled for the client. This function also sets the internal flag for Debug::isSecure()! * Debug::isSecure() Returns true if debuging is enabled for specific IP addresses, false otherwise. This is checked on the first call of Debug::isEnabled(). If you call this function before Debug::isEnabled(), the default value is false.
This commit is contained in:
parent
c63af2e7ad
commit
a0490e3673
5 changed files with 87 additions and 36 deletions
29
index.php
29
index.php
|
@ -1,31 +1,4 @@
|
|||
<?php
|
||||
/*
|
||||
Create a file named 'DEBUG' for enabling debug mode.
|
||||
For further security, you may put whitelisted IP addresses in the file,
|
||||
one IP per line. Empty file allows anyone(!).
|
||||
Debugging allows displaying PHP error messages and bypasses the cache: this
|
||||
can allow a malicious client to retrieve data about your server and hammer
|
||||
a provider throught your rss-bridge instance.
|
||||
*/
|
||||
if(file_exists('DEBUG')) {
|
||||
$debug_whitelist = trim(file_get_contents('DEBUG'));
|
||||
|
||||
$debug_enabled = empty($debug_whitelist)
|
||||
|| in_array($_SERVER['REMOTE_ADDR'],
|
||||
explode("\n", str_replace("\r", '', $debug_whitelist)
|
||||
)
|
||||
);
|
||||
|
||||
if($debug_enabled) {
|
||||
ini_set('display_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
define('DEBUG', true);
|
||||
if (empty($debug_whitelist)) {
|
||||
define('DEBUG_INSECURE', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/lib/rssbridge.php';
|
||||
|
||||
Configuration::verifyInstallation();
|
||||
|
@ -221,7 +194,7 @@ try {
|
|||
|
||||
if($mtime !== false
|
||||
&& (time() - $cache_timeout < $mtime)
|
||||
&& (!defined('DEBUG') || DEBUG !== true)) { // Load cached data
|
||||
&& !Debug::isEnabled()) { // Load cached data
|
||||
|
||||
// Send "Not Modified" response if client supports it
|
||||
// Implementation based on https://stackoverflow.com/a/10847262
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue