aboutsummaryrefslogtreecommitdiff
path: root/lib/html.php
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2023-06-02 20:22:09 +0200
committerGravatar GitHub <noreply@github.com> 2023-06-02 20:22:09 +0200
commitee498eadf93a1e5ffdc7932ed1519c875eadcd7d (patch)
tree0e0aa312bafc4de6ee0f1d9b496114563c2cc69b /lib/html.php
parentc5cd2294456c6a118885003f7beb6f32bb98bc68 (diff)
downloadrss-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.php33
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);
}