Remove index.html, add parameter to chose quote

This commit is contained in:
floppydiskette 2024-09-04 14:36:36 +01:00
parent cbd71c4cf4
commit a002cfc13e
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
2 changed files with 6 additions and 24 deletions

View file

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weh?</title>
<link rel="stylesheet" href="weh.css">
<link rel="icon" type="image/x-icon" href="weh.ico">
<meta property="og:title" content="Weh?">
<meta property="og:description" content="Can it fangs! You don't know diddly dang about squiddly squat!">
<meta property="og:image" content="/weh.png">
</head>
<body>
<div class="container">
<h1>Weh?</h1>
<div class="weh"></div>
<script src="./weh.js"></script>
</div>
</body>
</html>

View file

@ -2,7 +2,12 @@
$quotes = file_get_contents('weh.json'); $quotes = file_get_contents('weh.json');
if ($quotes !== false) { if ($quotes !== false) {
$quotes = json_decode($quotes, true); $quotes = json_decode($quotes, true);
$quote = $quotes[array_rand($quotes)]; if (isset($_GET['idx']) && ctype_digit($_GET['idx']) && $_GET['idx'] < count($quotes)) {
$index = $_GET['idx'];
} else {
$index = array_rand($quotes);
}
$quote = $quotes[$index];
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>