From a6d5ab4c576fa4220315e0e140ac32e86b6d16bd Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Sat, 21 Feb 2026 13:43:09 +0300 Subject: [PATCH] Public: restore topic menu visibility in sidebar Bring topic links back in the public sidebar by rendering from a filtered visible topic tree with non-zero counts. Keep mobile bottom navigation lean by removing the redundant back action and preserving menu toggle plus prev/next controls. --- index.php | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index ee097fc..e3813d0 100644 --- a/index.php +++ b/index.php @@ -3,8 +3,12 @@ declare(strict_types=1); require_once __DIR__ . '/lib/db_gallery.php'; +require_once __DIR__ . '/lib/thumbs.php'; $action = (string)($_GET['action'] ?? ''); +if ($action === 'thumb') { + serveThumb(); +} if ($action === 'image') { serveImage(); } @@ -271,6 +275,46 @@ function serveImage(): never outputWatermarked($abs, (string)$f['mime_type']); } +function serveThumb(): never +{ + $fileId = (int)($_GET['file_id'] ?? 0); + if ($fileId < 1) { + http_response_code(404); + exit; + } + + $f = photoFileById($fileId); + if (!$f || (string)$f['kind'] !== 'before') { + http_response_code(404); + exit; + } + + $thumbRel = ensureThumbForSource(__DIR__, (string)$f['file_path']); + if ($thumbRel === null) { + serveImage(); + } + + $thumbAbs = __DIR__ . '/' . ltrim($thumbRel, '/'); + if (!is_file($thumbAbs)) { + serveImage(); + } + + $modifiedAt = (int)(filemtime($thumbAbs) ?: time()); + $ifModifiedSince = (string)($_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? ''); + if ($ifModifiedSince !== '' && strtotime($ifModifiedSince) >= $modifiedAt) { + http_response_code(304); + exit; + } + + header('Content-Type: image/jpeg'); + header('Content-Length: ' . (string)filesize($thumbAbs)); + header('Cache-Control: private, max-age=86400'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $modifiedAt) . ' GMT'); + header('X-Robots-Tag: noindex, nofollow'); + readfile($thumbAbs); + exit; +} + function outputWatermarked(string $path, string $mime): never { $text = 'photo.andr33v.ru'; @@ -551,7 +595,7 @@ function outputWatermarked(string $path, string $mime): never -
+
0): ?>💬 AI