diff options
Diffstat (limited to 'pages/page.php')
-rw-r--r-- | pages/page.php | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/pages/page.php b/pages/page.php index 00622b3..a00a0f1 100644 --- a/pages/page.php +++ b/pages/page.php @@ -4,6 +4,28 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ if (!isset($_GET['_']) || trim($_GET['_']) === "") header("Location: /?error=Invalid request") and die(); $parts = explode("/", $_GET['_']); + +if (($parts[0] !== "cloudburst" && $parts[0] !== "raindrops") && (!(count($parts) > 2) || $parts[1] === "-")) { + $namesCloudburst = [...array_map(function ($i) { + return $i['name']; + }, 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)), "unknown-rd"]; + + $parts = explode("/", $_GET['_']); + array_unshift($parts, ""); + $parts = array_values($parts); + + if (in_array($parts[1], $namesCloudburst)) { + $parts[0] = "cloudburst"; + } else if (in_array($parts[1], $namesRaindrops)) { + $parts[0] = "raindrops"; + } + + if ($parts[1] === "unknown-rd" || $parts[1] === "unknown-cb") $parts[1] = "unknown"; +} + $system = $parts[0]; $member = ($parts[1] ?? null) === "" ? null : $parts[1]; @@ -12,12 +34,16 @@ $systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops $systemID = $system === "cloudburst" ? "ynmuc" : "gdapd"; if ($member === null) { + global $_SystemName; + $_SystemName = $system; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system.php'; } else if ($member === "-" && isset($parts[2])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.php')) { + global $_SystemPage; + $_SystemPage = $parts[2]; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.php'; } else { - header("Location: /?error=Page not found") and die(); + header("Location: /?error=Page not found: " . $parts[2]) and die(); } } else { $memberFoundInAnotherSystem = false; @@ -44,25 +70,32 @@ if ($member === null) { $memberCommonName = $m['display_name'] ?? $m['name']; $memberID = $m['id']; $system = $systemID === "gdapd" ? "cloudburst" : "raindrops"; - $systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System"; $systemID = $system === "cloudburst" ? "ynmuc" : "gdapd"; } else if ($m['name'] === $member) { $memberFoundInAnotherSystem = true; } } - if ($memberData === null) { - if ($memberFoundInAnotherSystem) { - header("Location: /" . ($systemID === "gdapd" ? "cloudburst" : "raindrops") . "/" . $member) and die(); - } else { - header("Location: /?error=System member not found") and die(); - } + global $_SystemName; + $_SystemName = $system; + + if (str_ends_with($member, "-travelling")) { + header("Location: /" . substr($member, 0, strlen($member) - 11)) and die(); } - if ($travelling[$memberID]['travelling'] && !$traveller) { - header("Location: /" . ($systemID === "gdapd" ? "cloudburst" : "raindrops") . "/" . $member) and die(); + if (isset($parts[2]) && $parts[2] === "-" && isset($parts[3])) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.php')) { + global $_MemberPage; + $_MemberPage = $parts[3]; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.php'; + } else { + header("Location: /?error=Page not found: " . $parts[3]) and die(); + } + die(); } + global $_MemberName; + $_MemberName = $member; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member.php'; } |