summaryrefslogtreecommitdiff
path: root/pages/edit-private.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/edit-private.inc')
-rw-r--r--pages/edit-private.inc36
1 files changed, 4 insertions, 32 deletions
diff --git a/pages/edit-private.inc b/pages/edit-private.inc
index 9564f7a..4d89b5c 100644
--- a/pages/edit-private.inc
+++ b/pages/edit-private.inc
@@ -1,21 +1,8 @@
<?php
-function getSubsystemByID(string $id) {
- global $subsystems;
- $subsystem = null;
-
- foreach ($subsystems as $ss) {
- if ($ss["source"] === $id) {
- $subsystem = $ss;
- }
- }
-
- return $subsystem;
-}
-
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
-if (!isset($_GET['_']) || trim($_GET['_']) === "") header("Location: /?error=Invalid request") and die();
+if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400);
$parts = explode("/", $_GET['_']);
array_shift($parts);
@@ -23,16 +10,13 @@ array_shift($parts);
$system = $parts[0];
$member = ($parts[1] ?? null) === "" ? null : $parts[1];
-if ($system !== "cloudburst" && $system !== "raindrops") header("Location: /?error=Invalid system name: " . $system) and die();
+if ($system !== "cloudburst" && $system !== "raindrops") peh_error("Invalid system name: " . $system, 400);
$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
$systemID = $system === "cloudburst" ? "ynmuc" : "gdapd";
-$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID.json"), true) ?? [];
-
if ($member === null) {
- header("Location: /?error=Unsupported target: system") and die();
+ peh_error("Unsupported target: system", 500);
} else {
- $isSubsystem = false;
$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true);
$memberData = null;
$memberCommonName = null;
@@ -47,19 +31,7 @@ if ($member === null) {
}
if ($memberData === null) {
- if (in_array($member, array_map(function ($i) {
- return $i["source"];
- }, $subsystems))) {
- $isSubsystem = true;
- $subsystemID = $member;
- $subsystem = getSubsystemByID($subsystemID);
- $subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystem[source].json"), true);
- $subsystemCommonName = $subsystemData["name"] ?? $subsystemID;
-
- require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/subsysedit.inc';
- } else {
- header("Location: /?error=System member or subsystem not found") and die();
- }
+ peh_error("System member not found", 404);
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/edit-private.inc';