From 8cc1f13c17fa2fb5a4410542d39e650e02945634 Mon Sep 17 00:00:00 2001
From: Minteck <contact@minteck.org>
Date: Thu, 23 Feb 2023 14:20:13 +0100
Subject: Updated 27 files, added assets/uploads/pt-twilightsparkle.png and
 deleted 3 files (automated)

---
 pages/page.inc | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

(limited to 'pages/page.inc')

diff --git a/pages/page.inc b/pages/page.inc
index f3859d3..3bdeb2e 100644
--- a/pages/page.inc
+++ b/pages/page.inc
@@ -1,19 +1,28 @@
 <?php
 
-global $lang; global $pages;
+global $lang; global $pages; global $isLoggedIn; global $isLowerLoggedIn;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
 
 $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);
 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] === "-")) {
+if (($parts[0] !== "cloudburst" && $parts[0] !== "raindrops" && $parts[0] !== $app["other"]["slug"]) && (!(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"];
+    $namesOther = [];
+
+    if ($isLoggedIn || $isLowerLoggedIn) {
+        $namesOther = [...array_map(function ($i) {
+            return $i['name'];
+        }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true)), $app["other"]["unknown"]];
+    }
 
     $parts = explode("/", $_GET['_']);
     array_unshift($parts, "");
@@ -23,17 +32,19 @@ if (($parts[0] !== "cloudburst" && $parts[0] !== "raindrops") && (!(count($parts
         $parts[0] = "cloudburst";
     } else if (in_array($parts[1], $namesRaindrops)) {
         $parts[0] = "raindrops";
+    } else if (in_array($parts[1], $namesOther) && ($isLoggedIn || $isLowerLoggedIn)) {
+        $parts[0] = $app["other"]["slug"];
     }
 
-    if ($parts[1] === "unknown-rd" || $parts[1] === "unknown-cb") $parts[1] = "unknown";
+    if ($parts[1] === "unknown-rd" || $parts[1] === "unknown-cb" || (($isLoggedIn || $isLowerLoggedIn) && $parts[1] === $app["other"]["slug"])) $parts[1] = "unknown";
 }
 
 $system = $parts[0];
 $member = (isset($parts[1]) ? $parts[1] : null) === "" ? null : (isset($parts[1]) ? $parts[1] : null);
 
-if ($system !== "cloudburst" && $system !== "raindrops") header("Location: /?error=" . $lang["page"]["system"]) and die();
-$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
-$systemID = $system === "cloudburst" ? "ynmuc" : "gdapd";
+if ($system !== "cloudburst" && $system !== "raindrops" && ($system !== $app["other"]["slug"] && !$isLowerLoggedIn && !$isLoggedIn)) header("Location: /?error=" . $lang["page"]["system"]) and die();
+$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : ($system === $app["other"]["slug"] && ($isLoggedIn || $isLowerLoggedIn) ? $app["other"]["name"] : "Raindrops System");
+$systemID = $system === "cloudburst" ? "ynmuc" : ($system === $app["other"]["slug"] && ($isLoggedIn || $isLowerLoggedIn) ? $app["other"]["id"] : "gdapd");
 
 if ($member === null) {
     global $_SystemName;
@@ -53,7 +64,7 @@ if ($member === null) {
     $memberFoundInAnotherSystem = false;
     $traveller = false;
 
-    $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true);
+    $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === $app["other"]["id"] ? "other" : $systemID) . "/members.json"), true);
     $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true);
     $memberData = null;
     $memberCommonName = null;
-- 
cgit