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
|
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
global $isLoggedIn; global $isLowerLoggedIn;
$isLoggedIn = false; $isLowerLoggedIn = false;
$list = scoreOrderGlobal();
function getAge($metadata) {
if (!isset($metadata["birth"]["year"]) || $metadata["birth"]["age"] > 0) {
if ($metadata["birth"]["age"] === -1) {
$age = " - Eternal";
} elseif ($metadata["birth"]["age"] <= 0) {
$age = "";
} else {
$age = " - " . ($metadata["birth"]["age"]);
}
} else {
if ($metadata["birth"]["year"] <= 1900) {
$age = "";
} else {
$age = " - " . ((int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1));
}
}
return $age;
}
header("Content-Type: application/json");
die(json_encode(array_map(function ($i) {
return [
"id" => $i["id"],
"name" => $i["display_name"] ?? $i["name"],
"system" => $i["system"],
"pronouns" => $i["pronouns"],
"species" => match ($i["_metadata"]["species"][0]) {
"earth" => $i["_metadata"]["robot"] ? "Robot earth pony" : (!$i["_metadata"]["plush"] ? "Earth pony" : "Earth pony plush"),
"alicorn" => $i["_metadata"]["robot"] ? "Robot alicorn" : (!$i["_metadata"]["plush"] ? "Alicorn" : "Alicorn plush"),
"crystal" => $i["_metadata"]["robot"] ? "Robot crystal pony" : (!$i["_metadata"]["plush"] ? "Crystal pony" : "Crystal pony plush"),
"pegasus" => $i["_metadata"]["robot"] ? "Robot pegasus" : (!$i["_metadata"]["plush"] ? "Pegasus" : "Pegasus plush"),
"batpony" => $i["_metadata"]["robot"] ? "Robot bat pony" : (!$i["_metadata"]["plush"] ? "Bat pony" : "Bat pony plush"),
"unicorn" => $i["_metadata"]["robot"] ? "Robot unicorn" : (!$i["_metadata"]["plush"] ? "Unicorn" : "Unicorn plush"),
"changeling" => "Changeling",
"human" => "Human",
"merpony" => "Merpony",
default => $i["_metadata"]["species"][0] . "_" . $i["_metadata"]["robot"]
},
"age" => getAge($i["_metadata"]),
"avatar" => "https://ponies.equestria.horse" . getAsset($i["system"], $i["id"], "heads")
];
}, $list), JSON_PRETTY_PRINT));
|