final api

This commit is contained in:
2026-02-22 15:26:16 -05:00
parent bf599f8e6d
commit 13b0b8c0ba
3 changed files with 24 additions and 20 deletions
-9
View File
@@ -1,9 +0,0 @@
<?php
$gif_files = glob($_SERVER['DOCUMENT_ROOT'] . '/assets/gifs/*.gif');
if (empty($gif_files)) { http_response_code(404); exit; }
$file = basename($gif_files[array_rand($gif_files)]);
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Location: /assets/gifs/' . rawurlencode($file), true, 302);
exit;
+24
View File
@@ -0,0 +1,24 @@
<?php
$gif_files = glob($_SERVER['DOCUMENT_ROOT'] . '/assets/gifs/*.gif');
$gifs = array_map(fn($f) => '/assets/gifs/' . basename($f), $gif_files);
$base_url = 'https://sistav.com';
$path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
// /gif/random — serve a random gif
if ($path === 'gif/random') {
if (empty($gifs)) { http_response_code(404); exit; }
$file = $gif_files[array_rand($gif_files)];
header('Content-Type: image/gif');
header('Content-Length: ' . filesize($file));
header('Cache-Control: no-store, no-cache, must-revalidate');
readfile($file);
exit;
}
// /gif — return JSON list
header('Content-Type: application/json');
echo json_encode([
'count' => count($gifs),
'gifs' => array_map(fn($g) => $base_url . $g, $gifs)
]);
-11
View File
@@ -1,11 +0,0 @@
<?php
$gif_files = glob($_SERVER['DOCUMENT_ROOT'] . '/assets/gifs/*.gif');
if (empty($gif_files)) { http_response_code(404); exit; }
$file = $gif_files[array_rand($gif_files)];
header('Content-Type: image/gif');
header('Content-Length: ' . filesize($file));
header('Cache-Control: no-store, no-cache, must-revalidate');
readfile($file);
exit;