diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
commit | 633c92eae865e957121e08de634aeee11a8b3992 (patch) | |
tree | 09d881bee1dae0b6eee49db1dfaf0f500240606c /pages | |
parent | c4657e4509733699c0f26a3c900bab47e915d5a0 (diff) | |
download | pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2 pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip |
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'pages')
-rw-r--r-- | pages/alphabet.inc | 51 | ||||
-rw-r--r-- | pages/api/fronter.php | 17 | ||||
-rw-r--r-- | pages/byspecies.inc | 98 | ||||
-rw-r--r-- | pages/home.inc | 4 | ||||
-rw-r--r-- | pages/metadata.inc | 5 | ||||
-rw-r--r-- | pages/relations.inc | 184 | ||||
-rw-r--r-- | pages/rules.inc | 9 | ||||
-rw-r--r-- | pages/splitting.inc | 7 | ||||
-rw-r--r-- | pages/stats.inc | 16 | ||||
-rw-r--r-- | pages/travelling.inc | 1 |
10 files changed, 268 insertions, 124 deletions
diff --git a/pages/alphabet.inc b/pages/alphabet.inc index 37bd74d..2b57c76 100644 --- a/pages/alphabet.inc +++ b/pages/alphabet.inc @@ -1,24 +1,26 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $isLowerLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; -?> +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json", "{}"); -<br> -<div class="container"> +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json"), true); + +function page(): void +{ global $lang; global $pages; ?> <div id="page-content"> <h2><?= $pages["alphabet"]["name"][$lang["_name"]] ?></h2> <?php $members = scoreOrderGlobal(); ?> <div> <?php foreach (str_split("abcdefghijklmnopqrstuvwxyz") as $letter): ?> - <div style="display:inline-grid;grid-template-columns: max-content 1fr;min-height:32px;"> - <div style="display:flex;align-items:center;justify-content:center;font-weight: bold;margin-right:10px;" class="font-monospace"><?= $letter ?>.</div> - <div> - <?php foreach ($members as $member): if (isset($member["proxy_tags"][0]) && isset($member["proxy_tags"][0]["prefix"]) && str_starts_with(strtolower($member["proxy_tags"][0]["prefix"]), strtolower($letter)) && strlen($member["proxy_tags"][0]["prefix"]) === 2): ?><a href="/<?= $member["name"] ?>" title="<b><?= $member["display_name"] ?></b> (<code class='text-white'><?= $member["proxy_tags"][0]["prefix"] ?></code>)" data-bs-toggle="tooltip" data-bs-html="true"><img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"></a><?php endif; endforeach; ?> + <div style="display:inline-grid;grid-template-columns: max-content 1fr;min-height:32px;"> + <div style="display:flex;align-items:center;justify-content:center;font-weight: bold;margin-right:10px;" class="font-monospace"><?= $letter ?>.</div> + <div> + <?php foreach ($members as $member): if (isset($member["proxy_tags"][0]) && isset($member["proxy_tags"][0]["prefix"]) && str_starts_with(strtolower($member["proxy_tags"][0]["prefix"]), strtolower($letter)) && strlen($member["proxy_tags"][0]["prefix"]) === 2): ?><a href="/<?= $member["name"] ?>" title="<b><?= $member["display_name"] ?></b> (<code class='text-white'><?= $member["proxy_tags"][0]["prefix"] ?></code>)" data-bs-toggle="tooltip" data-bs-html="true"><img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"></a><?php endif; endforeach; ?> + </div> </div> - </div> <?php foreach (str_split("abcdefghijklmnopqrstuvwxyz") as $letter2): $list = array_filter($members, function ($member) use ($letter, $letter2) { return isset($member["proxy_tags"][0]) && isset($member["proxy_tags"][0]["prefix"]) && str_starts_with(strtolower($member["proxy_tags"][0]["prefix"]), strtolower($letter . $letter2)) && strlen($member["proxy_tags"][0]["prefix"]) === 3; }); if (count($list) > 0): ?> @@ -33,6 +35,37 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; <?php endforeach; ?> </div> </div> +<?php } + +?> + +<br> +<div class="container"> + <?php if (!isset($cache["private"]) || !isset($cache["public"])) { + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = true; + $isLowerLoggedIn = true; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["private"] = ob_get_contents(); + ob_end_clean(); + + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = false; + $isLowerLoggedIn = false; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["public"] = ob_get_contents(); + ob_end_clean(); + } + + echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json", json_encode($cache)); ?> </div> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/api/fronter.php b/pages/api/fronter.php index 9f70fdc..a908efa 100644 --- a/pages/api/fronter.php +++ b/pages/api/fronter.php @@ -1,5 +1,6 @@ <?php +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; if (!$isLoggedIn || $isLowerLoggedIn) { header("Location: /-/login"); @@ -39,6 +40,8 @@ switch ($type) { if (!isset($list[$date])) $list[$date] = []; $list[$date][] = [$member, null]; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; case "cofront": @@ -57,6 +60,8 @@ switch ($type) { } $list[$date][$index][1] = $member; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; case "delete": @@ -72,6 +77,8 @@ switch ($type) { unset($day[$index]); $list[$date] = array_values($day); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; @@ -87,6 +94,8 @@ switch ($type) { } $list[$date][$index][1] = null; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; @@ -102,6 +111,8 @@ switch ($type) { } moveElement($list[$date], $index, $index + 1 < count($list[$date]) ? $index + 1 : $index); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; @@ -117,6 +128,8 @@ switch ($type) { } moveElement($list[$date], $index, count($list[$date]) - 1); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; @@ -132,6 +145,8 @@ switch ($type) { } moveElement($list[$date], $index, $index - 1 > -1 ? $index - 1 : $index); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; @@ -147,6 +162,8 @@ switch ($type) { } moveElement($list[$date], $index, 0); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + createJob("RefreshCache", []); break; diff --git a/pages/byspecies.inc b/pages/byspecies.inc index e3bdcc4..672493e 100644 --- a/pages/byspecies.inc +++ b/pages/byspecies.inc @@ -1,6 +1,8 @@ -<?php global $system; global $systemCommonName; global $lang; global $pages; global $systemID; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:species"]["name"][$lang["_name"]]; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $travelling; +<?php global $system; global $systemCommonName; global $lang; global $pages; global $systemID; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:species"]["name"][$lang["_name"]]; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $travelling; global $isLowerLoggedIn; global $isLoggedIn; -$members = scoreOrderGlobal(); +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", "{}"); + +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json"), true); function species(array $members, string $id, string $name) { global $systemID; global $travelling; ?> <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 4fr;"> @@ -16,45 +18,71 @@ function species(array $members, string $id, string $name) { global $systemID; g </div> <?php } +function page() { global $lang; + $members = scoreOrderGlobal(); + + $earth = []; + $pegasus = []; + $unicorn = []; + $alicorn = []; + $batpony = []; + $crystal = []; + $changeling = []; + $merpony = []; + + foreach ($members as $member) { + foreach ($member["_metadata"]["species"] as $species) { + if ($species === "earth") $earth[] = $member; + if ($species === "pegasus") $pegasus[] = $member; + if ($species === "unicorn") $unicorn[] = $member; + if ($species === "alicorn") $alicorn[] = $member; + if ($species === "batpony") $batpony[] = $member; + if ($species === "crystal") $crystal[] = $member; + if ($species === "changeling") $changeling[] = $member; + if ($species === "merpony") $merpony[] = $member; + } + } + + species($earth, "earth", $lang["species"]["earth"][3]); + species($pegasus, "pegasus", $lang["species"]["pegasus"][3]); + species($unicorn, "unicorn", $lang["species"]["unicorn"][3]); + species($alicorn, "alicorn", $lang["species"]["alicorn"][3]); + species($batpony, "batpony", $lang["species"]["batpony"][3]); + species($crystal, "crystal", $lang["species"]["crystal"][3]); + species($changeling, "changeling", "Changelings"); + species($merpony, "merpony", "Merponies"); +} + ?> <br> <div class="container" id="page-content"> - <h2><?= str_replace("%1", "All", $lang["species_compare"]["title"]) ?></h2> - <?php - - $earth = []; - $pegasus = []; - $unicorn = []; - $alicorn = []; - $batpony = []; - $crystal = []; - $changeling = []; - $merpony = []; - - foreach ($members as $member) { - foreach ($member["_metadata"]["species"] as $species) { - if ($species === "earth") $earth[] = $member; - if ($species === "pegasus") $pegasus[] = $member; - if ($species === "unicorn") $unicorn[] = $member; - if ($species === "alicorn") $alicorn[] = $member; - if ($species === "batpony") $batpony[] = $member; - if ($species === "crystal") $crystal[] = $member; - if ($species === "changeling") $changeling[] = $member; - if ($species === "merpony") $merpony[] = $member; - } - } + <h2>Members by species</h2> + <?php if (!isset($cache["private"]) || !isset($cache["public"])) { + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = true; + $isLowerLoggedIn = true; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["private"] = ob_get_contents(); + ob_end_clean(); - ?> + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = false; + $isLowerLoggedIn = false; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["public"] = ob_get_contents(); + ob_end_clean(); + } - <?php species($earth, "earth", $lang["species"]["earth"][3]); ?> - <?php species($pegasus, "pegasus", $lang["species"]["pegasus"][3]); ?> - <?php species($unicorn, "unicorn", $lang["species"]["unicorn"][3]); ?> - <?php species($alicorn, "alicorn", $lang["species"]["alicorn"][3]); ?> - <?php species($batpony, "batpony", $lang["species"]["batpony"][3]); ?> - <?php species($crystal, "crystal", $lang["species"]["crystal"][3]); ?> - <?php species($changeling, "changeling", "Changelings"); ?> - <?php species($merpony, "merpony", "Merponies"); ?> + echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", json_encode($cache)); ?> </div> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/home.inc b/pages/home.inc index cc04e42..9686f7f 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -151,9 +151,9 @@ function members() { global $isLoggedIn; global $isLowerLoggedIn; global $app; ? ?> - <div class="alert alert-warning" style="margin-top:20px;"> + <!--<div class="alert alert-warning" style="margin-top:20px;"> <b>Notice:</b> The administrators are currently trying a new optimisation technique based on a virtual file system (chvfs). Data loss, corruption or inconsistency may happen and should be reported on <a href="https://bugs.equestria.dev/issues/CH" target="_blank">bugs.equestria.dev</a>. - </div> + </div>--> <?php diff --git a/pages/metadata.inc b/pages/metadata.inc index b254ceb..2a67e9f 100644 --- a/pages/metadata.inc +++ b/pages/metadata.inc @@ -183,6 +183,11 @@ if ($member === null) { file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json", json_encode($metadata)); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}"); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", "{}"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", "{}"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); + + createJob("RefreshCache", []); header("Location: /" . $_GET['_']); } else { diff --git a/pages/relations.inc b/pages/relations.inc index f872a2f..1c5a878 100644 --- a/pages/relations.inc +++ b/pages/relations.inc @@ -3,86 +3,87 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; global $app; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; -?> +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", "{}"); -<br> -<div class="container"> +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json"), true); + +function page() { global $isLoggedIn; global $isLowerLoggedIn; global $pages; global $lang; global $app; ?> <div id="page-content"> <h2><?= $pages["relations"]["name"][$lang["_name"]] ?></h2> <?php foreach (withCaretakersDown(scoreOrderGlobal()) as $member): ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 2fr 2.25fr 2.25fr 2.25fr 2.25fr;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["name"] ?>"> - <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> - </a> - - <table class="relation-item relation-item-marefriends" style="margin-left:10px;padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["marefriends"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["marefriends"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["marefriends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - - <table class="relation-item relation-item-sisters" style="padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["sisters"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["sisters"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["sisters"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - - <table class="relation-item relation-item-caretakers" style="padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["caretakers"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["caretakers"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["caretakers"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= $marefriend["display_name"] ?? $marefriend["name"] ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - - <table class="relation-item relation-item-friends" style="padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;">Friends:</b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (!isset($member["_metadata"]["friends"]) || count($member["_metadata"]["friends"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["friends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= $marefriend["display_name"] ?? $marefriend["name"] ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - </div> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 2fr 2.25fr 2.25fr 2.25fr 2.25fr;"> + <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["name"] ?>"> + <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + </a> + + <table class="relation-item relation-item-marefriends" style="margin-left:10px;padding:0 20px;"> + <tbody><tr> + <td style="width: 50%;text-align:right;"> + <b style="padding-right:5px;"><?= $lang["relations"]["marefriends"] ?></b><span class="list-separator-mobile"><br></span> + </td> + <td style="width: 50%;text-align:left;"> + <?php if (count($member["_metadata"]["marefriends"]) === 0): ?> + <span class="text-muted"><?= $lang["relations"]["no"] ?></span> + <?php else: ?> + <?php foreach ($member["_metadata"]["marefriends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> + <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> + <?php endif; endforeach; ?> + <?php endif; ?> + </td> + </tr></tbody> + </table> + + <table class="relation-item relation-item-sisters" style="padding:0 20px;"> + <tbody><tr> + <td style="width: 50%;text-align:right;"> + <b style="padding-right:5px;"><?= $lang["relations"]["sisters"] ?></b><span class="list-separator-mobile"><br></span> + </td> + <td style="width: 50%;text-align:left;"> + <?php if (count($member["_metadata"]["sisters"]) === 0): ?> + <span class="text-muted"><?= $lang["relations"]["no"] ?></span> + <?php else: ?> + <?php foreach ($member["_metadata"]["sisters"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> + <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> + <?php endif; endforeach; ?> + <?php endif; ?> + </td> + </tr></tbody> + </table> + + <table class="relation-item relation-item-caretakers" style="padding:0 20px;"> + <tbody><tr> + <td style="width: 50%;text-align:right;"> + <b style="padding-right:5px;"><?= $lang["relations"]["caretakers"] ?></b><span class="list-separator-mobile"><br></span> + </td> + <td style="width: 50%;text-align:left;"> + <?php if (count($member["_metadata"]["caretakers"]) === 0): ?> + <span class="text-muted"><?= $lang["relations"]["no"] ?></span> + <?php else: ?> + <?php foreach ($member["_metadata"]["caretakers"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> + <a title="<?= $marefriend["display_name"] ?? $marefriend["name"] ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> + <?php endif; endforeach; ?> + <?php endif; ?> + </td> + </tr></tbody> + </table> + + <table class="relation-item relation-item-friends" style="padding:0 20px;"> + <tbody><tr> + <td style="width: 50%;text-align:right;"> + <b style="padding-right:5px;">Friends:</b><span class="list-separator-mobile"><br></span> + </td> + <td style="width: 50%;text-align:left;"> + <?php if (!isset($member["_metadata"]["friends"]) || count($member["_metadata"]["friends"]) === 0): ?> + <span class="text-muted"><?= $lang["relations"]["no"] ?></span> + <?php else: ?> + <?php foreach ($member["_metadata"]["friends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> + <a title="<?= $marefriend["display_name"] ?? $marefriend["name"] ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> + <?php endif; endforeach; ?> + <?php endif; ?> + </td> + </tr></tbody> + </table> + </div> <?php endforeach; ?> </div> @@ -115,6 +116,37 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; text-align: center; } </style> +<?php } + +?> + +<br> +<div class="container"> + <?php if (!isset($cache["private"]) || !isset($cache["public"])) { + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = true; + $isLowerLoggedIn = true; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["private"] = ob_get_contents(); + ob_end_clean(); + + ob_start(); + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = false; + $isLowerLoggedIn = false; + page(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + $cache["public"] = ob_get_contents(); + ob_end_clean(); + } + + echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", json_encode($cache)); ?> </div> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/rules.inc b/pages/rules.inc index 967a4b4..23447f2 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -1,5 +1,6 @@ <?php +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/Parsedown.php"; $Parsedown = new Parsedown(); @@ -30,15 +31,21 @@ if (isset($_POST["updateRules"])) { } file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", json_encode($_POST["payload"])); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", "{}"); + createJob("RefreshCache", []); header("Location: /-/rules"); die(); } require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", "{}"); +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json"), true); ?> +<?php if (!isset($cache["content"])): ob_start(); ?> + <br> <div class="container"> <div id="page-content"> @@ -272,5 +279,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; filter: invert(1); } </style> +<?php $cache["content"] = ob_get_contents(); ob_end_clean(); endif; +echo($cache["content"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", json_encode($cache)); ?> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/splitting.inc b/pages/splitting.inc index d1dccae..2f5fa39 100644 --- a/pages/splitting.inc +++ b/pages/splitting.inc @@ -3,10 +3,15 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json", "{}"); + +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json"), true); + ?> <br> <div class="container"> + <?php if (!isset($cache["content"])): ob_start(); ?> <div id="page-content"> <h2>Members by splitting date</h2> <?php $members = scoreOrderGlobal(); uasort($members, function ($a, $b) { @@ -50,6 +55,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; } } </style> + <?php $cache["content"] = ob_get_contents(); ob_end_clean(); endif; + echo($cache["content"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json", json_encode($cache)); ?> </div> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/stats.inc b/pages/stats.inc index de501bb..742fb87 100644 --- a/pages/stats.inc +++ b/pages/stats.inc @@ -3,8 +3,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; -$switchesRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/switches.json"), true); -$switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/switches.json"), true); +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/stats.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/stats.json", "{}"); + +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/stats.json"), true); ?> @@ -16,6 +17,11 @@ $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . <h2>Statistics</h2> <?php + if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]): ob_start(); + + $switchesRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/switches.json"), true); + $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/switches.json"), true); + $weeks = []; $weeksRectified = []; @@ -486,6 +492,12 @@ $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . } }); </script> + <?php $cache["content"] = ob_get_contents(); $cache["day"] = date('Y-m-d'); ob_end_clean(); endif; + + echo($cache["content"]); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/stats.json", json_encode($cache)); + + ?> </div> </div> diff --git a/pages/travelling.inc b/pages/travelling.inc index 687b9f2..9eadaed 100644 --- a/pages/travelling.inc +++ b/pages/travelling.inc @@ -99,6 +99,7 @@ if (isset($_GET['toggleTravel']) && $isLoggedIn) { file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}"); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); + createJob("RefreshCache", []); header("Location: /-/travelling"); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT))); |