From 35a660be7d852e2414556df4a119bcae93b16170 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 6 Feb 2023 16:58:51 +0100 Subject: [PATCH] fix double ACTION define + undefined URI in template --- system/router.php | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/system/router.php b/system/router.php index 52be68e5..d315f099 100644 --- a/system/router.php +++ b/system/router.php @@ -36,11 +36,29 @@ if(fetchDatabaseConfig('site_closed', $site_closed)) { } define('SITE_CLOSED', $site_closed); +// Strip query string (?foo=bar) and decode URI +/** @var string $uri */ +if (false !== $pos = strpos($uri, '?')) { + if ($pos !== 1) { + $uri = substr($uri, 0, $pos); + } + else { + $uri = str_replace_first('?', '', $uri); + } +} + +$uri = rawurldecode($uri); +if (BASE_DIR !== '') { + $tmp = str_replace_first('/', '', BASE_DIR); + $uri = str_replace_first($tmp . '/', '', $uri); +} + +define('URI', $uri); + /** @var boolean $load_it */ if(!$load_it) { // ignore warnings in some functions/plugins // page is not loaded anyways - define('ACTION', ''); define('PAGE', ''); return; @@ -116,25 +134,6 @@ $dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) // Fetch method and URI $httpMethod = $_SERVER['REQUEST_METHOD']; -// Strip query string (?foo=bar) and decode URI -/** @var string $uri */ -if (false !== $pos = strpos($uri, '?')) { - if ($pos !== 1) { - $uri = substr($uri, 0, $pos); - } - else { - $uri = str_replace_first('?', '', $uri); - } -} - -$uri = rawurldecode($uri); -if (BASE_DIR !== '') { - $tmp = str_replace_first('/', '', BASE_DIR); - $uri = str_replace_first($tmp . '/', '', $uri); -} - -define('URI', $uri); - $found = true; // old support for pages like /?subtopic=accountmanagement