serve 88x31 buttons from cache URLs instead of base64, preload the art font
Deploy / deploy (push) Successful in 3s

This commit is contained in:
2026-10-03 15:27:54 +02:00
parent 2e80e535b3
commit 2201006b24
3 changed files with 39 additions and 16 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
// Serves an 88x31 button from the local cache (see inc/buttons.php).
require_once __DIR__ . '/config.php';
$h = $_GET['h'] ?? '';
$file = DATA_DIR . '/buttons/' . $h;
if (!preg_match('/^[0-9a-f]{32}$/', $h) || !is_file($file)) {
http_response_code(404);
exit;
}
$raw = (string) file_get_contents($file);
$nl = strpos($raw, "\n");
$type = $nl !== false ? substr($raw, 0, $nl) : '';
if (!preg_match('#^image/[\w.+-]+$#', $type)) {
http_response_code(404);
exit;
}
header('Content-Type: ' . $type);
header('Cache-Control: public, max-age=31536000, immutable'); // URL carries ?v=<mtime>
echo substr($raw, $nl + 1);