summaryrefslogtreecommitdiff
path: root/pages/metadata.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/metadata.inc')
-rw-r--r--pages/metadata.inc40
1 files changed, 13 insertions, 27 deletions
diff --git a/pages/metadata.inc b/pages/metadata.inc
index 0a987f3..db5589d 100644
--- a/pages/metadata.inc
+++ b/pages/metadata.inc
@@ -1,23 +1,10 @@
<?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 $isLowerLoggedIn; global $isLoggedIn; global $lang; global $pages; global $app;
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc";
-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);
@@ -25,12 +12,10 @@ array_shift($parts);
$system = $parts[0];
$member = !isset($parts[1]) || $parts[1] === "" ? null : $parts[1];
-if ($system !== "cloudburst" && $system !== "raindrops" && $system !== $app["other"]["slug"]) header("Location: /?error=Invalid system name: " . $system) and die();
+if ($system !== "cloudburst" && $system !== "raindrops" && $system !== $app["other"]["slug"]) peh_error("Invalid system name: " . $system, 400);
$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : ($system === $app["other"]["slug"] ? $app["other"]["name"] : "Raindrops System");
$systemID = $system === "cloudburst" ? "ynmuc" : ($system === $app["other"]["slug"] ? $app["other"]["id"] : "gdapd");
-$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID.json"), true) ?? [];
-
if ($isLowerLoggedIn && $systemID !== $app["other"]["id"]) {
header("Location: /");
die();
@@ -40,7 +25,6 @@ if ($member === null) {
header("Location: /");
die();
} else {
- $isSubsystem = false;
$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true);
$memberData = null;
$memberCommonName = null;
@@ -55,7 +39,7 @@ if ($member === null) {
}
if ($memberData === null) {
- header("Location: /?error=Not found") and die();
+ peh_error("Not found", 404);
}
if (isset($_GET["submit"])) {
@@ -111,27 +95,29 @@ if ($member === null) {
$toUpdate["interest"] = strip_tags($_GET["interest"]);
}
+ $regex = "/^(ynmuc|gdapd|" . $app["other"]["id"] . ")\/[a-z]{5}$/m";
+
if (isset($_GET["marefriends"])) {
- $toUpdate["marefriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["marefriends"])), function ($i) {
- return !!preg_match("/^(ynmuc|gdapd)\/[a-z]{5}$/m", $i);
+ $toUpdate["marefriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["marefriends"])), function ($i) use ($regex) {
+ return !!preg_match($regex, $i);
}));
}
if (isset($_GET["sexfriends"])) {
- $toUpdate["sexfriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sexfriends"])), function ($i) {
- return !!preg_match("/^(ynmuc|gdapd)\/[a-z]{5}$/m", $i);
+ $toUpdate["sexfriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sexfriends"])), function ($i) use ($regex) {
+ return !!preg_match($regex, $i);
}));
}
if (isset($_GET["sisters"])) {
- $toUpdate["sisters"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sisters"])), function ($i) {
- return !!preg_match("/^(ynmuc|gdapd)\/[a-z]{5}$/m", $i);
+ $toUpdate["sisters"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sisters"])), function ($i) use ($regex) {
+ return !!preg_match($regex, $i);
}));
}
if (isset($_GET["caretakers"])) {
- $toUpdate["caretakers"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["caretakers"])), function ($i) {
- return !!preg_match("/^(ynmuc|gdapd)\/[a-z]{5}$/m", $i);
+ $toUpdate["caretakers"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["caretakers"])), function ($i) use ($regex) {
+ return !!preg_match($regex, $i);
}));
}