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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
<?php
function scoreOrder($members, $system, $useDominant = false) {
$ordered = [];
foreach ($members as $member) {
if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) {
if (isset($member["color"])) {
if ($useDominant) {
$rgb = [
hexdec(substr($member["dominant_color"] ?? $member["color"], 0, 2)),
hexdec(substr($member["dominant_color"] ?? $member["color"], 2, 2)),
hexdec(substr($member["dominant_color"] ?? $member["color"], 4, 2))
];
} else {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
hexdec(substr($member["color"], 2, 2)),
hexdec(substr($member["color"], 4, 2))
];
}
$hsl = rgbToHsl(
$rgb[0],
$rgb[1],
$rgb[2]
);
} else {
$rgb = [255, 255, 255];
$hsl = rgbToHsl(255, 255, 255);
}
$systemID = $member["system"] ?? $system;
$member["_system"] = $member["system"] = $systemID;
$member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true));
$member["_score"] = $hsl[0];
$ordered[] = $member;
}
}
uasort($ordered, function($a, $b) {
return $a["_score"] - $b["_score"];
});
return $ordered;
}
function scoreOrderGlobal() {
global $isLowerLoggedIn;
global $isLoggedIn;
$ordered = [];
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) {
if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
hexdec(substr($member["color"], 2, 2)),
hexdec(substr($member["color"], 4, 2))
];
$hsl = rgbToHsl(
$rgb[0],
$rgb[1],
$rgb[2]
);
} else {
$rgb = [255, 255, 255];
$hsl = rgbToHsl(255, 255, 255);
}
$member["_score"] = $hsl[0];
$member["_system"] = "gdapd";
$member["system"] = "gdapd";
$member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true));
$ordered[] = $member;
}
}
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) {
if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
hexdec(substr($member["color"], 2, 2)),
hexdec(substr($member["color"], 4, 2))
];
$hsl = rgbToHsl(
$rgb[0],
$rgb[1],
$rgb[2]
);
} else {
$rgb = [255, 255, 255];
$hsl = rgbToHsl(255, 255, 255);
}
$member["_score"] = $hsl[0];
$member["_system"] = "ynmuc";
$member["system"] = "ynmuc";
$member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true));
$ordered[] = $member;
}
}
if ($isLowerLoggedIn || $isLoggedIn) {
$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true) as $member) {
if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
hexdec(substr($member["color"], 2, 2)),
hexdec(substr($member["color"], 4, 2))
];
$hsl = rgbToHsl(
$rgb[0],
$rgb[1],
$rgb[2]
);
} else {
$rgb = [255, 255, 255];
$hsl = rgbToHsl(255, 255, 255);
}
$member["_score"] = $hsl[0];
$member["_system"] = $app["other"]["id"];
$member["system"] = $app["other"]["id"];
$member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true));
$ordered[] = $member;
}
}
}
uasort($ordered, function($a, $b) {
return $a["_score"] - $b["_score"];
});
return array_values($ordered);
}
|