From 09bd0164ebc020a54b944b7326dcba496fb5d82c Mon Sep 17 00:00:00 2001 From: Minteck Date: Fri, 26 Aug 2022 22:29:23 +0200 Subject: idk when was the last commit so I'm making a new one - Violet Dawn --- app.php | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'app.php') diff --git a/app.php b/app.php index 0fae8cc..8889a38 100644 --- a/app.php +++ b/app.php @@ -24,30 +24,47 @@ if (in_array($toplevel, ["editor", "icons", "species", "uploads"])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php"; + } else { + header("Location: /?error=Page not found: " . strip_tags($pagename)) and die(); } } 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") { + $parts = explode("/", $_GET['_']); + + if (isset($parts[1]) && $parts[1] !== "-") { + if ($parts[1] === "unknown") { + if ($parts[0] === "cloudburst") { + header("Location: /unknown-cb"); + } else { + header("Location: /unknown-rd"); + } + } else { + header("Location: /" . $parts[1]); + } + + die(); + } + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.php"; } else { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) { header("Location: /-/" . $toplevel); } else { - $namesCloudburst = array_map(function ($i) { + $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) { + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)), "unknown-cb"]; + $namesRaindrops = [...array_map(function ($i) { return $i['name']; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)); + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)), "unknown-rd"]; - if (in_array($pagename, $namesCloudburst)) { - header("Location: /cloudburst/" . $pagename) and die(); - } else if (in_array($pagename, $namesRaindrops)) { - header("Location: /raindrops/" . $pagename) and die(); + if ((in_array($toplevel, $namesCloudburst) || in_array($toplevel, $namesRaindrops)) && $toplevel !== "unknown") { + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.php"; } else { - header("Location: /?error=Page not found: " . strip_tags($pagename)) and die(); + global $toplevel; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/short.php"; } } } -- cgit