Compare commits

...
2 Commits
Author SHA1 Message Date
0xa0 ead99e6769 Merge branch 'main' of https://git.0xa0.dev/0xA0/0xa0.dev
Deploy / deploy (push) Successful in 4s
2026-07-22 16:35:26 +02:00
0xa0 6e6052483c faster poll 2026-07-22 16:35:17 +02:00
4 changed files with 7 additions and 15 deletions
+1
View File
@@ -1,5 +1,6 @@
<?php
const DISCORD_ID = '298221448642953217';
const SITE_TITLE = '0xA0.dev';
const REPO_URL = 'https://git.0xa0.dev';
define('DATA_DIR', getenv('DATA_DIR') ?: '/var/www/data');
+1 -1
View File
@@ -5,7 +5,7 @@
<div class="buttons88x31">
<?= render_buttons_88x31() ?>
</div>
<small>&copy; <?= date('Y') ?> · <a href="https://git.0xa0.dev">source</a> · build: <?= htmlspecialchars($build) ?></small>
<small>&copy; <?= date('Y') ?> · <a href="<?= htmlspecialchars(REPO_URL) ?>">build <?= htmlspecialchars($build) ?></a></small>
</footer>
</body>
</html>
+1 -1
View File
@@ -5,7 +5,7 @@
<section class="status-widget">
<h2>status</h2>
<div id="status" hx-get="/status.php" hx-trigger="every 10s" hx-ext="morph" hx-swap="morph:innerHTML">
<div id="status" hx-get="/status.php" hx-trigger="every 3s" hx-ext="morph" hx-swap="morph:innerHTML">
<?php include __DIR__ . '/status.php'; ?>
</div>
</section>
+4 -13
View File
@@ -2,7 +2,7 @@
require_once __DIR__ . '/config.php';
$cacheFile = DATA_DIR . '/lanyard.json';
$ttl = 15;
$ttl = 2;
if (!function_exists('lanyard_refresh')) {
function lanyard_refresh(string $cacheFile): void {
@@ -21,12 +21,11 @@ if (!function_exists('lanyard_refresh')) {
}
}
$haveCache = is_file($cacheFile);
$stale = !$haveCache || (time() - filemtime($cacheFile) > $ttl);
$isPoll = realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__;
$stale = !is_file($cacheFile) || (time() - filemtime($cacheFile) > $ttl);
if ($stale && !$haveCache) {
if ($stale && ($isPoll || !is_file($cacheFile))) {
lanyard_refresh($cacheFile);
$stale = false;
}
$data = json_decode(@file_get_contents($cacheFile), true)['data'] ?? null;
@@ -83,11 +82,3 @@ $banner = $bannerHash
</div>
<?php endif; ?>
</div>
<?php
if ($stale && realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__) {
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
lanyard_refresh($cacheFile);
}
?>