diff options
author | Sebastian Korotkiewicz <skorotkiewicz@gmail.com> | 2022-03-19 09:17:55 +0100 |
---|---|---|
committer | Sebastian Korotkiewicz <skorotkiewicz@gmail.com> | 2022-03-19 09:17:55 +0100 |
commit | 53da95395aad137bd0ab2b2f4ed1e9e3cb00c962 (patch) | |
tree | b101ce45b258711180a1cc16fcc27bdf5d252241 /public_html/browser/get.php | |
download | site_roulette-53da95395aad137bd0ab2b2f4ed1e9e3cb00c962.tar.gz |
Initial commit
Diffstat (limited to 'public_html/browser/get.php')
-rw-r--r-- | public_html/browser/get.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/public_html/browser/get.php b/public_html/browser/get.php new file mode 100644 index 0000000..fa346c3 --- /dev/null +++ b/public_html/browser/get.php @@ -0,0 +1,35 @@ +<?php + +require_once('/home/grizzly/store/browser/db.php'); + +$member = $_GET['member']; + +if (isset($_GET["random"]) || !isset($member)) { + $stmt = $db->prepare("SELECT * FROM `websites` ORDER BY RANDOM() LIMIT 1;"); + $stmt->execute(); + $row = $stmt->fetch(); + + die(header("Location: https://tilde.team/~grizzly/browser/?member=" . $row['login_name'])); +} else { + $stmt = $db->prepare("SELECT * FROM `websites` WHERE login_name = :login_name;"); + $stmt->execute(array(':login_name' => $member)); + $row = $stmt->fetch(); // works + + $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id > :id;"); + $stmt->execute(array(':id' => $row['id'])); + $next = $stmt->fetch(); // works + + $stmt = $db->prepare("SELECT login_name FROM `websites` WHERE id < :id;"); + $stmt->execute(array(':id' => $row['id'])); + $prev = $stmt->fetch(); // always return first record from database, why? +} + +$current = $row["login_name"]; +$next = $next["login_name"] ? $next["login_name"] : null; +$prev = $prev["login_name"] ? $prev["login_name"] : null; + +// echo "current: " . $current . "\n"; +// echo "next: " . $next . "\n"; +// echo "prev: " . $prev . "\n"; + +?> \ No newline at end of file |