summaryrefslogtreecommitdiff
path: root/pages/alphabet.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/alphabet.inc')
-rw-r--r--pages/alphabet.inc51
1 files changed, 42 insertions, 9 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'; ?>