From a2df9a69dcc14cb70118cda2ded499055e7ee358 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 21 Aug 2022 17:31:56 +0200 Subject: m. update --- app.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'app.php') diff --git a/app.php b/app.php index 79ed008..0fae8cc 100644 --- a/app.php +++ b/app.php @@ -18,11 +18,37 @@ if (in_array($toplevel, ["editor", "icons", "species", "uploads"])) { } elseif ($toplevel === "") { require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/home.php"; } else { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php"; + if ($toplevel === "-") { + $pagename = substr($pagename, 2); + $toplevel = explode("/", $pagename)[0]; + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php"; + } + } else if ($toplevel === "api") { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php"; + } } else if ($toplevel === "cloudburst" || $toplevel === "raindrops") { require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.php"; } else { - header("Location: /?error=Page not found: " . strip_tags($pagename)) and die(); + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { + header("Location: /-/" . $toplevel); + } else { + $namesCloudburst = array_map(function ($i) { + return $i['name']; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)); + $namesRaindrops = array_map(function ($i) { + return $i['name']; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)); + + if (in_array($pagename, $namesCloudburst)) { + header("Location: /cloudburst/" . $pagename) and die(); + } else if (in_array($pagename, $namesRaindrops)) { + header("Location: /raindrops/" . $pagename) and die(); + } else { + header("Location: /?error=Page not found: " . strip_tags($pagename)) and die(); + } + } } } \ No newline at end of file -- cgit