3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly") { if (str_contains($parts[0], "/")) { return explode("/", $parts[0])[0]; } else { return $parts[0]; } } else { return $name; } } } if (!function_exists("getSystemMember")) { function getSystemMember(string $system, string $id) { $systemID = $system; $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); $member = null; foreach ($members as $m) { if ($m["id"] === $id) $member = $m; } return $member; } } if (!function_exists("showMembersFromList")) { function showMembersFromList(array $list) { foreach ($list as $member) { if ($member['name'] !== "unknown" && $member['name'] !== "fusion") { echo('
' . ($member['display_name'] ?? $member['name']) . '
' . ($member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
'); }} } } if (!function_exists("showSubsystem")) { function showSubsystem(array $data, string $parentSystem) { $subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$parentSystem-subsystem-$data[source].json"), true); echo('
'); echo('
'); showMembersFromList(scoreOrder(array_map(function ($i) use ($parentSystem) { return getSystemMember($parentSystem, $i); }, $data["members"]), $parentSystem)); echo('
'); } } if (!function_exists("showSystem")) { function showSystem(string $id, string $name, string $color, bool $hideTitle) { global $travelling; $global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id-general.json"), true); if ($hideTitle) { echo('
'); } else { echo('
'); } if (!$hideTitle) echo('

' . $name . '
'); if ($hideTitle) { echo('
'); } else { echo('
'); } showMembersFromList(scoreOrder([...array_map(function ($i) use ($id) { $i["travelling"] = false; $i["system"] = $id; return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id-members.json"), true), function ($i) use ($travelling) { return !$travelling[$i['id']]['travelling']; })), ...array_map(function ($i) use ($id) { $i["travelling"] = true; $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), function ($i) use ($travelling) { return $travelling[$i['id']]['travelling']; }))], $id)); echo('
'); } } if (!function_exists("cloudburst")) { function cloudburst(bool $hideTitle): void { showSystem("ynmuc", "Cloudburst System", "#5f08a9a6", $hideTitle); } } if (!function_exists("raindrops")) { function raindrops(bool $hideTitle): void { showSystem("gdapd", "Raindrops System", "#a95f08a6", $hideTitle); } } if (!function_exists("getMember")) { function getMember(string $id) { global $systemID; $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); $member = null; foreach ($members as $m) { if ($m["id"] === $id) $member = $m; } return $member; } } if (!function_exists("timeAgo")) { function timeAgo($time): string { if (!is_numeric($time)) { $time = strtotime($time); } $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); $now = time(); $difference = $now - $time; if ($difference <= 10 && $difference >= 0) { return $tense = "now"; } elseif ($difference > 0) { $tense = "ago"; } else { $tense = "later"; } for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); $period = $periods[$j] . ($difference >1 ? "s" :''); return "{$difference} {$period} {$tense}"; } } if (!function_exists("getMemberSystem")) { function getMemberSystem(string $id) { $list = scoreOrderGlobal(); foreach ($list as $item) { if ($item["id"] === $id) return $item["_system"]; } } } if (!function_exists("getMemberFromName")) { function getMemberFromName(string $name) { $list = [...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), ...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)]; foreach ($list as $item) { if ($item["name"] === $name) return $item; } } } if (!function_exists("resolveMember")) { function resolveMember(mixed $name) { if (is_string($name)) { if (str_ends_with($name, "-travelling")) { return substr($name, 0, strlen($name) - 11); } else { return $name; } } else { return $name; } } }