From 61d23cd8c2ce523c22f14b36c44cf1a489175370 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Thu, 17 Apr 2025 10:36:45 +0300 Subject: [PATCH] Lets plugins add themselves to the public pages --- public_html/index.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public_html/index.php b/public_html/index.php index ecb2a61..60d539e 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -157,6 +157,17 @@ $app_root = $config['folder']; // List of pages that don't require authentication $public_pages = ['login', 'help', 'about']; +// Let plugins filter/extend public_pages +function filter_public_pages($pages) { + if (!empty($GLOBALS['plugin_hooks']['filter_public_pages'])) { + foreach ($GLOBALS['plugin_hooks']['filter_public_pages'] as $callback) { + $pages = call_user_func($callback, $pages); + } + } + return $pages; +} +$public_pages = filter_public_pages($public_pages); + // Check if the requested page requires authentication if (!isset($_COOKIE['username']) && !$validSession && !in_array($page, $public_pages)) { require_once '../app/includes/session_middleware.php';