fix double ACTION define + undefined URI in template

This commit is contained in:
slawkens 2023-02-06 16:58:51 +01:00
parent 07a03c38b3
commit 35a660be7d

View File

@ -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