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
|
<?php
$app = $GLOBALS["ColdHazeApp"] ?? 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);
$json_cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true);
$json_raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true);
$json_other = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true);
if (!isset($json_cloudburst)) $json_cloudburst = [];
if (!isset($json_raindrops)) $json_raindrops = [];
if (!isset($json_other)) $json_other = [];
$members = [...array_map(function ($i) {
$i["_system"] = "ynmuc";
return $i;
}, $json_cloudburst), ...array_map(function ($i) {
$i["_system"] = "gdapd";
return $i;
}, $json_raindrops), ...array_map(function ($i) use ($app) {
$i["_system"] = $app["other"]["id"];
return $i;
}, $json_other)];
foreach ($members as $member) {
if (!isset($travelling[$member["id"]])) {
$travelling[$member["id"]] = [
"travelling" => false,
"history" => []
];
@file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT)));
}
if (!isset($travelling[$member["id"]]["equestria"])) {
$travelling[$member["id"]]["equestria"] = false;
}
}
function withTravelers(array $members, string $system): array {
global $travelling;
global $app;
if ($system === $app["other"]["id"]) {
return $members;
} else {
return [
...array_map(function ($i) use ($system) {
$i['system'] = $system;
return $i;
}, array_filter($members, function ($i) use ($travelling) {
return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria']));
})),
...array_filter(array_map(function ($i) use ($system) {
$i['system'] = $system === "gdapd" ? "ynmuc" : "gdapd";
return $i;
}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true)), function ($i) use ($travelling) {
return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria']);
})
];
}
}
|