summaryrefslogtreecommitdiff
path: root/includes/util/score.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/util/score.inc')
-rw-r--r--includes/util/score.inc24
1 files changed, 11 insertions, 13 deletions
diff --git a/includes/util/score.inc b/includes/util/score.inc
index 622f057..c7d47de 100644
--- a/includes/util/score.inc
+++ b/includes/util/score.inc
@@ -1,12 +1,13 @@
<?php
function scoreOrder($members, $system, $useDominant = false) {
+ global $defaultMember;
global $isLowerLoggedIn;
global $isLoggedIn;
$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 ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling")) {
if (isset($member["color"])) {
if ($useDominant) {
$rgb = [
@@ -28,14 +29,13 @@ function scoreOrder($members, $system, $useDominant = false) {
$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["_metadata"] = parseMetadata(json_decode(file_get_contents_or_defaults($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json", $defaultMember), true));
$member["_score"] = $hsl[0];
if (!isset($member["_metadata"]["private"]) || !$member["_metadata"]["private"] || $isLoggedIn || $isLowerLoggedIn) {
@@ -52,13 +52,14 @@ function scoreOrder($members, $system, $useDominant = false) {
}
function scoreOrderGlobal() {
+ global $defaultMember;
global $isLowerLoggedIn;
global $isLoggedIn;
$ordered = [];
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/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 ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
@@ -71,13 +72,12 @@ function scoreOrderGlobal() {
$rgb[2]
);
} else {
- $rgb = [255, 255, 255];
$hsl = rgbToHsl(255, 255, 255);
}
$member["_score"] = $hsl[0];
$member["_system"] = "hrbom";
$member["system"] = "hrbom";
- $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true));
+ $member["_metadata"] = parseMetadata(json_decode(file_get_contents_or_defaults($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json", $defaultMember), true));
if (!isset($member["_metadata"]["private"]) || !$member["_metadata"]["private"] || $isLoggedIn || $isLowerLoggedIn) {
$ordered[] = $member;
@@ -86,7 +86,7 @@ function scoreOrderGlobal() {
}
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 ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
@@ -99,13 +99,12 @@ function scoreOrderGlobal() {
$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));
+ $member["_metadata"] = parseMetadata(json_decode(file_get_contents_or_defaults($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json", $defaultMember), true));
if (!isset($member["_metadata"]["private"]) || !$member["_metadata"]["private"] || $isLoggedIn || $isLowerLoggedIn) {
$ordered[] = $member;
@@ -116,7 +115,7 @@ function scoreOrderGlobal() {
if ($isLowerLoggedIn || $isLoggedIn) {
$app = $GLOBALS["ColdHazeApp"] ?? 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 ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling")) {
if (isset($member["color"])) {
$rgb = [
hexdec(substr($member["color"], 0, 2)),
@@ -129,13 +128,12 @@ function scoreOrderGlobal() {
$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));
+ $member["_metadata"] = parseMetadata(json_decode(file_get_contents_or_defaults($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json", $defaultMember), true));
$ordered[] = $member;
}
}
@@ -146,4 +144,4 @@ function scoreOrderGlobal() {
});
return array_values($ordered);
-} \ No newline at end of file
+}