Update index.php
This commit is contained in:
+32
-20
@@ -1,25 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
$gif_files = glob($_SERVER['DOCUMENT_ROOT'] . '/assets/gifs/*.gif');
|
$gif_files = glob($_SERVER['DOCUMENT_ROOT'] . '/assets/gifs/*.gif');
|
||||||
$gifs = array_map(fn($f) => '/assets/gifs/' . basename($f), $gif_files);
|
$gif_files = array_values($gif_files);
|
||||||
$random = !empty($gifs) ? $gifs[array_rand($gifs)] : '';
|
|
||||||
|
|
||||||
$base_url = 'https://sistav.com';
|
// If a specific GIF was requested via ?id=, serve its embed
|
||||||
$gif_url = $base_url . $random;
|
if (isset($_GET['id'])) {
|
||||||
?>
|
$id = (int)$_GET['id'];
|
||||||
<!DOCTYPE html>
|
$gif = isset($gif_files[$id])
|
||||||
<html>
|
? '/assets/gifs/' . basename($gif_files[$id])
|
||||||
<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">
|
|
||||||
|
|
||||||
<!-- Twitter/Discord animated GIF support -->
|
$base_url = 'https://sistav.com';
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
$gif_url = $base_url . $gif;
|
||||||
<meta name="twitter:image" content="<?= htmlspecialchars($gif_url) ?>">
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:url" content="<?= $base_url ?>/gif?id=<?= $id ?>">
|
||||||
|
<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
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
<!-- Redirect real visitors to the homepage -->
|
// No ?id= — pick a random GIF and redirect to its unique URL
|
||||||
<meta http-equiv="refresh" content="0; url=/">
|
// The random token makes the URL unique so Discord won't serve a cached embed
|
||||||
</head>
|
$id = array_rand($gif_files);
|
||||||
<body></body>
|
$token = bin2hex(random_bytes(4)); // e.g. ?id=3&t=a1b2c3d4
|
||||||
</html>
|
header("Location: /gif?id={$id}&t={$token}");
|
||||||
|
exit;
|
||||||
Reference in New Issue
Block a user