1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<?php
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['_']) === "") peh_error("Invalid request", 400);
$parts = explode("/", $_GET['_']);
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, "");
$parts = array_values($parts);
if (in_array($parts[1], $namesCloudburst)) {
$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" || (($isLoggedIn || $isLowerLoggedIn) && $parts[1] === $app["other"]["unknown"])) $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" && ($system !== $app["other"]["slug"] && !$isLowerLoggedIn && !$isLoggedIn)) peh_error("System not found", 404);
$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;
$_SystemName = $system;
$pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc';
} else if ($member === "-" && isset($parts[2])) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc')) {
global $_SystemPage;
$_SystemPage = $parts[2];
$pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc';
} else {
peh_error("System page not found: " . strip_tags($parts[2]), 404);
}
} else {
$memberFoundInAnotherSystem = false;
$traveller = false;
$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;
$memberID = null;
foreach ($members as $m) {
if ($m['name'] === $member) {
$memberData = $m;
$memberCommonName = $m['display_name'] ?? $m['name'];
$memberID = $m['id'];
}
}
foreach ($members2 as $m) {
if ($m['name'] === $member && $travelling[$m['id']]['travelling']) {
$traveller = true;
$memberData = $m;
$memberCommonName = $m['display_name'] ?? $m['name'];
$memberID = $m['id'];
$system = $systemID === "gdapd" ? "cloudburst" : "raindrops";
$systemID = $system === "cloudburst" ? "ynmuc" : "gdapd";
} else if ($m['name'] === $member) {
$memberFoundInAnotherSystem = true;
}
}
global $_SystemName;
$_SystemName = $system;
if (str_ends_with($member, "-travelling")) {
header("Location: /" . substr($member, 0, strlen($member) - 11)) and die();
}
if (isset($parts[2]) && $parts[2] === "-" && isset($parts[3])) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc')) {
global $_MemberPage;
$_MemberPage = $parts[3];
$pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc';
} else {
peh_error("Member page not found: " . strip_tags($parts[3]), 404);
}
die();
}
global $_MemberName;
$_MemberName = $member;
$pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc';
}
exit;
|