diff options
Diffstat (limited to 'includes/util')
-rw-r--r-- | includes/util/banner.inc | 30 | ||||
-rw-r--r-- | includes/util/functions.inc | 14 | ||||
-rw-r--r-- | includes/util/score.inc | 29 |
3 files changed, 68 insertions, 5 deletions
diff --git a/includes/util/banner.inc b/includes/util/banner.inc index aca1edb..944a701 100644 --- a/includes/util/banner.inc +++ b/includes/util/banner.inc @@ -1,5 +1,26 @@ <?php +function getAge($metadata) { + if (!isset($metadata["birth"]["year"]) || $metadata["birth"]["age"] > 0 || $metadata["birth"]["age"] === -1) { + if ($metadata["birth"]["age"] === -1) { + return "Eternal"; + } elseif ($metadata["birth"]["age"] <= 0) { + return "-"; + } elseif (is_numeric($metadata["birth"]["age"])) { + return $metadata["birth"]["age"] . "* years old"; + } + } else { + if ($metadata["birth"]["year"] <= 1900) { + return "-"; + } else { + $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1); + return $age . " years old"; + } + } + + return "-"; +} + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/pronouns.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; @@ -167,10 +188,10 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { $app = $GLOBALS["ColdHazeApp"]; $systemData = []; - $systemData['page'] = "/" . ($system === "gdapd" ? "raindrops" : ($system === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst")); + $systemData['page'] = "/" . ($system === "gdapd" ? "raindrops" : ($system === $app["other"]["id"] ? $app["other"]["slug"] : ($system === "hrbom" ? "moonglow" : "cloudburst"))); $systemData['icon'] = getAsset($system); - $systemData['name'] = $system === "gdapd" ? "Raindrops" : ($system === $app["other"]["id"] ? $app["other"]["short"] : "Cloudburst"); - $systemData['full_name'] = $system === "gdapd" ? "Raindrops System" : ($system === $app["other"]["id"] ? $app["other"]["name"] : "Cloudburst System"); + $systemData['name'] = $system === "gdapd" ? "Raindrops" : ($system === $app["other"]["id"] ? $app["other"]["short"] : ($system === "hrbom" ? "Moonglow" : "Cloudburst")); + $systemData['full_name'] = $system === "gdapd" ? "Raindrops System" : ($system === $app["other"]["id"] ? $app["other"]["name"] : ($system === "hrbom" ? "Moonglow" : "Cloudburst System")); $systemData['temporary'] = false; if ($travelling[$member['id']]["travelling"] && !$travelling[$member['id']]["equestria"]) { @@ -400,7 +421,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { 'median' => $metadata["median"], 'little' => $metadata["little"] >= 2, 'name' => $member["display_name"] ?? $member["name"], - 'gender' => isset($metadata["gender"]) && trim($metadata["gender"]) !== "" ? $Parsedown->text($metadata["gender"]) : "Agender", + 'gender' => isset($metadata["show_gender"]) && $metadata["show_gender"] ? (isset($metadata["gender"]) && trim($metadata["gender"]) !== "" ? $Parsedown->text($metadata["gender"]) : "Agender") : null, 'badges' => $badges, 'prefixes' => $prefixes, 'pronouns' => isset($member["pronouns"]) && trim($member["pronouns"]) !== "" ? $member["pronouns"] : "<i>they/them</i>", @@ -408,6 +429,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { 'last_fronted' => $lastFronted, 'species' => $speciesList, 'system' => $systemData, + 'age' => getAge($metadata), 'relations' => [ 'marefriends' => $marefriends ?? [], 'sexfriends' => $sexfriends ?? null, diff --git a/includes/util/functions.inc b/includes/util/functions.inc index 8a8c4f8..0cf15d2 100644 --- a/includes/util/functions.inc +++ b/includes/util/functions.inc @@ -316,6 +316,13 @@ if (!function_exists("getMemberWithoutSystem")) { if ($m["id"] === $id) $member = $m; } + $members3 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/members.json"), true); + foreach ($members3 as $m) { + $m["_system"] = "hrbom"; + $m["system"] = "hrbom"; + if ($m["id"] === $id) $member = $m; + } + if ($isLowerLoggedIn || $isLoggedIn) { $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); $members3 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true); @@ -419,13 +426,18 @@ if (!function_exists("cloudburst")) { } } - if (!function_exists("raindrops")) { function raindrops(bool $hideTitle): void { showSystem("gdapd", "Raindrops System", "#a95f08a6", $hideTitle); } } +if (!function_exists("moonglow")) { + function moonglow(bool $hideTitle): void { + showSystem("hrbom", "Moonglow", "#9064cca6", $hideTitle); + } +} + if (!function_exists("other")) { function other(bool $hideTitle): void { $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); diff --git a/includes/util/score.inc b/includes/util/score.inc index 9deacca..b70f866 100644 --- a/includes/util/score.inc +++ b/includes/util/score.inc @@ -56,6 +56,35 @@ function scoreOrderGlobal() { 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 (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"] = "hrbom"; + $member["system"] = "hrbom"; + $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + + if (!isset($member["_metadata"]["private"]) || !$member["_metadata"]["private"] || $isLoggedIn || $isLowerLoggedIn) { + $ordered[] = $member; + } + } + } + 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"])) { |