From 4eff9ddb730e496316d30487ea9b41a9da82d13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Fri, 2 Feb 2024 15:53:32 +0100 Subject: [PATCH] debug print --- lib/page.php | 1 + lib/router.php | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/page.php b/lib/page.php index 15107b4..f53bd8f 100644 --- a/lib/page.php +++ b/lib/page.php @@ -43,6 +43,7 @@ function getPage($page_name = null): array|false|string $dynamic_page_file = $routerConfig["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".php"; $page_file = $routerConfig["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".html"; + echo $page_file; $skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html"); $nav = file_get_contents($routerConfig["template_dir"] . "nav.html"); diff --git a/lib/router.php b/lib/router.php index 87cab8d..c408e96 100644 --- a/lib/router.php +++ b/lib/router.php @@ -16,19 +16,19 @@ function initRouter(): bool $routerRequest["domain"] = basename($routerRequest["requestAddress"][0]); $routerRequest["tld"] = basename($routerRequest["requestAddress"][1]); - } else { - $routerRequest["subdomain"] = basename($routerRequest["requestAddress"][0]); - $routerRequest["domain"] = basename($routerRequest["requestAddress"][1]); - $routerRequest["tld"] = basename($routerRequest["requestAddress"][2]); - - $routerRequest["page_name"] = basename($_SERVER["QUERY_STRING"]); - - if (empty($routerRequest["page_name"])) { - // Page name is empty - $needsRedirect = true; - $routerRequest["page_name"] = $routerConfig["default_page"]; - } } + $routerRequest["subdomain"] = basename($routerRequest["requestAddress"][0]); + $routerRequest["domain"] = basename($routerRequest["requestAddress"][1]); + $routerRequest["tld"] = basename($routerRequest["requestAddress"][2]); + + $routerRequest["page_name"] = basename($_SERVER["QUERY_STRING"]); + + if (empty($routerRequest["page_name"])) { + // Page name is empty + $needsRedirect = true; + $routerRequest["page_name"] = $routerConfig["default_page"]; + } + if ($needsRedirect) { $redirectAddress = $routerConfig["protocol"] .