40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
// ============================================================
|
|
// FILE 1: /gif/index.php
|
|
// Visited when someone pastes sistav.com/gif into Discord
|
|
// ============================================================
|
|
|
|
$token = bin2hex(random_bytes(8));
|
|
$base_url = 'https://sistav.com';
|
|
$gif_url = $base_url . '/assets/gif.php?t=' . $token;
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:url" content="<?= $base_url ?>/gif">
|
|
<meta property="og:image" content="<?= htmlspecialchars($gif_url) ?>">
|
|
<meta property="og:image:type" content="image/gif">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:image" content="<?= htmlspecialchars($gif_url) ?>">
|
|
<meta http-equiv="refresh" content="0; url=/">
|
|
</head>
|
|
<body></body>
|
|
</html>
|
|
|
|
<?php
|
|
// ============================================================
|
|
// FILE 2: /assets/gif.php
|
|
// Streams a random GIF — t= token is ignored, just busts cache
|
|
// ============================================================
|
|
|
|
$gif_files = glob(__DIR__ . '/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');
|
|
readfile($file);
|
|
exit;
|