diff options
author | 2023-06-02 20:22:09 +0200 | |
---|---|---|
committer | 2023-06-02 20:22:09 +0200 | |
commit | ee498eadf93a1e5ffdc7932ed1519c875eadcd7d (patch) | |
tree | 0e0aa312bafc4de6ee0f1d9b496114563c2cc69b /lib/html.php | |
parent | c5cd2294456c6a118885003f7beb6f32bb98bc68 (diff) | |
download | rss-bridge-ee498eadf93a1e5ffdc7932ed1519c875eadcd7d.tar.gz rss-bridge-ee498eadf93a1e5ffdc7932ed1519c875eadcd7d.tar.zst rss-bridge-ee498eadf93a1e5ffdc7932ed1519c875eadcd7d.zip |
fix: move debug mode to config (#3324)
* fix: move debug mode to config
* fix: also move debug_whitelist to .ini config
* fix: move logic back to Debug class
* docs
* docs
* fix: disable debug mode by default
* fix: restore previous behavior for alerts
* fix: center-align alert text
Diffstat (limited to 'lib/html.php')
-rw-r--r-- | lib/html.php | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/html.php b/lib/html.php index 7f4f1201..ca0a411c 100644 --- a/lib/html.php +++ b/lib/html.php @@ -1,23 +1,34 @@ <?php /** - * This file is part of RSS-Bridge, a PHP project capable of generating RSS and - * Atom feeds for websites that don't have one. - * - * For the full license information, please view the UNLICENSE file distributed - * with this source code. - * - * @package Core - * @license http://unlicense.org/ UNLICENSE - * @link https://github.com/rss-bridge/rss-bridge + * Render template using base.html.php as base */ - function render(string $template, array $context = []): string { if ($template === 'base.html.php') { throw new \Exception('Do not render base.html.php into itself'); } - $context['system_message'] = Configuration::getConfig('system', 'message'); + $context['messages'] = $context['messages'] ?? []; + if (Configuration::getConfig('system', 'message')) { + $context['messages'][] = [ + 'body' => Configuration::getConfig('system', 'message'), + 'level' => 'info', + ]; + } + if (Debug::isEnabled()) { + $debugModeWhitelist = Configuration::getConfig('system', 'debug_mode_whitelist') ?: []; + if ($debugModeWhitelist === []) { + $context['messages'][] = [ + 'body' => 'Warning : Debug mode is active from any location, make sure only you can access RSS-Bridge.', + 'level' => 'error' + ]; + } else { + $context['messages'][] = [ + 'body' => 'Warning : Debug mode is active from your IP address, your requests will bypass the cache.', + 'level' => 'warning' + ]; + } + } $context['page'] = render_template($template, $context); return render_template('base.html.php', $context); } |