diff options
author | Minteck <contact@minteck.org> | 2022-10-10 20:51:39 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-10 20:51:39 +0200 |
commit | 108525534c28013cfe1897c30e4565f9893f3766 (patch) | |
tree | dd3e5132971f96ab5f05e7f3f8f6dbbf379a19bd /includes | |
parent | 2162eaa06f7e4764eb3dcfe130ec2c711d0c62ab (diff) | |
download | pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.gz pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.bz2 pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.zip |
Update
Diffstat (limited to 'includes')
-rw-r--r-- | includes/ai.inc (renamed from includes/ai.php) | 0 | ||||
-rw-r--r-- | includes/assets.inc | 55 | ||||
-rw-r--r-- | includes/backup.inc (renamed from includes/backup.php) | 2 | ||||
-rw-r--r-- | includes/banner.inc (renamed from includes/banner.php) | 42 | ||||
-rw-r--r-- | includes/bitset.inc (renamed from includes/bitset.php) | 0 | ||||
-rw-r--r-- | includes/edit-private.inc (renamed from includes/edit-private.php) | 12 | ||||
-rw-r--r-- | includes/edit.inc (renamed from includes/edit.php) | 12 | ||||
-rw-r--r-- | includes/emergency.inc (renamed from includes/emergency.php) | 0 | ||||
-rw-r--r-- | includes/footer.inc (renamed from includes/footer.php) | 9 | ||||
-rw-r--r-- | includes/functions.inc (renamed from includes/functions.php) | 186 | ||||
-rw-r--r-- | includes/header.inc (renamed from includes/header.php) | 82 | ||||
-rw-r--r-- | includes/icons.inc | 5 | ||||
-rw-r--r-- | includes/init.inc | 28 | ||||
-rw-r--r-- | includes/init.php | 18 | ||||
-rw-r--r-- | includes/keywords.inc (renamed from includes/keywords.php) | 4 | ||||
-rw-r--r-- | includes/logo.inc | 97 | ||||
-rw-r--r-- | includes/member.inc (renamed from includes/member.php) | 38 | ||||
-rw-r--r-- | includes/member/hierarchy.inc (renamed from includes/member/hierarchy.php) | 20 | ||||
-rw-r--r-- | includes/member/tree.inc (renamed from includes/member/tree.php) | 0 | ||||
-rw-r--r-- | includes/pages.json | 116 | ||||
-rw-r--r-- | includes/planner.inc (renamed from includes/planner.php) | 173 | ||||
-rw-r--r-- | includes/pleasure.inc (renamed from includes/pleasure.php) | 0 | ||||
-rw-r--r-- | includes/pronouns.inc (renamed from includes/pronouns.php) | 0 | ||||
-rw-r--r-- | includes/rail.inc | 176 | ||||
-rw-r--r-- | includes/rainbow.inc (renamed from includes/rainbow.php) | 46 | ||||
-rw-r--r-- | includes/random.inc (renamed from includes/random.php) | 0 | ||||
-rw-r--r-- | includes/refresh.php | 144 | ||||
-rw-r--r-- | includes/restore.inc (renamed from includes/restore.php) | 0 | ||||
-rw-r--r-- | includes/score.inc (renamed from includes/score.php) | 29 | ||||
-rw-r--r-- | includes/search.inc (renamed from includes/search.php) | 10 | ||||
-rw-r--r-- | includes/session.inc (renamed from includes/session.php) | 0 | ||||
-rw-r--r-- | includes/short.inc (renamed from includes/short.php) | 6 | ||||
-rw-r--r-- | includes/subsysbanner.inc (renamed from includes/subsysbanner.php) | 11 | ||||
-rw-r--r-- | includes/subsysedit.inc (renamed from includes/subsysedit.php) | 10 | ||||
-rw-r--r-- | includes/sysbanner.inc (renamed from includes/sysbanner.php) | 34 | ||||
-rw-r--r-- | includes/sysedit.inc (renamed from includes/sysedit.php) | 6 | ||||
-rw-r--r-- | includes/system.inc (renamed from includes/system.php) | 8 | ||||
-rw-r--r-- | includes/system/compare.inc (renamed from includes/system/compare.php) | 16 | ||||
-rw-r--r-- | includes/system/history.inc (renamed from includes/system/history.php) | 222 | ||||
-rw-r--r-- | includes/system/species.inc (renamed from includes/system/species.php) | 12 | ||||
-rw-r--r-- | includes/system/subsystem.inc (renamed from includes/system/subsystem.php) | 14 | ||||
-rw-r--r-- | includes/system/tree.inc (renamed from includes/system/tree.php) | 16 | ||||
-rw-r--r-- | includes/travelling.inc (renamed from includes/travelling.php) | 10 | ||||
-rw-r--r-- | includes/wakeup.inc (renamed from includes/wakeup.php) | 0 |
44 files changed, 1252 insertions, 417 deletions
diff --git a/includes/ai.php b/includes/ai.inc index 8f5f7ba..8f5f7ba 100644 --- a/includes/ai.php +++ b/includes/ai.inc diff --git a/includes/assets.inc b/includes/assets.inc new file mode 100644 index 0000000..9a0a9ac --- /dev/null +++ b/includes/assets.inc @@ -0,0 +1,55 @@ +<?php + +if (!file_exists("../assets/avatars")) mkdir("../assets/avatars"); +if (!file_exists("../assets/banners")) mkdir("../assets/banners"); +if (!file_exists("../assets/heads")) mkdir("../assets/heads"); +if (!file_exists("../assets/bodies")) mkdir("../assets/bodies"); + +function downloadAssets($system) { + $general = json_decode(file_get_contents("./data/$system/general.json"), true); + + if (isset($general["avatar_url"])) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]); + echo(" /avatars/$id.webp\n"); + exec("convert -resize 512x512 \"" . $general["avatar_url"] . "\" ../assets/avatars/" . $id . ".webp"); + exec("convert -resize 512x512 \"" . $general["avatar_url"] . "\" ../assets/uploads/" . ($id === "gdapd" ? "raindrops" : "cloudburst") . ".png"); + } + + if (isset($general["banner"])) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]); + echo(" /banners/$id.webp\n"); + exec("convert -resize 2048x2048 \"" . $general["banner"] . "\" ../assets/banners/" . $id . ".webp"); + } + + $members = json_decode(file_get_contents("./data/$system/members.json"), true); + + foreach ($members as $member) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]) . preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $member["uuid"]); + + if (isset($member["avatar_url"])) { + echo(" /avatars/$id.webp\n"); + exec("convert -resize 512x512 \"" . $member["avatar_url"] . "\" ../assets/avatars/" . $id . ".webp"); + } + + if (isset($member["banner"])) { + echo(" /banners/$id.webp\n"); + exec("convert -resize 2048x2048 \"" . $member["banner"] . "\" ../assets/banners/" . $id . ".webp"); + } + + if (file_exists("../assets/uploads/pt-" . $member["name"] . ".png")) { + $url = "../assets/uploads/pt-" . $member["name"] . ".png"; + } else { + $url = "../assets/uploads/pt.png"; + } + echo(" /heads/$id.webp\n"); + exec("convert -resize 64x64 \"" . $url . "\" ../assets/heads/" . $id . ".webp"); + + if (file_exists("../app/fronters/ponies/" . $member["id"] . ".png")) { + echo(" /bodies/$id.webp\n"); + exec("convert -resize 128x128 \"" . "../app/fronters/ponies/" . $member["id"] . ".png" . "\" ../assets/bodies/" . $id . ".webp"); + } + } +} + +downloadAssets("gdapd"); +downloadAssets("ynmuc");
\ No newline at end of file diff --git a/includes/backup.php b/includes/backup.inc index ad09617..489390b 100644 --- a/includes/backup.php +++ b/includes/backup.inc @@ -18,7 +18,7 @@ foreach ($root as $file) { foreach (array_filter(scandir("data/$file"), function ($i) { return !str_starts_with($i, "."); }) as $dirfile) { - if ($dirfile === "backup.poniesbackup" || $dirfile === "backup.ponieskey" || $dirfile === "encrypted" || $dirfile === "oldactions" || str_ends_with($dirfile, ".poniesbackup")) continue; + if ($dirfile === "backup.poniesbackup" || $dirfile === "backup.ponieskey" || $dirfile === "encrypted" || str_ends_with($dirfile, ".poniesbackup")) continue; echo(" /$dirfile/$file\n"); $files[] = [ diff --git a/includes/banner.php b/includes/banner.inc index 213863a..a3c6f10 100644 --- a/includes/banner.php +++ b/includes/banner.inc @@ -1,13 +1,13 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/pronouns.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/pronouns.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); function _header_getMember(string $id, $system) { - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-members.json"), true); + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/members.json"), true); $member = null; foreach ($members as $m) { @@ -48,10 +48,10 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { global $travelling; global $isLoggedIn; - $subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-subsystems.json"), true) ?? []; + $subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$system.json"), true) ?? []; $member = getSystemMember($system, $id); - $metadata = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-$id-metadata.json") ? parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-$id-metadata.json"), true)) : parseMetadata([ + $metadata = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$id.json") ? parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$id.json"), true)) : parseMetadata([ "bitset" => 4196352, "regression" => null, "median" => null, @@ -73,21 +73,21 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { if (!$metadata["median"]) { $fronters = array_map(function ($item) { return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json"), true)["members"]); + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); if (in_array($id, $fronters)) { $lastFronted = [ 'now' => true, - 'relative' => timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json"), true)["timestamp"]), - 'absolute' => date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json"), true)["timestamp"])), - 'timestamp' => strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json"), true)["timestamp"]), + 'relative' => timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), + 'absolute' => date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"])), + 'timestamp' => strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), 'duration' => [ 'seconds' => null, 'pretty' => null ] ]; } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-switches.json"), true); + $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); $thisMember = array_filter($switches, function ($item) { global $memberData; @@ -184,13 +184,13 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { $systemData['subsystem'] = [ "page" => $systemData['page'] . "/-/subsystem/" . $subsystem["source"], "icon" => "ss-$subsystem[source].png", - "name" => file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-subsystem-$subsystem[source].json") ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-subsystem-$subsystem[source].json"), true)["name"] : $subsystem["source"] + "name" => file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$system-$subsystem[source].json") ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$system-$subsystem[source].json"), true)["name"] : $subsystem["source"] ]; } if ($travelling[$member['id']]["travelling"]) { $systemData['page'] = "/" . ($system === "gdapd" ? "cloudburst" : "raindrops"); - $systemData['icon'] = ($system === "gdapd" ? "cloudburst" : "raindrops") . ".png"; + $systemData['icon'] = getAsset($system); $systemData['name'] = $system === "gdapd" ? "Cloudburst" : "Raindrops"; $systemData['full_name'] = $system === "gdapd" ? "Cloudburst System" : "Raindrops System"; $systemData['subsystem'] = null; @@ -201,7 +201,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { foreach ($metadata["marefriends"] as $marefriend) { $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) use ($mfMemberID) { + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { return $item["id"] === $mfMemberID; }); sort($mfMember); @@ -210,7 +210,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { $marefriends[] = [ "id" => $marefriend, "link" => "/" . ($mfMember["name"]), - "icon" => "pt" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "") . ".png", + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), "name" => getMiniName($mfMember["display_name"] ?? $mfMember["name"]), "full_name" => $mfMember["display_name"] ?? $mfMember["name"] ]; @@ -220,7 +220,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { foreach ($metadata["sisters"] as $marefriend) { $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) use ($mfMemberID) { + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { return $item["id"] === $mfMemberID; }); sort($mfMember); @@ -229,7 +229,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { $sisters[] = [ "id" => $marefriend, "link" => "/" . ($mfMember["name"]), - "icon" => "pt" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "") . ".png", + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), "name" => getMiniName($mfMember["display_name"] ?? $mfMember["name"]), "full_name" => $mfMember["display_name"] ?? $mfMember["name"] ]; @@ -242,7 +242,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { foreach ($metadata["caretakers"] as $marefriend) { $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) use ($mfMemberID) { + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { return $item["id"] === $mfMemberID; }); sort($mfMember); @@ -251,7 +251,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { $caretakers[] = [ "id" => $marefriend, "link" => "/" . ($mfMember["name"]), - "icon" => "pt" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "") . ".png", + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), "name" => getMiniName($mfMember["display_name"] ?? $mfMember["name"]), "full_name" => $mfMember["display_name"] ?? $mfMember["name"] ]; @@ -434,7 +434,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { 'id' => $member['name'], 'color' => $member["color"] ?? "000000", 'icon' => [ - "online" => $member['avatar_url'], + "online" => getAsset($system, $member["id"]), "offline" => "pf-$system-$id.webp" ], 'median' => $metadata["median"], diff --git a/includes/bitset.php b/includes/bitset.inc index 1d026e5..1d026e5 100644 --- a/includes/bitset.php +++ b/includes/bitset.inc diff --git a/includes/edit-private.php b/includes/edit-private.inc index 58e9ed5..e760b94 100644 --- a/includes/edit-private.php +++ b/includes/edit-private.inc @@ -1,7 +1,7 @@ -<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (private page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (private page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; -if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json")) { - $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json"), true)); +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) { + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); } ?> @@ -16,12 +16,12 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" <br> <p class="text-muted" id="page-content"> - <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> + <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> </p> <!--suppress HtmlFormInputWithoutLabel --> <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") : "" ?> + <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") : "" ?> </textarea> <script src="/assets/editor/editor.js"></script> @@ -144,4 +144,4 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" </script> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/edit.php b/includes/edit.inc index 5bbd38a..d8cf673 100644 --- a/includes/edit.php +++ b/includes/edit.inc @@ -1,7 +1,7 @@ -<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (public page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (public page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; -if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json")) { - $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json"), true)); +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) { + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); } ?> @@ -16,12 +16,12 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" <br> <p class="text-muted" id="page-content"> - <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> + <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> </p> <!--suppress HtmlFormInputWithoutLabel --> <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") : "" ?> + <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") : "" ?> </textarea> <script src="/assets/editor/editor.js"></script> @@ -144,4 +144,4 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" </script> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/emergency.php b/includes/emergency.inc index 5490985..5490985 100644 --- a/includes/emergency.php +++ b/includes/emergency.inc diff --git a/includes/footer.php b/includes/footer.inc index 720881a..303b6f0 100644 --- a/includes/footer.php +++ b/includes/footer.inc @@ -1,6 +1,6 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; ?> @@ -9,10 +9,11 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; <?php $refresh = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/refresh.json"), true); + $version = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json"), true); ?> - © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted">Equestria.dev Developers</a> · <a href="https://git.equestria.dev/equestria.dev/ponies.equestria.horse" target="_blank" class="text-muted">Source Code</a><br> - <a href="/-/debug" class="text-muted" style="text-decoration: none;">Data updated <?= trim(timeAgo($refresh["timestamp"])) ?> (<?= date('D j M, G:i:s T', $refresh["timestamp"]) ?>; took <?= round($refresh["duration"] * 1000) ?> ms, <?= count($refresh["restored"]) > 0 ? (count($refresh["restored"]) > 1 ? "reported " . count($refresh["restored"]) . " failures" : "reported 1 failure") : "no failures reported" ?>)</a> + © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted">Equestria.dev Developers</a> · version 2.<?= $version["build"] ?>.<?= hexdec(substr($version["hash"], 0, 4)) ?>.<?= $version["revision"] ?><br> + <a href="/-/debug" class="text-muted" style="text-decoration: none;">Data updated <?= trim(timeAgo($refresh["timestamp"])) ?> (<?php if (time() - $refresh["timestamp"] > 360): ?>not updating; <?php endif; ?><?= date('D j M, G:i:s T', $refresh["timestamp"]) ?>; took <?= round($refresh["duration"] * 1000) ?> ms, <?= count($refresh["restored"]) > 0 ? (count($refresh["restored"]) > 1 ? "reported " . count($refresh["restored"]) . " failures" : "reported 1 failure") : "no failures reported" ?>)</a> <br><br><br> </div> @@ -29,7 +30,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; }) </script> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/search.php"; ?> +<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/search.inc"; ?> </body> </html>
\ No newline at end of file diff --git a/includes/functions.php b/includes/functions.inc index 1a2bf4c..386d2b2 100644 --- a/includes/functions.php +++ b/includes/functions.inc @@ -1,13 +1,167 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc"; + +if (!function_exists("getAsset")) { + function getAsset($systemID, $memberID = null, $type = "avatars") { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/general.json")) { + $id1 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/general.json"), true)["uuid"]); + + if (isset($memberID)) { + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); + $list = array_map(function ($i) { + return $i["id"]; + }, $members); + + if (in_array($memberID, $list)) { + $id2 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", getMemberWithoutSystem($memberID)["uuid"]); + } else { + return "/error/nomember/?s=$systemID&m=$memberID&t=$type"; + } + + $id = $id1 . $id2; + } else { + $id = $id1; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/" . $type . "/" . $id . ".webp")) { + return "/assets/" . $type . "/" . $id . ".webp"; + } else { + return "/error/nofile/?s=$systemID&m=$memberID&t=$type"; + } + } else { + return "/error/nosys/?s=$systemID&m=$memberID&t=$type"; + } + } +} + +if (!function_exists("rgbToHsl")) { + function rgbToHsl($r, $g, $b) { + $oldR = $r; + $oldG = $g; + $oldB = $b; + + $r /= 255; + $g /= 255; + $b /= 255; + + $max = max($r, $g, $b); + $min = min($r, $g, $b); + + $l = ($max + $min) / 2; + $d = $max - $min; + + if ($d == 0) { + $h = $s = 0; + } else { + $s = $d / (1 - abs(2 * $l - 1)); + + switch ($max) { + case $r: + $h = 60 * fmod((($g - $b) / $d), 6); + if ($b > $g) { + $h += 360; + } + break; + + case $g: + $h = 60 * (($b - $r) / $d + 2); + break; + + case $b: + $h = 60 * (($r - $g) / $d + 4); + break; + } + } + + return array(round($h, 2), round($s, 2), round($l, 2)); + } +} + +if (!function_exists("imageCreateCorners")) { + function imageCreateCorners($sourceImageFile, $radius) { + # test source image + if (file_exists($sourceImageFile)) { + $res = is_array($info = getimagesize($sourceImageFile)); + } + else $res = false; + + # open image + if ($res) { + $w = $info[0]; + $h = $info[1]; + switch ($info['mime']) { + case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile); + break; + case 'image/gif': $src = imagecreatefromgif($sourceImageFile); + break; + case 'image/png': $src = imagecreatefrompng($sourceImageFile); + break; + default: + $res = false; + } + } + + # create corners + if ($res) { + + $q = 10; # change this if you want + $radius *= $q; + + # find unique color + do { + $r = rand(0, 255); + $g = rand(0, 255); + $b = rand(0, 255); + } + while (imagecolorexact($src, $r, $g, $b) < 0); + + $nw = $w*$q; + $nh = $h*$q; + + $img = imagecreatetruecolor($nw, $nh); + $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127); + imagealphablending($img, false); + imagesavealpha($img, true); + imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor); + + imagefill($img, 0, 0, $alphacolor); + imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h); + + imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor); + imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor); + imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor); + imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor); + imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor); + imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor); + imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor); + imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor); + imagealphablending($img, true); + imagecolortransparent($img, $alphacolor); + + # resize image down + $dest = imagecreatetruecolor($w, $h); + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor); + imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh); + + # output image + $res = $dest; + imagedestroy($src); + imagedestroy($img); + } + + return $res; + } +} if (!function_exists("getMiniName")) { function getMiniName(string $name) { $parts = explode(" ", $name); - if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy") { + if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy" && (isset($parts[1]) && $parts[1] !== "Brightdawn")) { if (str_contains($parts[0], "/")) { return explode("/", $parts[0])[0]; } else { @@ -40,13 +194,15 @@ 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); + $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; } + $member["system"] = $member["_system"] = $system; + return $member; } } @@ -55,15 +211,17 @@ if (!function_exists("getMemberWithoutSystem")) { function getMemberWithoutSystem(string $id) { $member = null; - $members1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true); + $members1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true); foreach ($members1 as $m) { $m["_system"] = "ynmuc"; + $m["system"] = "ynmuc"; if ($m["id"] === $id) $member = $m; } - $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true); + $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true); foreach ($members2 as $m) { $m["_system"] = "gdapd"; + $m["system"] = "gdapd"; if ($m["id"] === $id) $member = $m; } @@ -76,7 +234,7 @@ if (!function_exists("showMembersFromList")) { foreach ($list as $member) { if ($member['name'] !== "unknown" && $member['name'] !== "fusion") { echo('<!-- ' . ($member['display_name'] ?? $member['name']) . ' --> <a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;"><div> -<img alt="" src="' . $member['avatar_url'] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> +<img alt="" src="' . getAsset($member["system"], $member["id"]) . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> <div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['display_name'] ?? $member['name']) . '</div> <div style="text-decoration:none !important;color:black !important;"><code style="text-decoration:none !important;color:white !important;">' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '</code></div> </div></div></a>'); @@ -86,7 +244,7 @@ if (!function_exists("showMembersFromList")) { 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); + $subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$parentSystem-$data[source].json"), true); echo('<!-- ' . $subsystemData["name"] . ' --> <div id="hpd-cloudburst" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px;display:grid;grid-template-columns: 1fr;margin-bottom:10px;">'); @@ -106,7 +264,7 @@ 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); + $global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id/general.json"), true); if ($hideTitle) { echo('<!-- ' . $name . ' --> @@ -117,7 +275,7 @@ if (!function_exists("showSystem")) { } if (!$hideTitle) echo('<!-- System Name --> <a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #' . $global['color'] . '55;width: 148px;text-decoration:none;color:white;filter:none !important;" href="/' . ($id === "gdapd" ? "raindrops" : "cloudburst") . '" class="hpd-system"> -<div style="text-align:center;"><img src="/assets/uploads/' . ($id === "gdapd" ? "raindrops" : "cloudburst") . '.png" style="width:64px;"><br>' . $name . '</div> +<div style="text-align:center;"><img src="' . getAsset($id) . '" style="width:64px;"><br>' . $name . '</div> </a>'); if ($hideTitle) { @@ -130,13 +288,13 @@ if (!function_exists("showSystem")) { $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) { + }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id/members.json"), true), function ($i) use ($travelling) { return !(isset($travelling[$i['id']]) && $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) { + }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), function ($i) use ($travelling) { return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; }))], $id)); @@ -162,7 +320,7 @@ 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); + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); $member = null; foreach ($members as $m) { @@ -296,7 +454,7 @@ if (!function_exists("getMemberSystem")) { 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)]; + $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; diff --git a/includes/header.php b/includes/header.inc index 91d0aee..e851c85 100644 --- a/includes/header.php +++ b/includes/header.inc @@ -1,5 +1,23 @@ <?php global $title; global $pages; +$readOnly = false; +@file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test", "hello"); + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test")) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test"); +} else { + $readOnly = true; +} + +$isNormallyLoggedIn = false; + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $isUserLoggedIn; +if ($readOnly && $isLoggedIn || $readOnly && $isUserLoggedIn) { + $isLoggedIn = false; + $isUserLoggedIn = false; + $isNormallyLoggedIn = true; +} + $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); function error($errno, $errstr, $file, $line) { @@ -23,14 +41,18 @@ global $_SystemName; global $_SystemPage; global $toplevel; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.php"; global $travelling; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.php"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.php"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; global $isUserLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); +$page = $pages[$toplevel] ?? [ + "rail" => false +]; + +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.inc"; global $travelling; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; ?> @@ -57,13 +79,21 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; <?php if (isset($_SystemName) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/" . $_SystemName . ".png") && (!isset($_MemberName) || $_MemberName !== "fusion")): ?> <link rel="shortcut icon" href="/assets/uploads/<?= $_SystemName ?>.png" type="image/png"> <?php else: ?> - <link rel="shortcut icon" href="/assets/logo/logo.png" type="image/png"> + <link rel="shortcut icon" href="/assets/logo/newlogo.png" type="image/png"> <?php endif; ?> <?php endif; ?> <?php endif; ?> <?php endif; ?> <?php endif; ?> <style> + #admin-page { + margin-left: 32px; + } + + #admin-page .navbar { + margin-left: -32px; + } + nav.navbar { background-color: black !important; border-bottom: 1px solid rgba(255, 255, 255, .25); @@ -723,10 +753,10 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; } </style> </head> -<body> +<body<?php if ($page["rail"] && $isLoggedIn): ?> id="admin-page"<?php endif; ?>> <nav class="navbar navbar-expand-<?= $isLoggedIn ? 'xl' : 'lg' ?> bg-dark navbar-dark" style="height:60px;"> <div class="container-fluid"> - <a class="navbar-brand" href="/"><img src="/assets/logo/logo.png" alt="" style="width:32px;vertical-align: middle;margin-right:5px;"> <span style="vertical-align: middle;">Cold Haze</span><a> + <a class="navbar-brand" href="/"><img src="/assets/logo/newlogo.png" alt="" style="width:32px;vertical-align: middle;margin-right:5px;"> <span style="vertical-align: middle;">Cold Haze</span><a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar"> <span class="navbar-toggler-icon"></span> </button> @@ -751,6 +781,10 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; <img src="/assets/icons/relations.svg" class="dropdown-icon" alt="" style="width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $pages["relations"]["name"] ?></span> </a></li> + <li><a class="dropdown-item" href="/-/government"> + <img src="/assets/icons/government.svg" class="dropdown-icon" alt="" style="width:24px;vertical-align: middle;"> + <span style="vertical-align: middle;"><?= $pages["government"]["name"] ?></span> + </a></li> <li><a class="dropdown-item" href="/-/terminology"> <img src="/assets/icons/terminology.svg" class="dropdown-icon" alt="" style="width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $pages["terminology"]["name"] ?></span> @@ -780,8 +814,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; </a></li> <?php - $frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true)["members"]; - $frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true)["members"]; + $frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true)["members"]; + $frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"]; if (isset($_GET['pleasure']) || (isset($frontRaindrops[0]) && isset($frontCloudburst[0]) && ( ((int)date('H') >= 20 || (int)date('H') < 6) && @@ -863,7 +897,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; </a></li> <?php - $subsystems1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-subsystems.json"), true); + $subsystems1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/ynmuc.json"), true); $subsystemsNotMember = array_values(array_filter($subsystems1, function ($i) { return $i["source_type"] !== "member"; })); @@ -871,7 +905,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; if (count($subsystemsNotMember) > 0): ?> <li><hr class="dropdown-divider"></li> <li><h5 class="dropdown-header">Subsystems</h5></li> - <?php foreach ($subsystemsNotMember as $subsystem): $ssData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-subsystem-" . $subsystem['source'] . ".json"), true); ?> + <?php foreach ($subsystemsNotMember as $subsystem): $ssData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/ynmuc-" . $subsystem['source'] . ".json"), true); ?> <li><a class="dropdown-item" href="/cloudburst/-/subsystem/<?= $subsystem['source'] ?>"> <img src="/assets/uploads/ss-<?= $subsystem['source'] ?>.png" alt="" style="border-radius:5px;width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $ssData['name'] ?? $subsystem['source'] ?></span> @@ -880,9 +914,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; <?php endif; ?> <li><hr class="dropdown-divider"></li> <li><h5 class="dropdown-header">Members</h5></li> - <?php foreach (scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true), "ynmuc"), "ynmuc") as $member): if ($member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"): ?> + <?php foreach (scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc") as $member): if ($member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"): ?> <li><a class="dropdown-item" href="/<?= $member['name'] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" alt="" style="width:24px;vertical-align: middle;"> + <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" alt="" style="width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $member['display_name'] ?? $member['name'] ?></span> </a></li> <?php endif; endforeach; ?> @@ -900,7 +934,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; </a></li> <?php - $subsystems1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-subsystems.json"), true); + $subsystems1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/gdapd.json"), true); $subsystemsNotMember = array_values(array_filter($subsystems1, function ($i) { return $i["source_type"] !== "member"; })); @@ -908,7 +942,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; if (count($subsystemsNotMember) > 0): ?> <li><hr class="dropdown-divider"></li> <li><h5 class="dropdown-header">Subsystems</h5></li> - <?php foreach ($subsystemsNotMember as $subsystem): $ssData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-subsystem-" . $subsystem['source'] . ".json"), true); ?> + <?php foreach ($subsystemsNotMember as $subsystem): $ssData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/gdapd-" . $subsystem['source'] . ".json"), true); ?> <li><a class="dropdown-item" href="/raindrops/-/subsystem/<?= $subsystem['source'] ?>"> <img src="/assets/uploads/ss-<?= $subsystem['source'] ?>.png" alt="" style="border-radius:5px;width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $ssData['name'] ?? $subsystem['source'] ?></span> @@ -917,9 +951,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; <?php endif; ?> <li><hr class="dropdown-divider"></li> <li><h5 class="dropdown-header">Members</h5></li> - <?php foreach (scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd"), "gdapd") as $member): if ($member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"): ?> + <?php foreach (scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd") as $member): if ($member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"): ?> <li><a class="dropdown-item" href="/<?= $member['name'] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" alt="" style="width:24px;vertical-align: middle;"> + <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" alt="" style="width:24px;vertical-align: middle;"> <span style="vertical-align: middle;"><?= $member['display_name'] ?? $member['name'] ?></span> </a></li> <?php endif; endforeach; ?> @@ -960,4 +994,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ical/main.php"; </ul> </div> </div> - </nav>
\ No newline at end of file + </nav> + +<?php if ($page["rail"] && $isLoggedIn): ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rail.inc"; ?> +<?php endif; ?> diff --git a/includes/icons.inc b/includes/icons.inc new file mode 100644 index 0000000..ec433b2 --- /dev/null +++ b/includes/icons.inc @@ -0,0 +1,5 @@ +<?php + +chdir("../assets/icons"); +exec("node icongen.js"); +chdir("../../includes");
\ No newline at end of file diff --git a/includes/init.inc b/includes/init.inc new file mode 100644 index 0000000..7265c0e --- /dev/null +++ b/includes/init.inc @@ -0,0 +1,28 @@ +<?php + +global $title; +global $toplevel; +global $emergencyHeader; +global $pages; + +$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; + +if (in_array($toplevel, array_keys($pages))) { + $title = $pages[$toplevel]["name"]; + + if ($pages[$toplevel]["admin"]) { + $readOnly = false; + @file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test", "hello"); + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test")) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test"); + } else { + $readOnly = true; + } + + if (!$isLoggedIn || ($readOnly && !$emergencyHeader)) header("Location: /-/login/?return=$toplevel") and die(); + } +} else { + $title = $toplevel; +}
\ No newline at end of file diff --git a/includes/init.php b/includes/init.php deleted file mode 100644 index 71d7def..0000000 --- a/includes/init.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -global $title; -global $toplevel; -global $pages; - -$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; - -if (in_array($toplevel, array_keys($pages))) { - $title = $pages[$toplevel]["name"]; - - if ($pages[$toplevel]["admin"]) { - if (!$isLoggedIn) header("Location: /-/login/?return=$toplevel") and die(); - } -} else { - $title = $toplevel; -}
\ No newline at end of file diff --git a/includes/keywords.php b/includes/keywords.inc index 270d905..9bea167 100644 --- a/includes/keywords.php +++ b/includes/keywords.inc @@ -1,8 +1,8 @@ <?php function getKeyWords() { - $actions = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions.json"), true); - $toys = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys.json"), true); + $actions = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions/actions.json"), true); + $toys = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true); $pages = []; foreach ($actions as $action) { diff --git a/includes/logo.inc b/includes/logo.inc new file mode 100644 index 0000000..442ff2b --- /dev/null +++ b/includes/logo.inc @@ -0,0 +1,97 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + +$columns = round(sqrt(count(scoreOrderGlobal()))); +$members = scoreOrderGlobal(); + +usort($members, function ($a, $b) { + $vr = hexdec(substr($a["color"], 0, 2)); + $vg = hexdec(substr($a["color"], 2, 2)); + $vb = hexdec(substr($a["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $ra = $hsl[0]; + + $vr = hexdec(substr($b["color"], 0, 2)); + $vg = hexdec(substr($b["color"], 2, 2)); + $vb = hexdec(substr($b["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $rb = $hsl[0]; + + return $ra - $rb; +}); + +$packs = []; +$currentPack = []; + +foreach ($members as $member) { + if (count($currentPack) >= $columns) { + $packs[] = $currentPack; + $currentPack = []; + } + + $currentPack[] = $member["color"]; +} + +if (count($currentPack) > 0) $packs[] = $currentPack; + +$newPacks = []; +foreach ($packs as $pack) { + usort($pack, function ($a, $b) { + $vra = hexdec(substr($a, 0, 2)); + $vga = hexdec(substr($a, 2, 2)); + $vba = hexdec(substr($a, 4, 2)); + + $hsla = rgbToHsl($vra, $vga, $vba); + $ra = $hsla[2] * $hsla[1]; + + $vrb = hexdec(substr($b, 0, 2)); + $vgb = hexdec(substr($b, 2, 2)); + $vbb = hexdec(substr($b, 4, 2)); + + $hslb = rgbToHsl($vrb, $vgb, $vbb); + $rb = $hslb[2] * $hslb[1]; + + return $rb < $ra; + }); + + while (count($pack) < $columns) $pack[] = "ffffff"; + + $newPacks[] = $pack; +} + +$img = imagecreatetruecolor($columns, $columns); +$factor = 64; + +for ($y = 0; $y < $columns; ++$y) { + for ($x = 0; $x < $columns; ++$x) { + imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); + } +} + +$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); +imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo.png"); + +for ($x = 1; $x <= 120; $x++) { + imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); +} + +imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo-template.png");
\ No newline at end of file diff --git a/includes/member.php b/includes/member.inc index d0120d5..2a0c346 100644 --- a/includes/member.php +++ b/includes/member.inc @@ -6,18 +6,18 @@ if ($memberData["name"] === "fusion") { $title = $memberCommonName . " · " . $systemCommonName; } -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); if ($memberData["name"] !== "unknown" && $memberData["name"] !== "fusion") { - $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json"), true)); + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); } global $isLoggedIn; -$frontersRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true); -$frontersCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true); +$frontersRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true); +$frontersCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true); $fusionRaindrops = false; @@ -96,7 +96,7 @@ if ($memberData["name"] === "fusion") { <?= "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst(getMemberPronouns($memberData['pronouns'])["subjective"])) . str_replace("'", "'", getMemberPronouns($memberData["pronouns"])["third"] ? " doesn't" : " don't") . " age like the body does, making " . str_replace("'", "'", getMemberPronouns($memberData['pronouns'])["object"]) . " stay " . $metadata["birth"]["age"] . " years old for " . str_replace("'", "'", getMemberPronouns($memberData['pronouns'])["possessive_det"]) . " entire life.'>" . $metadata["birth"]["age"] . "* years old</span>" ?> <?php endif; ?> <?php else: ?> - <?php if ($metadata["birth"]["year"] <= 2000): ?> + <?php if ($metadata["birth"]["year"] <= 1900): ?> - <?php else: ?> <?php @@ -139,7 +139,7 @@ if ($memberData["name"] === "fusion") { <?php global $isLoggedIn; if ($isLoggedIn && $memberData["name"] !== "unknown" && $memberData["name"] !== "fusion"): ?> <?php if (!isset($metadata["bitset"])): ?> <div class="alert alert-warning"> - <b>This member's metadata needs an update.</b> It still uses the old JSON metadata system instead of the new 24bit integer-based system. Contact a developer to request an update. (only administrators can see this; file: <code><?= $_SERVER['DOCUMENT_ROOT'] ?>/includes/data/<?= $systemID ?>-<?= $memberID ?>-metadata.json</code>) + <b>This member's metadata needs an update.</b> It still uses the old JSON metadata system instead of the new 24bit integer-based system. Contact a developer to request an update. (only administrators can see this; file: <code><?= $_SERVER['DOCUMENT_ROOT'] ?>/includes/data/metadata/<?= $memberID ?>.json</code>) </div> <?php endif; ?> <div class="alert alert-dark"> @@ -149,9 +149,9 @@ if ($memberData["name"] === "fusion") { <li><b>ID:</b> <code><?= $memberID ?></code> (<code><?= $systemID . "/" . $memberID ?></code>, <?= $memberData["name"] ?>)</li> <li><b>Files:</b> <ul> - <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-metadata.json" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-metadata.json") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-metadata.json") . " bytes" : "not found" ?>)</li> - <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") . " bytes" : "not found" ?>)</li> - <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") . " bytes" : "not found" ?>)</li> + <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$memberID.json" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$memberID.json") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$memberID.json") . " bytes" : "not found" ?>)</li> + <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") . " bytes" : "not found" ?>)</li> + <li><code><?= $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html" ?></code> (<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") . " bytes" : "not found" ?>)</li> </ul> </li> <li><b>Date added:</b> <?= date('l j F Y', strtotime($memberData["created"])) ?> (<?= timeAgo($memberData["created"]) ?>, <code><?= $memberData["created"] ?></code>)</li> @@ -172,7 +172,7 @@ if ($memberData["name"] === "fusion") { <li><b>Protector:</b> <code><?= $metadata["protector"] ? "1" : "0" ?></code> (<?= $metadata["protector"] ? "Yes" : "No" ?>)</li> <li><b>Little:</b> <code><?= $metadata["little"] ?></code> (<?= $metadata["little"] === 2 ? "Is a little" : ($metadata["little"] === 1 ? "Is an age regressor" : ($metadata["little"] === 3 ? "Not a little, but younger" : "No")) ?>)</li> <li><b>Relations count:</b> <code><?= count($metadata["marefriends"]) + count($metadata["sisters"]) ?></code></li> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $score = calculateScore($metadata, $memberData["display_name"] ?? $memberData["name"]); ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; $score = calculateScore($metadata, $memberData["display_name"] ?? $memberData["name"]); ?> <li> <b>Score breakdown:</b> <code><?= $score["total"] ?></code> <ul> @@ -204,7 +204,7 @@ if ($memberData["name"] === "fusion") { <br> <div style="filter:invert(0);" class="alert alert-warning"> <b>AI-generated page:</b> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ai.php"; ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/ai.inc"; ?> </div> </details> </div> @@ -238,7 +238,7 @@ if ($memberData["name"] === "fusion") { <p>Below is the list of who is merged, we can be either from a single system or from different systems.</p> <div class="list-group"> <?php $foundFusion = false; $fusionOn = false; foreach ($fusionRaindrops ? $frontersRaindrops['members'] : $frontersCloudburst['members'] as $fronter): if ($fronter["name"] !== "fusion"): if ($fusionOn): $foundFusion = true; $name = str_ends_with($fronter['name'], "-travelling") ? substr($fronter['name'], 0, strlen($fronter['name']) - 11) : $fronter['name'] ?> - <a class="list-group-item list-group-item-action text-black" href="/<?= $name ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $name . ".png") ? "-" . $name : "" ?>.png" style="filter:invert(1) hue-rotate(180deg);width:24px;"> <?= $fronter["display_name"] ?? $name ?></a> + <a class="list-group-item list-group-item-action text-black" href="/<?= $name ?>"><img src="<?= getAsset($system, $fronter["id"], "heads") ?>" style="filter:invert(1) hue-rotate(180deg);width:24px;"> <?= $fronter["display_name"] ?? $name ?></a> <?php endif; else: $fusionOn = true; endif; endforeach; ?> </div> <?php if (!$foundFusion): ?> @@ -250,19 +250,19 @@ if ($memberData["name"] === "fusion") { <small style="opacity:.5;display:block;">(edit: <a href="/-/edit/<?= $system ?>/<?= $memberData['name'] ?>">public</a>, <a href="/-/edit-private/<?= $system ?>/<?= $memberData['name'] ?>">private</a>)</small> <?php endif; ?> - <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") && $isLoggedIn): ?> - <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-private.html") ?> + <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") && $isLoggedIn): ?> + <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ?> <hr> <?php endif; ?> - <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html")): ?> - <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") ?> + <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html")): ?> + <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") ?> <?php else: ?> <p class="text-muted">This page is automatically generated and may not be 100% accurate.</p> - <?php require $_SERVER['DOCUMENT_ROOT'] . "/includes/ai.php"; ?> + <?php require $_SERVER['DOCUMENT_ROOT'] . "/includes/ai.inc"; ?> <?php endif; ?> <?php endif; ?> </div> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/member/hierarchy.php b/includes/member/hierarchy.inc index 301bd1c..dfb42c9 100644 --- a/includes/member/hierarchy.php +++ b/includes/member/hierarchy.inc @@ -6,22 +6,22 @@ global $memberData; global $memberCommonName; global $memberID; $title = "Member hierarchy · " . $memberCommonName . " · " . $systemCommonName; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); -$metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json"), true)); +$metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); -$allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-members.json"), true), $systemID); -$allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd"); +$allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true), $systemID); +$allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd"); -$systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-general.json"), true); +$systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/general.json"), true); if ($travelling[$memberID]["travelling"]) { - $allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd"); - $allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-members.json"), true), $systemID); + $allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd"); + $allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true), $systemID); - $systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-general.json"), true); + $systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/general.json"), true); $system = $systemID === "gdapd" ? "cloudburst" : "raindrops"; $systemCommonName = $systemID === "gdapd" ? "Cloudburst System" : "Raindrops System"; @@ -174,4 +174,4 @@ if ($travelling[$memberID]["travelling"]) { } </style> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/member/tree.php b/includes/member/tree.inc index 2e94951..2e94951 100644 --- a/includes/member/tree.php +++ b/includes/member/tree.inc diff --git a/includes/pages.json b/includes/pages.json index 4fc023b..704fcbb 100644 --- a/includes/pages.json +++ b/includes/pages.json @@ -1,162 +1,212 @@ { + "about": { + "name": "About Cold Haze", + "short": "About", + "admin": true, + "rail": true + }, "actions": { "name": "Actions database", "short": "Actions", - "admin": true + "admin": true, + "rail": true }, "api": { "name": "API", "short": null, - "admin": false + "admin": false, + "rail": false }, "app": { "name": "Mobile application", "short": null, - "admin": false + "admin": false, + "rail": false }, "bitset": { "name": "Bitset calculator", "short": "Bitset", - "admin": true + "admin": true, + "rail": true }, "byfront": { "name": "Members by last fronted", "short": "Last fronts", - "admin": true + "admin": true, + "rail": true }, "dashboard": { "name": "Dashboard", "short": null, - "admin": true + "admin": true, + "rail": true }, "debug": { "name": "Data updater debugging", "short": null, - "admin": false + "admin": false, + "rail": true }, "demo": { "name": "Demo interface", "short": null, - "admin": false + "admin": false, + "rail": false }, "docs": { "name": "Documents", "short": "Docs", - "admin": true + "admin": true, + "rail": true }, "disclaimers": { "name": "Disclaimers", "short": null, - "admin": false + "admin": false, + "rail": false }, "edit": { "name": "Editor", "short": null, - "admin": true + "admin": true, + "rail": false }, "edit-private": { "name": "Editor (private)", "short": null, - "admin": true + "admin": true, + "rail": false }, "emergency": { "name": "Emergency alert", "short": null, - "admin": true + "admin": true, + "rail": true }, "fronting": { "name": "Front planner", "short": null, - "admin": true + "admin": true, + "rail": true + }, + "government": { + "name": "Government", + "short": null, + "admin": false, + "rail": false }, "home": { "name": "Home", "short": null, - "admin": false + "admin": false, + "rail": false }, "login": { "name": "Login", "short": null, - "admin": false + "admin": false, + "rail": false }, "logout": { "name": "Logout", "short": null, - "admin": false + "admin": false, + "rail": false }, "nicknames": { "name": "Relations nicknames", "short": "Nicknames", - "admin": true + "admin": true, + "rail": true }, "page": { "name": "Member/system page", "short": null, - "admin": false + "admin": false, + "rail": false }, "parser": { "name": "Message parser", "short": null, - "admin": false + "admin": false, + "rail": false }, "pleasure": { "name": "Pleasure alert", "short": null, - "admin": true + "admin": true, + "rail": true }, "prefix": { "name": "Prefix generator", "short": null, - "admin": false + "admin": false, + "rail": false }, "relations": { "name": "Relations", "short": null, - "admin": false + "admin": false, + "rail": false }, "rules": { "name": "Systems rules", "short": "Rules", - "admin": true + "admin": true, + "rail": true }, "score": { "name": "Score system testing", "short": null, - "admin": true + "admin": true, + "rail": true }, "splitting": { "name": "Members by splitting date", "short": "Splits", - "admin": true + "admin": true, + "rail": true + }, + "stats": { + "name": "Statistics", + "short": "Stats", + "admin": true, + "rail": true }, "terminology": { "name": "Terminology", "short": null, - "admin": false + "admin": false, + "rail": true }, "together": { "name": "Watch Together", "short": "Together", - "admin": true + "admin": true, + "rail": true }, "together-dev": { "name": "Watch Together (dev)", "short": null, - "admin": true + "admin": true, + "rail": false }, "toys": { "name": "Toys database", "short": "Toys", - "admin": true + "admin": true, + "rail": true }, "travelling": { "name": "System travels manager", - "short": null, - "admin": true + "short": "Travels", + "admin": true, + "rail": true }, "wakeup": { "name": "Wake-up alert", "short": null, - "admin": true + "admin": true, + "rail": true } }
\ No newline at end of file diff --git a/includes/planner.php b/includes/planner.inc index f98d83b..da25770 100644 --- a/includes/planner.php +++ b/includes/planner.inc @@ -1,16 +1,16 @@ <?php -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.php"; global $travelling; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.php"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.php"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; global $isUserLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; - -$cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json"), true); -$raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-planner.json"), true); +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.inc"; global $travelling; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $isUserLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; + +$cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json"), true); +$raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json"), true); foreach ($cloudburst as $id => $day) { foreach ($day as $index => $fronter) { @@ -70,11 +70,11 @@ foreach ($raindrops as $id => $day) { } } -function day($display, $diff): void { global $cloudburst; global $raindrops; ?> +function day($display, $diff): void { if ($diff < 0) $disabled = true; else $disabled = false; global $cloudburst; global $raindrops; ?> <?php if (!isset($display)) { $display = date('l', time() + (86400 * $diff)); }?> - <tr class="planner-day" id="planner-header-<?= $diff ?>"> + <tr class="planner-day" id="planner-header-<?= $diff ?>" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>> <td colspan="10"><?= $display ?></td> <?php @@ -90,12 +90,12 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> ?> </tr> - <tr class="planner-header"> + <tr class="planner-header" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>> <td colspan="5">Cloudburst System</td> <td colspan="5">Raindrops System</td> </tr> <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> + <tr class="planner-member" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>> <?php if (isset($dayCloudburst[$index])): ?> <td class="planner-member-id"> <?= $index + 1 ?> @@ -103,9 +103,9 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <td class="planner-link" style="width:50vw;" <?php if (!isset($dayCloudburst[$index][1])): ?>colspan="3" <?php else: ?>colspan="2"<?php endif; ?>> <?php $member = getMemberWithoutSystem($dayCloudburst[$index][0]); ?> <?php if ($member["name"] === "fusion"): ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a> <?php else: ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a> <?php endif; ?> </td> <?php if (!isset($dayCloudburst[$index][1])): ?> @@ -118,9 +118,9 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <td class="planner-link" style="width:41.35vw;" colspan="2"> <?php $member = getMemberWithoutSystem($dayCloudburst[$index][1]); ?> <?php if ($member["name"] === "fusion"): ?> - <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a> <?php else: ?> - <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a> <?php endif; ?> </td> <?php endif; ?> @@ -141,9 +141,9 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <?php $member = getMemberWithoutSystem($dayRaindrops[$index][0]); ?> <td class="planner-link" style="width:50vw;" <?php if (!isset($dayRaindrops[$index][1])): ?>colspan="3" <?php else: ?>colspan="2"<?php endif; ?>> <?php if ($member["name"] === "fusion"): ?> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a> <?php else: ?> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a> <?php endif; ?> </td> <?php if (!isset($dayRaindrops[$index][1])): ?> @@ -156,15 +156,15 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <td class="planner-link" style="width:41.35vw;" colspan="2"> <?php $member = getMemberWithoutSystem($dayRaindrops[$index][1]); ?> <?php if ($member["name"] === "fusion"): ?> - <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a> <?php else: ?> - <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a> <?php endif; ?> </td> <?php endif; ?> <?php elseif ($index === count($dayRaindrops)): ?> <td class="planner-add-inner planner-link" colspan="5"> - <a href="#" onclick="addFronter('raindrops', <?= $diff ?>);" class="planner-add-link"> + <a href="#" onclick="addFronter('raindrops', <?= $diff ?>, <?= $index ?>);" class="planner-add-link"> <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> <span class="planner-add-text">Add new fronter</span> </a> @@ -174,7 +174,7 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <?php endif; ?> </tr> <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> + <tr class="planner-day planner-end-of-day" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>> <td colspan="10"> <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> <?= getMiniName(getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["name"]) ?> will sleep with <?= getMiniName(getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["name"]) ?> @@ -191,13 +191,27 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <h2>Front planner</h2> <table id="planner"> <tbody> + <?php day("Yesterday", -1) ?> <?php day("Today", 0) ?> <?php day("Tomorrow", 1) ?> - <?php day(null, 2) ?> - <?php day(null, 3) ?> - <?php day(null, 4) ?> - <?php day(null, 5) ?> - <?php day(null, 6) ?> + <?php + + $factor = 1; + $lastDay = time() + 86400; + $lastDayWeek = date('W', $lastDay); + $tomorrowWeek = date('W', time() + 86400); + + while ($lastDayWeek === $tomorrowWeek) { + $factor++; + $lastDay = time() + (86400 * $factor); + $lastDayWeek = date('W', $lastDay); + + if ($lastDayWeek === $tomorrowWeek) { + day(null, $factor); + } + } + + ?> </tbody> </table> @@ -336,6 +350,16 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> } } + @media (max-width: 991px) { + .member-link-text { + display: none; + } + + .planner-link .member-link { + text-align: center; + } + } + </style> <!--suppress JSUnresolvedVariable, JSUnresolvedFunction --> @@ -348,14 +372,40 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> window.names = JSON.parse(window.atob(`<?php $names = []; - foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { $names[$member['id']] = $member['display_name'] ?? $member['name']; } - foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { $names[$member['id']] = $member['display_name'] ?? $member['name']; } echo(base64_encode(json_encode($names))) ?>`)); + window.relations = JSON.parse(window.atob(`<?php + + $relations = []; + foreach (scoreOrderGlobal() as $member) { + $relations[$member['id']] = array_map(function ($i) { + return explode("/", $i)[1]; + }, [...($member["_metadata"]["marefriends"] ?? []), ...($member["_metadata"]["sisters"] ?? []), ...($member["_metadata"]["caretakers"] ?? [])]); + } + + echo(base64_encode(json_encode($relations))) ?>`)); + + function getSuggestedPonies() { + if (window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex]) { + let otherPony = window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex][0]; + let availablePonies = window.relations[window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex][0]]; + + document.getElementById("associated-results").innerHTML = ""; + + for (let pony of availablePonies) { + document.getElementById("associated-results").innerHTML += document.getElementById("list-pony-" + pony).outerHTML; + } + + document.getElementById("list").style.display = "none"; + document.getElementById("associated-results").style.display = ""; + } + } function ordinal(n) { let s = ["th", "st", "nd", "rd"]; @@ -394,6 +444,26 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> case "<?= date('Y-m-d', time() + (86400 * 6)) ?>": display = "on <?= date('l', time() + (86400 * 6)) ?>"; break; + + case "<?= date('Y-m-d', time() + (86400 * 7)) ?>": + display = "on <?= date('l', time() + (86400 * 7)) ?>"; + break; + + case "<?= date('Y-m-d', time() + (86400 * 8)) ?>": + display = "on <?= date('l', time() + (86400 * 8)) ?>"; + break; + + case "<?= date('Y-m-d', time() + (86400 * 9)) ?>": + display = "on <?= date('l', time() + (86400 * 9)) ?>"; + break; + + case "<?= date('Y-m-d', time() + (86400 * 10)) ?>": + display = "on <?= date('l', time() + (86400 * 10)) ?>"; + break; + + case "<?= date('Y-m-d', time() + (86400 * 11)) ?>": + display = "on <?= date('l', time() + (86400 * 11)) ?>"; + break; } window.selectedFronting = { @@ -533,7 +603,7 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> document.getElementById("search2").focus(); } - function addFronter(system, offset) { + function addFronter(system, offset, index) { let date; let display; @@ -572,14 +642,41 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> date = "<?= date('Y-m-d', time() + (86400 * 6)) ?>"; display = "on <?= date('l', time() + (86400 * 6)) ?>"; break; + + case 7: + date = "<?= date('Y-m-d', time() + (86400 * 7)) ?>"; + display = "on <?= date('l', time() + (86400 * 7)) ?>"; + break; + + case 8: + date = "<?= date('Y-m-d', time() + (86400 * 8)) ?>"; + display = "on <?= date('l', time() + (86400 * 8)) ?>"; + break; + + case 9: + date = "<?= date('Y-m-d', time() + (86400 * 9)) ?>"; + display = "on <?= date('l', time() + (86400 * 9)) ?>"; + break; + + case 10: + date = "<?= date('Y-m-d', time() + (86400 * 10)) ?>"; + display = "on <?= date('l', time() + (86400 * 10)) ?>"; + break; + + case 11: + date = "<?= date('Y-m-d', time() + (86400 * 11)) ?>"; + display = "on <?= date('l', time() + (86400 * 11)) ?>"; + break; } window.currentWorkingDate = date; + window.addIndex = index; document.getElementById("new-fronter-date").innerText = display; document.getElementById("new-fronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System"; window.addSystem = system === "raindrops" ? "gdapd" : "ynmuc"; document.getElementById("list").style.display = "block"; + getSuggestedPonies(); document.getElementById("search-results").style.display = "none"; document.getElementById("search").value = ""; @@ -688,13 +785,14 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <div id="list"> <div class="list-group"> <?php foreach (scoreOrderGlobal() as $member): ?> - <a id="list-pony-<?= $member['id'] ?>" onclick="confirmFronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a> + <a id="list-pony-<?= $member['id'] ?>" onclick="confirmFronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a> <?php endforeach; $member = getSystemMember("gdapd", "irxyh") ?> <a onclick="confirmFronterAdd(window.addSystem, 'irxyh');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted">Multiple merged members</span></a> </div> </div> <div id="search-results" class="list-group"></div> + <div id="associated-results" class="list-group"></div> </div> </div> @@ -718,7 +816,7 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <div id="list2"> <div class="list-group"> <?php foreach (scoreOrderGlobal() as $member): ?> - <a id="list2-pony-<?= $member['id'] ?>" onclick="confirmCofronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-cofronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a> + <a id="list2-pony-<?= $member['id'] ?>" onclick="confirmCofronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-cofronter-link member-link list-group-item list-group-item-action" href="#"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a> <?php endforeach; $member = getSystemMember("gdapd", "irxyh") ?> </div> </div> @@ -858,6 +956,7 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> if (query.trim() === "") { document.getElementById("list").style.display = "block"; + getSuggestedPonies(); document.getElementById("search-results").style.display = "none"; } } @@ -920,7 +1019,7 @@ function day($display, $diff): void { global $cloudburst; global $raindrops; ?> <?php -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json", json_encode($cloudburst)); -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-planner.json", json_encode($raindrops)); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json", json_encode($cloudburst)); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json", json_encode($raindrops)); ?>
\ No newline at end of file diff --git a/includes/pleasure.php b/includes/pleasure.inc index 8b4835b..8b4835b 100644 --- a/includes/pleasure.php +++ b/includes/pleasure.inc diff --git a/includes/pronouns.php b/includes/pronouns.inc index 6ab2487..6ab2487 100644 --- a/includes/pronouns.php +++ b/includes/pronouns.inc diff --git a/includes/rail.inc b/includes/rail.inc new file mode 100644 index 0000000..b2ed467 --- /dev/null +++ b/includes/rail.inc @@ -0,0 +1,176 @@ +<?php global $pages; ?> +<div id="rail" style="position: fixed;top: 60px;left: 0;bottom: 0;background: rgba(255, 255, 255, .1);width: 32px; display: grid; grid-template-rows: max-content 1fr;"> + <div> + <a id="rl-1" class="rail-link" href="/-/dashboard" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/home.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-2" class="rail-link" href="/-/fronting" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/fronting.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-3" class="rail-link" href="/-/actions" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/actions.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-4" class="rail-link" href="/-/rules" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/rules.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-5" class="rail-link" href="/-/docs" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/docs.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-6" class="rail-link" href="/-/nicknames" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/nicknames.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-7" class="rail-link" href="/-/together" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/together.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-8" class="rail-link" href="/-/splitting" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/splitting.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-9" class="rail-link" href="/-/byfront" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/byfront.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-10" class="rail-link" href="/-/bitset" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/bitset.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-11" class="rail-link" href="/-/travelling" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/travelling.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-12" class="rail-link" href="/-/toys" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/toys.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-16" class="rail-link" href="/-/stats" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/stats.svg" style="filter: invert(1) brightness(2000%); height: 24px; display:block;"> + </a> + <a id="rl-87" class="rail-link" href="/-/emergency" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/emergency.svg" style="height: 24px; display:block;"> + </a> + <a id="rl-88" class="rail-link" href="/-/wakeup" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/wakeup.svg" style="height: 24px; display:block;"> + </a> + <a id="rl-89" class="rail-link" href="/-/pleasure" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/pleasure.svg" style="height: 24px; display:block;"> + </a> + </div> + <div style="margin-top: auto; height: max-content;"> + <a id="rl-98" class="rail-link" href="/-/debug" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/debug.svg" style="filter: invert(1); height: 24px; display:block;"> + </a> + <a id="rl-99" class="rail-link" href="/-/about" style="padding: 4px; display: block;"> + <img alt="" src="/assets/icons/about.svg" style="filter: invert(1) brightness(2000%); height: 24px; display:block;"> + </a> + </div> +</div> +<div id="rail-text" style="position: fixed;top: 60px;left: 32px;bottom: 0; z-index: 9999999; opacity: 0; pointer-events: none; display: grid; grid-template-rows: max-content 1fr;"> + <div> + <div id="rlt-1" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["dashboard"]["name"] ?> + </div> + <div id="rlt-2" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["fronting"]["name"] ?> + </div> + <div id="rlt-3" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["actions"]["name"] ?> + </div> + <div id="rlt-4" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["rules"]["name"] ?> + </div> + <div id="rlt-5" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["docs"]["name"] ?> + </div> + <div id="rlt-6" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["nicknames"]["name"] ?> + </div> + <div id="rlt-7" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["together"]["name"] ?> + </div> + <div id="rlt-8" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["splitting"]["name"] ?> + </div> + <div id="rlt-9" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["byfront"]["name"] ?> + </div> + <div id="rlt-10" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["bitset"]["name"] ?> + </div> + <div id="rlt-11" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["travelling"]["name"] ?> + </div> + <div id="rlt-12" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["toys"]["name"] ?> + </div> + <div id="rlt-16" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["stats"]["name"] ?> + </div> + <div id="rlt-87" class="rail-text-item text-danger fw-bold" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["emergency"]["name"] ?> + </div> + <div id="rlt-88" class="rail-text-item text-info fw-bold" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["wakeup"]["name"] ?> + </div> + <div id="rlt-89" class="rail-text-item text-success fw-bold" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["pleasure"]["name"] ?> + </div> + </div> + <div style="margin-top: auto; height: max-content;"> + <div id="rlt-98" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["debug"]["name"] ?> + </div> + <div id="rlt-99" class="rail-text-item" style="height: 32px; display: flex; align-items: center; padding-left: 10px; opacity: 0;"> + <?= $pages["about"]["name"] ?> + </div> + </div> +</div> + +<style> + .rail-link:hover { + background: rgba(255, 255, 255, .1); + border-top: 1px solid #555; + border-bottom: 1px solid #555; + padding: 3px 4px !important; + } + + .rail-text-item { + border: 1px solid #555; + border-left: none; + padding-right: 10px; + border-top-right-radius: 999px; + border-bottom-right-radius: 999px; + width: 0; + } + + .rail-text-item.hovered { + background: #313131; + opacity: 1 !important; + width: max-content !important; + } +</style> + +<script> + Array.from(document.getElementsByClassName("rail-link")).forEach((i) => { + let rt = document.getElementById("rlt-" + i.id.split("-")[1]); + + i.onmouseenter = () => { + rt.classList.add("hovered"); + } + + i.onmouseleave = () => { + rt.classList.remove("hovered"); + } + }) + + document.getElementById("rail").onmouseenter = () => { + document.getElementById("rail-text").style.opacity = "1"; + } + + document.getElementById("rail").onmouseleave = () => { + document.getElementById("rail-text").style.opacity = "0"; + } + + window.onscroll = () => { + let scroll = document.getElementsByTagName("html")[0].scrollTop; + let pos = 60 - scroll; + + if (pos <= 0) pos = 0; + document.getElementById("rail").style.top = pos + "px"; + document.getElementById("rail-text").style.top = pos + "px"; + } +</script>
\ No newline at end of file diff --git a/includes/rainbow.php b/includes/rainbow.inc index c710be0..470f288 100644 --- a/includes/rainbow.php +++ b/includes/rainbow.inc @@ -1,48 +1,8 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; - -function rgbToHsl($r, $g, $b) { - $oldR = $r; - $oldG = $g; - $oldB = $b; - - $r /= 255; - $g /= 255; - $b /= 255; - - $max = max($r, $g, $b); - $min = min($r, $g, $b); - - $l = ($max + $min) / 2; - $d = $max - $min; - - if ($d == 0) { - $h = $s = 0; - } else { - $s = $d / (1 - abs(2 * $l - 1)); - - switch ($max) { - case $r: - $h = 60 * fmod((($g - $b) / $d), 6); - if ($b > $g) { - $h += 360; - } - break; - - case $g: - $h = 60 * (($b - $r) / $d + 2); - break; - - case $b: - $h = 60 * (($r - $g) / $d + 4); - break; - } - } - - return array(round($h, 2), round($s, 2), round($l, 2)); -} +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; function rainbow(): array { $members = scoreOrderGlobal(); diff --git a/includes/random.php b/includes/random.inc index b6e7905..b6e7905 100644 --- a/includes/random.php +++ b/includes/random.inc diff --git a/includes/refresh.php b/includes/refresh.php index 8f9da79..e8e12dd 100644 --- a/includes/refresh.php +++ b/includes/refresh.php @@ -1,5 +1,7 @@ <?php +$_SERVER['DOCUMENT_ROOT'] = ".."; + $app = json_decode(file_get_contents("./app.json"), true); $start = microtime(true); @mkdir("./data"); @@ -10,11 +12,11 @@ $restored = []; $times = []; $currentOpStart = microtime(true); -file_put_contents("./data/backup/actions_" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/actions.json")); -file_put_contents("./data/backup/toys_" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/toys.json")); +file_put_contents("./data/actions/" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/actions/actions.json")); +file_put_contents("./data/toys/" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/toys/toys.json")); -exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data/backup; ls -tp toys_* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); -exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data/backup; ls -tp actions_* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); +exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data; ls -tp toys/20* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); +exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data; ls -tp actions/20* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); $times["important_backup"] = microtime(true) - $currentOpStart; @@ -40,10 +42,83 @@ foreach ($deletable as $item) { $times["docs_cleanup"] = microtime(true) - $currentOpStart; $currentOpStart = microtime(true); +$version = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json"), true); + +$ignore = [ + $_SERVER['DOCUMENT_ROOT'] . "/Data", + $_SERVER['DOCUMENT_ROOT'] . "/bits/Data", + $_SERVER['DOCUMENT_ROOT'] . "/Private/Data", + $_SERVER['DOCUMENT_ROOT'] . "/bits/Data", + $_SERVER['DOCUMENT_ROOT'] . "/bits/Private/Data", + $_SERVER['DOCUMENT_ROOT'] . "/includes/data", + $_SERVER['DOCUMENT_ROOT'] . "/includes/tokens", + $_SERVER['DOCUMENT_ROOT'] . "/app", + $_SERVER['DOCUMENT_ROOT'] . "/assets", +]; + +function rscandir($dir) { + global $ignore; + $files = []; + + foreach (array_filter(scandir($dir), function ($i) { + return !str_starts_with($i, "."); + }) as $file) { + if (in_array($dir . "/" . $file, $ignore)) continue; + + if (is_dir($dir . "/" . $file)) { + array_push($files, ...rscandir($dir . "/" . $file)); + } else { + $files[] = $dir . "/" . $file; + } + } + + return array_unique($files); +} + +function calculateVersionNumber() { + $files = rscandir($_SERVER['DOCUMENT_ROOT']); + $hashes = []; + + foreach ($files as $file) { + $hashes[] = md5_file($file); + } + + $hash = md5(implode("", $hashes)); + return [$hash, $hashes]; +} + +$versionHash = calculateVersionNumber(); + +if ($versionHash[0] !== $version["hash"]) { + $version["hash"] = $versionHash[0]; + $version["timestamp"] = time(); + $version["revision"] = 0; + $version["list"] = [ + "current" => $versionHash[1], + "old" => isset($version["list"]) ? $version["list"]["current"] ?? null : null + ]; + $version["build"]++; +} else { + $version["revision"]++; +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json", json_encode($version)); +$times["version"] = microtime(true) - $currentOpStart; + +$currentOpStart = microtime(true); foreach (array_filter(scandir("./data"), function ($i) { - return !str_starts_with($i, ".") && $i !== "backup" && is_file("./data/" . $i); + return !str_starts_with($i, ".") && $i !== "backup" && (is_file("./data/" . $i) || is_dir("./data/" . $i)); }) as $file) { - $files[] = $file; + if (is_dir("./data/" . $file)) { + foreach (array_filter(scandir("./data"), function ($i) use ($file) { + return !str_starts_with($i, ".") && $i !== "backup" && is_file("./data/" . $file . "/" . $i); + }) as $file2) { + @mkdir("./data/backup/" . $file); + $files[] = $file . "/" . $file2; + } + } else { + $files[] = $file; + } } @mkdir("./data/backup"); @@ -57,17 +132,28 @@ function getSystem(string $id) { echo(" Base system info\n"); $currentOpStart = microtime(true); - file_put_contents("./data/$id-general.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id")); + $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id"); + + if (trim($data) !== "" && $data !== false) { + file_put_contents("./data/$id/general.json", $data); + } $times["system-general-$id"] = microtime(true) - $currentOpStart; echo(" System members\n"); $currentOpStart = microtime(true); - file_put_contents("./data/$id-members.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/members")); + $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/members"); + + if (trim($data) !== "" && $data !== false) { + file_put_contents("./data/$id/members.json", $data); + } $times["system-members-$id"] = microtime(true) - $currentOpStart; echo(" Fronters\n"); - $currentOpStart = microtime(true); - file_put_contents("./data/$id-fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/fronters")); + $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/fronters"); + + if (trim($data) !== "" && $data !== false) { + file_put_contents("./data/$id/fronters.json", $data); + } $times["system-fronters-$id"] = microtime(true) - $currentOpStart; echo(" Switches\n"); @@ -84,8 +170,10 @@ function getSystem(string $id) { echo(" Part 3/3\n"); $switches3 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true); - file_put_contents("./data/$id-switches.json", json_encode([...$switches1, ...$switches2, ...$switches3], JSON_PRETTY_PRINT)); - $times["system-switches-$id"] = microtime(true) - $currentOpStart; + if ($switches1 !== null && $switches2 !== null && $switches3 !== null) { + file_put_contents("./data/$id/switches.json", json_encode([...$switches1, ...$switches2, ...$switches3], JSON_PRETTY_PRINT)); + $times["system-switches-$id"] = microtime(true) - $currentOpStart; + } } getSystem("gdapd"); // Raindrops @@ -93,13 +181,13 @@ getSystem("ynmuc"); // Cloudburst echo("Calendar\n"); $currentOpStart = microtime(true); -file_put_contents("./data/calendar.ics", file_get_contents($app["calendar"])); +file_put_contents("./data/calendar/calendar.ics", file_get_contents($app["calendar"])); $times["calendar"] = microtime(true) - $currentOpStart; echo("Downloading images.\n"); if (!file_exists("./data/images")) mkdir("./data/images"); -foreach (json_decode(file_get_contents("./data/gdapd-members.json"), true) as $member) { +foreach (json_decode(file_get_contents("./data/gdapd/members.json"), true) as $member) { $currentOpStart2 = microtime(true); echo(" " . $member['id'] . "\n"); @@ -117,7 +205,7 @@ foreach (json_decode(file_get_contents("./data/gdapd-members.json"), true) as $m $times["images-gdapd-" . $member['id']] = microtime(true) - $currentOpStart2; } -foreach (json_decode(file_get_contents("./data/ynmuc-members.json"), true) as $member) { +foreach (json_decode(file_get_contents("./data/ynmuc/members.json"), true) as $member) { $currentOpStart2 = microtime(true); echo(" " . $member['id'] . "\n"); @@ -152,12 +240,36 @@ $times["restore"] = microtime(true) - $currentOpStart; echo("Backing up...\n"); if (date('i') === "00") { - require_once "./backup.php"; + require_once "./backup.inc"; echo("Backup completed\n"); } else { echo("Backup skipped\n"); } +echo("Generating logo...\n"); + +$currentOpStart = microtime(true); +require_once "./logo.inc"; +$times["logo"] = microtime(true) - $currentOpStart; + +echo("Generated logo\n"); + +echo("Generating favicons...\n"); + +$currentOpStart = microtime(true); +require_once "./icons.inc"; +$times["favicons"] = microtime(true) - $currentOpStart; + +echo("Generated favicons\n"); + +echo("Downloading assets...\n"); + +$currentOpStart = microtime(true); +require_once "./assets.inc"; +$times["assets"] = microtime(true) - $currentOpStart; + +echo("Downloading assets\n"); + $time = array_sum($times); echo("Completed in " . $time . " seconds.\n"); diff --git a/includes/restore.php b/includes/restore.inc index 72748ab..72748ab 100644 --- a/includes/restore.php +++ b/includes/restore.inc diff --git a/includes/score.php b/includes/score.inc index cd8c389..c35e9bc 100644 --- a/includes/score.php +++ b/includes/score.inc @@ -15,6 +15,8 @@ function calculateScore($metadata, $name) { $scoreAdd = 0; if ($name === "Cloudy Dreams") $scoreAdd += 250; + if ($name === "Zoom Zephyrwing") $scoreAdd += 250; + if ($name === "Thunder") $scoreAdd += 250; if ($name === "Scoots/Mia") $scoreAdd -= 495; $score = $scoreHost + $scoreFictive + $scoreLittle + $scoreNotTalking + $scoreProtector + $scoreSharedMemory + $scoreRelations + $scoreSpecies + $scoreName + $scoreMedian + $scoreAdd; @@ -38,11 +40,11 @@ function calculateScore($metadata, $name) { function scoreOrder($members, $system) { $ordered = []; foreach ($members as $member) { - if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($member["system"] ?? $system) . "-$member[id]-metadata.json")) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { $systemID = $member["system"] ?? $system; - $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$member[id]-metadata.json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]); + $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $ordered[] = $member; } } @@ -56,19 +58,22 @@ function scoreOrder($members, $system) { function scoreOrderGlobal() { $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_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json")) { + 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_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { $member["_system"] = "gdapd"; - $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]); + $member["system"] = "gdapd"; + $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $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_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json")) { + + 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_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { $member["_system"] = "ynmuc"; - $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)), $member["display_name"] ?? $member["name"]); + $member["system"] = "ynmuc"; + $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $ordered[] = $member; } } @@ -77,5 +82,5 @@ function scoreOrderGlobal() { return $b["_score"]["total"] - $a["_score"]["total"]; }); - return $ordered; + return array_values($ordered); }
\ No newline at end of file diff --git a/includes/search.php b/includes/search.inc index 037b6de..d8e573f 100644 --- a/includes/search.php +++ b/includes/search.inc @@ -22,7 +22,7 @@ const pages_list = JSON.parse(atob(`<?php $base = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/pages"), function ($i) { - return !str_starts_with($i, ".") && $i !== "page.php" && $i !== "api.php" && $i !== "demo.php" && $i !== "logout.php" && $i !== "edit.php" && $i !== "edit-private.php" && $i !== "app.php" && !str_ends_with($i, ".bak.php") && !str_ends_with($i, ".old.php") && !str_ends_with($i, "-dev.php"); + return !str_starts_with($i, ".") && $i !== "page.inc" && $i !== "api.inc" && $i !== "demo.inc" && $i !== "logout.inc" && $i !== "edit.inc" && $i !== "edit-private.inc" && $i !== "app.inc" && !str_ends_with($i, ".bak.php") && !str_ends_with($i, ".old.php") && !str_ends_with($i, "-dev.php"); })); $list = array_values(array_filter(array_map(function ($i) { global $pages; @@ -70,9 +70,9 @@ $list = array_map(function ($i) { return [ 'name' => $i["display_name"] ?? $i["name"], - 'description' => file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$i[_system]-$i[id]-content.html") ? strip_tags(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$i[_system]-$i[id]-content.html")) : "", + 'description' => file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$i[id].html") ? strip_tags(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$i[id].html")) : "", 'url' => '/' . $i["name"], - 'icon' => "/assets/uploads/pt" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($i['name']) . ".png") ? "-" . $i['name'] : "") . ".png", + 'icon' => getAsset($i["system"], $i["id"], "heads"), 'invert' => false ]; }, $base); @@ -103,7 +103,7 @@ global $isLoggedIn; if ($isLoggedIn) { - $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys.json"), true)); + $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true)); $list = array_map(function ($i) { return [ 'name' => $i["name"], @@ -143,7 +143,7 @@ global $isLoggedIn; if ($isLoggedIn) { - $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions.json"), true)); + $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions/actions.json"), true)); $list = array_map(function ($i) { return [ 'name' => $i["name"], diff --git a/includes/session.php b/includes/session.inc index b440c9c..b440c9c 100644 --- a/includes/session.php +++ b/includes/session.inc diff --git a/includes/short.php b/includes/short.inc index 59b3cae..66d749d 100644 --- a/includes/short.php +++ b/includes/short.inc @@ -1,8 +1,8 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; global $toplevel; diff --git a/includes/subsysbanner.php b/includes/subsysbanner.inc index 7788155..176380f 100644 --- a/includes/subsysbanner.php +++ b/includes/subsysbanner.inc @@ -12,7 +12,7 @@ global $subsystem; $fronters = array_map(function ($item) { return $item["id"]; -}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-fronters.json"), true)["members"]); +}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true)["members"]); ?> @@ -25,7 +25,7 @@ $fronters = array_map(function ($item) { <span> <b>Fronter:</b> <?php if (in_array($fronters[0], $subsystem["members"])): $member = getMember($fronters[0]); ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> <?php else: ?> <span class="text-muted">N/A</span> <?php endif; ?> @@ -34,14 +34,14 @@ $fronters = array_map(function ($item) { <?php $subsystem = getSubsystemByID($subsystemID); - $arr = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-switches.json"), true), function ($i) use ($subsystem) { + $arr = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/switches.json"), true), function ($i) use ($subsystem) { return isset($i["members"][0]) && in_array($i["members"][0], $subsystem["members"]); }); sort($arr); $previousID = $arr[in_array($fronters[0], $subsystem["members"]) ? 1 : 0]["members"][0]; $member = null; - foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true) as $members) { + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true) as $members) { if ($members["id"] === $previousID) { $member = $members; break; @@ -49,7 +49,8 @@ $fronters = array_map(function ($item) { } ?> - <b>Last fronter: </b><a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <b>Last fronter: </b><a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID + , $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> </span> <span> <b>Members:</b> <?= count($subsystem["members"]) ?> diff --git a/includes/subsysedit.php b/includes/subsysedit.inc index e6aa9ca..e9c4b4c 100644 --- a/includes/subsysedit.php +++ b/includes/subsysedit.inc @@ -1,19 +1,19 @@ -<?php global $system; global $systemCommonName; global $systemID; global $subsystem; global $subsystemData; global $subsystemCommonName; global $subsystemID; $title = "Editing " . $subsystemCommonName . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; global $subsystem; global $subsystemData; global $subsystemCommonName; global $subsystemID; $title = "Editing " . $subsystemCommonName . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; ?> <br> <div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/subsysbanner.php"; ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/subsysbanner.inc"; ?> <br> <p class="text-muted"> - <span id="editor-save-status">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html")) : "0" ?></span> bytes + <span id="editor-save-status">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystemID.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html")) : "0" ?></span> bytes </p> <!--suppress HtmlFormInputWithoutLabel --> <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") : "" ?> + <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystemID.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") : "" ?> </textarea> <script src="/assets/editor/editor.js"></script> @@ -140,4 +140,4 @@ </script> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/sysbanner.php b/includes/sysbanner.inc index 45c1c16..d3caecd 100644 --- a/includes/sysbanner.php +++ b/includes/sysbanner.inc @@ -7,7 +7,7 @@ global $systemCommonName; global $systemID; global $system; -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); ?> @@ -23,15 +23,15 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ $foundHost = false; $hostGoneTravelling = false; - $members = array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true), $systemID), function ($i) use ($travelling) { + $members = array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true), $systemID), function ($i) use ($travelling) { global $hostGoneTravelling; if ($travelling[$i['id']]['travelling'] && $i["_metadata"]["host"]) $hostGoneTravelling = true; return true; }); foreach ($members as $member) { - $data = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$member[id]-metadata.json"), true)); + $data = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); if ($data["host"]): $foundHost = true; ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> <?php endif; } @@ -42,29 +42,29 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ </span>--> <span> - <?php $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-fronters.json"), true); ?> + <?php $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true); ?> <b>Fronter: </b> <?php if (isset($fronters["members"][0])): ?> <?php $member = $fronters["members"][0]; ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . resolveMember($member['name']) : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? ($member["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member["name"])) ?></a> + <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? ($member["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member["name"])) ?></a> <?php if (isset($fronters["members"][1])): ?> <?php $member2 = $fronters["members"][1]; ?> <br>(with - <a class="member-link" href="/<?= $member2["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . resolveMember($member2['name']) : "" ?>.png" style="width:24px;"> <?= getMiniName($member2["display_name"] ?? ($member2["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member2["name"])) ?></a>) - <?php else: ?>-<?php endif; ?> + <a class="member-link" href="/<?= $member2["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member2["display_name"] ?? ($member2["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member2["name"])) ?></a>) + <?php endif; ?> <?php else: ?>-<?php endif; ?> </span> <span> <b>Last fronter: </b> <?php - $previous = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-switches.json"), true)[1]["members"]; + $previous = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/switches.json"), true)[1]["members"]; if (isset($previous[0])): $previousID = $previous[0]; $member = null; - foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true) as $members) { + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true) as $members) { if ($members["id"] === $previousID) { $member = $members; break; @@ -72,31 +72,31 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ } ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? ($member["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member["name"])) ?></a> + <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? ($member["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member["name"])) ?></a> <?php if (isset($previous[1])): $previousID = $previous[1]; $member2 = null; - foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true) as $members) { + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true) as $members) { if ($members["id"] === $previousID) { $member2 = $members; break; } } ?> <br>(with - <a class="member-link" href="/<?= $member2["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . resolveMember($member2['name']) : "" ?>.png" style="width:24px;"> <?= getMiniName($member2["display_name"] ?? ($member2["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member2["name"])) ?></a>) - <?php else: ?>-<?php endif; ?> + <a class="member-link" href="/<?= $member2["name"] ?>"><img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member2["display_name"] ?? ($member2["name"] === "fusion" ? "<peh-muted>More than one</peh-muted>" : $member2["name"])) ?></a>) + <?php endif; ?> <?php else: ?>-<?php endif; ?> </span> <span> <?php - $travellers = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), function ($i) use ($travelling) { + $travellers = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), function ($i) use ($travelling) { return $travelling[$i['id']]['travelling']; }); ?> - <b>Members: </b><?= count(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true), $systemID)) ?><?php + <b>Members: </b><?= count(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true), $systemID)) ?><?php if (count($travellers) > 0) { echo("<br>+ " . count($travellers) . " traveller" . (count($travellers) > 1 ? "s" : "")); @@ -105,7 +105,7 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ ?> </span> <span> - <b>Last switch: </b><span data-bs-toggle="tooltip" title="<?= date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-fronters.json"), true)["timestamp"])) ?>"><?= timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-fronters.json"), true)["timestamp"]) ?></span> + <b>Last switch: </b><span data-bs-toggle="tooltip" title="<?= date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true)["timestamp"])) ?>"><?= timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true)["timestamp"]) ?></span> </span> </div> </div> diff --git a/includes/sysedit.php b/includes/sysedit.inc index 0eca518..95a0b5b 100644 --- a/includes/sysedit.php +++ b/includes/sysedit.inc @@ -1,10 +1,10 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "Editing " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; $title = "Editing " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; ?> <br> <div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/sysbanner.php"; ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/sysbanner.inc"; ?> <br> <p class="text-muted"> @@ -140,4 +140,4 @@ </script> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system.php b/includes/system.inc index 46adeb1..099f522 100644 --- a/includes/system.php +++ b/includes/system.inc @@ -1,19 +1,19 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; $title = $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; ?> <br> <div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/sysbanner.php"; ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/sysbanner.inc"; ?> <br> <div id="page-content"> <?php global $isLoggedIn; if ($isLoggedIn): ?> <small style="opacity:.5;display:block;">(<a href="/-/edit/<?= $system ?>">edit</a>)</small> <?php endif; ?> - <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-content.html") ?> + <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") ?> </div> <?php if ($system === "cloudburst") cloudburst(true); else raindrops(true); ?> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system/compare.php b/includes/system/compare.inc index 9714488..de777aa 100644 --- a/includes/system/compare.php +++ b/includes/system/compare.inc @@ -1,6 +1,6 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "Compare members · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; global $travelling; +<?php global $system; global $systemCommonName; global $systemID; $title = "Compare members · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $travelling; -$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); +$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); function getMember(string $id) { global $systemID; @@ -90,7 +90,7 @@ function getMember(string $id) { ?> <a title="<?= $member["display_name"] ?? $member["name"] ?>" data-bs-toggle="tooltip" class="member-link comparison-item comparison-item-clickable" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <span style="vertical-align: middle;"><span class="comparison-name-full"><?= $member["display_name"] ?? $member["name"] ?></span><span class="comparison-name-small"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></span> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><span class="comparison-name-full"><?= $member["display_name"] ?? $member["name"] ?></span><span class="comparison-name-small"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></span> <span class="comparison-colors" style="background-color: #<?= $member["color"] ?? "ffffff" ?>; height: 16px; width: 16px;display: inline-block;vertical-align: middle;border-radius:2px;"></span> </a> <span class="comparison-item"> @@ -132,16 +132,16 @@ function getMember(string $id) { <?= count($metadata["marefriends"]) + count($metadata["sisters"]) > 0 ? count($metadata["marefriends"]) + count($metadata["sisters"]) : "" ?> </span> <span class="comparison-relations-full"> - <?php $index = 0; foreach ($metadata["marefriends"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) { + <?php $index = 0; foreach ($metadata["marefriends"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) { global $mfMemberID; return $item["id"] === $mfMemberID; - }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Marefriend" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "" ?>.png" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["sisters"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) { + }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Marefriend" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["sisters"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) { global $mfMemberID; return $item["id"] === $mfMemberID; - }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Sister" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "" ?>.png" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["caretakers"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem-members.json"), true), function ($item) { + }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Sister" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?><?php $index = 0; foreach ($metadata["caretakers"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) { global $mfMemberID; return $item["id"] === $mfMemberID; - }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Caretaker" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $mfMember['name'] . ".png") ? "-" . $mfMember['name'] : "" ?>.png" style="width:24px;"></a><?php $index++; endforeach; ?> + }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br>Caretaker" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php $index++; endforeach; ?> </span> </span> <span class="comparison-item"> @@ -186,4 +186,4 @@ function getMember(string $id) { </div> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system/history.php b/includes/system/history.inc index a13a3e1..ee687d7 100644 --- a/includes/system/history.php +++ b/includes/system/history.inc @@ -1,9 +1,9 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "Front history · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; $title = "Front history · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; function getMember(string $id) { global $systemID; - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); $member = null; foreach ($members as $m) { @@ -19,9 +19,7 @@ function getMember(string $id) { <div class="container" id="page-content"> <?php - $switches = array_values(array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-switches.json"), true), function ($i) { - return isset($i["members"][0]); - })); + $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/switches.json"), true); uksort($switches, function ($a, $b) { if (isset($b["timestamp"]) && isset($a["timestamp"])) { return strtotime($b["timestamp"]) - strtotime($a["timestamp"]); @@ -102,7 +100,7 @@ function getMember(string $id) { $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -114,9 +112,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches2[0]) ? $switches2[0]["timestamp"] : (isset($switches3[0]) ? $switches3[0]["timestamp"] : (isset($switches4[0]) ? $switches4[0]["timestamp"] : (isset($switches5[0]) ? $switches5[0]["timestamp"] : (isset($switches6[0]) ? $switches6[0]["timestamp"] : (isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"])))))))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 0) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -124,21 +120,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 0) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 0) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;">Yesterday</h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -150,9 +155,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches3[0]) ? $switches3[0]["timestamp"] : (isset($switches4[0]) ? $switches4[0]["timestamp"] : (isset($switches5[0]) ? $switches5[0]["timestamp"] : (isset($switches6[0]) ? $switches6[0]["timestamp"] : (isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"]))))))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 1) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -160,21 +163,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 1) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 1) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 2)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -186,9 +198,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches4[0]) ? $switches4[0]["timestamp"] : (isset($switches5[0]) ? $switches5[0]["timestamp"] : (isset($switches6[0]) ? $switches6[0]["timestamp"] : (isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"])))))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 2) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -196,21 +206,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 2) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 2) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 3)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -222,9 +241,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches5[0]) ? $switches5[0]["timestamp"] : (isset($switches6[0]) ? $switches6[0]["timestamp"] : (isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"]))))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 3) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -232,21 +249,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 3) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 3) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 4)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -258,9 +284,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches6[0]) ? $switches6[0]["timestamp"] : (isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"])))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 4) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -268,21 +292,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 4) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 4) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 5)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -294,9 +327,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches7[0]) ? $switches7[0]["timestamp"] : (isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"]))) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 5) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -304,21 +335,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 5) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 5) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 6)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -330,9 +370,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches8[0]) ? $switches8[0]["timestamp"] : (isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"])) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 6) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -340,21 +378,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member2["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 6) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 6) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 7)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -366,9 +413,7 @@ function getMember(string $id) { "date" => strtotime(isset($switches9[0]) ? $switches9[0]["timestamp"] : $switches10[0]["timestamp"]) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 7) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -376,21 +421,30 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 7) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 7) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 8)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; @@ -399,12 +453,10 @@ function getMember(string $id) { $fronters[] = [ "member" => isset($switches10[0]) ? $switches10[0]["members"][0] : getSwitchBefore($switches9[count($switches9) - 1]["id"])["members"][0], "member2" => isset($switches10[0]) && isset($switches10[0]["members"]) && isset($switches10[0]["members"][1]) ? $switches10[0]["members"][1] : (isset(getSwitchBefore($switches9[count($switches9) - 1]["id"])["members"][1]) ? getSwitchBefore($switches9[count($switches9) - 1]["id"])["members"][1] : null), - "date" => strtotime($switches10[0] ? $switches10[0]["timestamp"] : getSwitchBefore($switches9[count($switches9) - 1]["id"])["timestamp"]) + "date" => strtotime(isset($switches10[0]) ? $switches10[0]["timestamp"] : getSwitchBefore($switches9[count($switches9) - 1]["id"])["timestamp"]) ]; - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 8) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -412,29 +464,36 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 7) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 7) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> <h4 style="margin-top:15px;"><?= date('D j M', time() - (86400 * 9)) ?></h4> <?php $fronters = array_map(function ($i) { return [ - "member" => $i["members"][0], + "member" => $i["members"][0] ?? null, "member2" => $i["members"][1] ?? null, "date" => strtotime($i["timestamp"]) ]; }, $switches10); - $fronters = array_unique($fronters, SORT_REGULAR); - - foreach ($fronters as $fronter): $member = getMember($fronter["member"]); + foreach ($fronters as $fronter): if (isset($fronter["member"])): $member = getMember($fronter["member"]); ?> <div class="fronter"> <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 9) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -442,19 +501,28 @@ function getMember(string $id) { </span> <span class="fronter-profile" style="vertical-align: middle;"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <?php if (isset($fronter["member2"])): $member2 = getMember($fronter["member2"]); ?> (with <a class="member-link" href="/<?= $member2["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member2['name']) . ".png") ? "-" . $member2['name'] : "" ?>.png" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= $member2["display_name"] ?? $member2["name"] ?></a>) <?php endif; ?> </span> </div> - <?php endforeach; ?> + <?php else: ?> + <div class="fronter"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 7) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <?= isNotToday($fronter["date"], 7) ? "00:00" : date('H:i', $fronter["date"]) ?> + </span> + <span class="fronter-profile" style="vertical-align: middle;"> + <span class="text-muted">Fallback pony</span> + </span> + </div> + <?php endif; endforeach; ?> </div> <script> Array.from(document.getElementsByClassName("fronter-date")).forEach((i) => { i.innerText = new Date(parseInt(i.getAttribute("data-date-time").trim()) * 1000).toTimeString().split(" ")[0].substring(0, 5) + " " }); document.getElementById("timezone").style.display = ""; </script> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system/species.php b/includes/system/species.inc index a35e811..bd37d7b 100644 --- a/includes/system/species.php +++ b/includes/system/species.inc @@ -1,6 +1,6 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "Members by species · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; global $travelling; +<?php global $system; global $systemCommonName; global $systemID; $title = "Members by species · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $travelling; -$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); +$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); $members = scoreOrder($members, $systemID); function species(array $members, string $id, string $name) { global $systemID; ?> @@ -11,9 +11,9 @@ function species(array $members, string $id, string $name) { global $systemID; ? global $travelling; return !$travelling[$i['id']]['travelling']; }), - ...array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), function ($i) use ($id, $systemID) { + ...array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), function ($i) use ($id, $systemID) { global $travelling; - return $travelling[$i['id']]['travelling'] && in_array($id, parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "-" . $i['id'] . "-metadata.json"), true))["species"]); + return $travelling[$i['id']]['travelling'] && in_array($id, parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $i['id'] . ".json"), true))["species"]); }) ]; @@ -26,7 +26,7 @@ function species(array $members, string $id, string $name) { global $systemID; ? <div class="relation-item" style="margin-left:10px;padding:0 20px;"> <?php if (count($members) > 0): ?> <?php $index = 0; foreach ($members as $member): ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a><?php if ($index + 2 <= count($members)) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; endforeach; ?> + <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a><?php if ($index + 2 <= count($members)) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; endforeach; ?> <?php else: ?>-<?php endif; ?> </div> </div> @@ -67,4 +67,4 @@ function species(array $members, string $id, string $name) { global $systemID; ? <?php species($crystal, "crystal", "Crystal ponies"); ?> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system/subsystem.php b/includes/system/subsystem.inc index 372ad08..b7d73f1 100644 --- a/includes/system/subsystem.php +++ b/includes/system/subsystem.inc @@ -2,11 +2,11 @@ if (str_ends_with($_GET['_'], "/subsystem")) header("Location: /?error=Invalid subsystem ID") and die(); -$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); +$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); $subsystemID = $parts[3]; -$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystems.json"), true) ?? []; +$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID.json"), true) ?? []; function getMember(string $id) { global $systemID; @@ -74,27 +74,27 @@ function getSubsystemByID(string $id) { } if (getSubsystemByID($subsystemID) === null) header("Location: /?error=Invalid subsystem ID") and die(); -$subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.json"), true); +$subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystemID.json"), true); global $subsystem; $subsystem = getSubsystemByID($subsystemID); -$title = $subsystemData["name"] . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +$title = $subsystemData["name"] . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; ?> <br> <div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/subsysbanner.php"; ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/subsysbanner.inc"; ?> <br> <div id="page-content"> <?php global $isLoggedIn; if ($isLoggedIn): ?> <small style="opacity:.5;display:block;">(<a href="/-/edit/<?= $system ?>/<?= $subsystemID ?>">edit</a>)</small> <?php endif; ?> - <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") ?> + <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystemID.html") ?> </div> <?php showSubsystem(getSubsystemByID($subsystemID), $systemID); ?> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/system/tree.php b/includes/system/tree.inc index 21d146b..c3cc5c4 100644 --- a/includes/system/tree.php +++ b/includes/system/tree.inc @@ -1,9 +1,9 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "System tree · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +<?php global $system; global $systemCommonName; global $systemID; $title = "System tree · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; -$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); +$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); $members = scoreOrder($members, $systemID); -$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystems.json"), true) ?? []; +$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID.json"), true) ?? []; function getMember(string $id) { global $systemID; @@ -70,7 +70,7 @@ function getMemberSubsystem(array $member) { <div class="tree-l0-separator<?= $first ? " tree-first-separator" : "" ?>"> </div> <div class="tree-inner"> <a class="member-link" href="/<?= $systemID === "gdapd" ? "raindrops" : "cloudburst" ?>/-/subsystem/<?= $subsystem["source"] ?>"> - <img src="/assets/uploads/ss-<?= $subsystem["source"] ?>.png" style="width:24px;border-radius:5px;"> <span style="vertical-align: middle;"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystem[source].json") ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystem[source].json"), true)["name"] : $subsystem["source"] ?></span> + <img src="/assets/uploads/ss-<?= $subsystem["source"] ?>.png" style="width:24px;border-radius:5px;"> <span style="vertical-align: middle;"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystem[source].json") ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/$systemID-$subsystem[source].json"), true)["name"] : $subsystem["source"] ?></span> </a> </div> <?php $ssfirst = true; foreach ($subsystem["members"] as $ssm): $ssmember = getMember($ssm); ?> @@ -79,7 +79,7 @@ function getMemberSubsystem(array $member) { <div class="tree-l1-separator<?= $ssfirst ? " tree-first-separator" : "" ?>"> </div> <div class="tree-inner"> <a class="member-link" href="/<?= $ssmember["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $ssmember['name'] . ".png") ? "-" . $ssmember['name'] : "" ?>.png" style="width:24px;"> <span style="vertical-align: middle;"><?= $ssmember["display_name"] ?? $ssmember["name"] ?></span> + <img src="<?= getAsset($systemID, $ssmember["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><?= $ssmember["display_name"] ?? $ssmember["name"] ?></span> </a> </div> </div> @@ -91,7 +91,7 @@ function getMemberSubsystem(array $member) { <div class="tree-l0-separator<?= $first ? " tree-first-separator" : "" ?>"> </div> <div class="tree-inner"> <a class="member-link" href="/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <span style="vertical-align: middle;"><?= $member["display_name"] ?? $member["name"] ?></span> + <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><?= $member["display_name"] ?? $member["name"] ?></span> </a> </div> <?php if (memberHasSubsystem($member)): ?> @@ -101,7 +101,7 @@ function getMemberSubsystem(array $member) { <div class="tree-l1-separator<?= $ssfirst ? " tree-first-separator" : "" ?>"> </div> <div class="tree-inner"> <a class="member-link" href="/<?= $ssmember["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $ssmember['name'] . ".png") ? "-" . $ssmember['name'] : "" ?>.png" style="width:24px;"> <span style="vertical-align: middle;"><?= $ssmember["display_name"] ?? $ssmember["name"] ?></span> + <img src="<?= getAsset($systemID, $ssmember["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><?= $ssmember["display_name"] ?? $ssmember["name"] ?></span> </a> </div> </div> @@ -111,4 +111,4 @@ function getMemberSubsystem(array $member) { <?php $first = false; endif; endforeach; ?> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/travelling.php b/includes/travelling.inc index b74c826..edcb267 100644 --- a/includes/travelling.php +++ b/includes/travelling.inc @@ -1,9 +1,9 @@ <?php -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); -$json_cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true); -$json_raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true); +$json_cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true); +$json_raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true); if (!isset($json_cloudburst)) $json_cloudburst = []; if (!isset($json_raindrops)) $json_raindrops = []; @@ -38,10 +38,10 @@ function withTravelers(array $members, string $system): array { ...array_filter(array_map(function ($i) use ($system) { $i['system'] = $system === "gdapd" ? "ynmuc" : "gdapd"; return $i; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true)), function ($i) use ($travelling) { + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true)), function ($i) use ($travelling) { return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; }) ]; } -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT)));
\ No newline at end of file +@file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT)));
\ No newline at end of file diff --git a/includes/wakeup.php b/includes/wakeup.inc index 587e705..587e705 100644 --- a/includes/wakeup.php +++ b/includes/wakeup.inc |