From a0490e36731957196648c674cf5e8e4f1d7d292d Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 10 Nov 2018 20:44:23 +0100 Subject: [PATCH] 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. --- index.php | 29 +---------------- lib/BridgeList.php | 12 +++---- lib/Debug.php | 79 +++++++++++++++++++++++++++++++++++++++++++++- lib/contents.php | 2 +- lib/rssbridge.php | 1 + 5 files changed, 87 insertions(+), 36 deletions(-) diff --git a/index.php b/index.php index 7b41586c..d57de89b 100644 --- a/index.php +++ b/index.php @@ -1,31 +1,4 @@ Warning : Debug mode is active from any location, -make sure only you can access RSS-Bridge. +
Warning : Debug mode is active from any location, + make sure only you can access RSS-Bridge.
EOD; } else { $warning .= <<Warning : Debug mode is active from your IP address, -your requests will bypass the cache. +
Warning : Debug mode is active from your IP address, + your requests will bypass the cache.
EOD; } } diff --git a/lib/Debug.php b/lib/Debug.php index 7d1f498d..0429f7eb 100644 --- a/lib/Debug.php +++ b/lib/Debug.php @@ -1,8 +1,85 @@ getTime(); if($time !== false && (time() - $duration < $time) - && (!defined('DEBUG') || DEBUG !== true)) { // Contents within duration + && Debug::isEnabled()) { // Contents within duration $content = $cache->loadData(); } else { // Content not within duration $content = getContents($url, $header, $opts); diff --git a/lib/rssbridge.php b/lib/rssbridge.php index ac70580b..07812f2c 100644 --- a/lib/rssbridge.php +++ b/lib/rssbridge.php @@ -1,5 +1,6 @@