From 23b96a3942555f2a4640f861c15e24c80a5c0e9e Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 15 Feb 2024 10:19:52 +0100 Subject: [PATCH] Create sitemap --- index.php | 3 ++- lib/router.php | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index e0eebf8..3e03a20 100644 --- a/index.php +++ b/index.php @@ -20,7 +20,8 @@ if (!isLoggedIn()) { if($routerRequest["site_name"] == "sitemap.xml") { require "lib/sitemap.php"; - return generateSitemap(); + echo generateSitemap(); + exit(); } if ($routerRequest["type"] == "api") { diff --git a/lib/router.php b/lib/router.php index 2a74b0d..5814c00 100644 --- a/lib/router.php +++ b/lib/router.php @@ -12,15 +12,16 @@ function initRouter(): array $request_uri = array_slice($request_uri, -3, 3); - $routerRequest["site_name"] = basename($request_uri[1]); - $routerRequest["page_name"] = basename($request_uri[2]); - if (empty($routerRequest["site_name"])) { - $routerRequest["site_name"] = $routerConfig["default_site"]; + $routerRequest["site_name"] = $routerConfig["default_site"]; + $routerRequest["page_name"] = $routerConfig["default_page"]; + + if(count($request_uri > 2)){ + $routerRequest["page_name"] = basename($request_uri[2]); } + if(count($request_uri) > 1){ + $routerRequest["site_name"] = basename($request_uri[1]); - if (empty($routerRequest["page_name"])) { - $routerRequest["page_name"] = $routerConfig["default_page"]; } if($_SERVER["REQUEST_METHOD"] == "POST"){