From 13b0b8c0ba869149a1a554a956da0cd6987e99af Mon Sep 17 00:00:00 2001 From: sistav Date: Sun, 22 Feb 2026 15:26:16 -0500 Subject: [PATCH] final api --- gif.php | 9 --------- gif/index.php | 24 ++++++++++++++++++++++++ test/index.php | 11 ----------- 3 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 gif.php create mode 100644 gif/index.php delete mode 100644 test/index.php diff --git a/gif.php b/gif.php deleted file mode 100644 index f59eb55..0000000 --- a/gif.php +++ /dev/null @@ -1,9 +0,0 @@ - '/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) +]); \ No newline at end of file diff --git a/test/index.php b/test/index.php deleted file mode 100644 index fbc86be..0000000 --- a/test/index.php +++ /dev/null @@ -1,11 +0,0 @@ -