commit 53da95395aad137bd0ab2b2f4ed1e9e3cb00c962 Author: Sebastian Korotkiewicz Date: Sat Mar 19 09:17:55 2022 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e5fe92 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Sites Roulette + +My simple application to view user pages on a given server, + +curl.php gets the data from the main page of the server, parses it and writes to the database, thanks to cron you can easily update the database for example once a day. + +it's a very simple script, if you want to run it, you need to personalize some things, like the name of your home directory or regex to download users + +to change: + +- public_html/browser/get.php + + - require_once('/home/grizzly/store/browser/db.php'); + - die(header("Location: https://tilde.team/~grizzly/browser/?member=" . $row['login_name'])); + +- public_html/browser/index.php + + - s/tilde.team/you.website/ + +- store/browser/curl.php + + - require_once ('/home/grizzly/store/browser/db.php'); + - curl_setopt($c, CURLOPT_URL,'https://tilde.team/'); + - preg*match_all('/
  • ~(.\_)<\/a><\/li>/', $data, $matches); + +- store/browser/update.sh + +and add cron.txt content to your cron: `crontab -e` + +--- + +the script was created out of "need", I wanted to browse all user pages and I didn't want to open thousands of tabs, so this is "sites roulette". + +you can modify it, share it freely + +--- + +if you want to change or improve something, clone the repo, add changes, upload to some git server and send me the link, if you are a user of tilde.institute, send me an email with the path to your repo on the server + +=> grizzly/at/nand.sh diff --git a/cron.txt b/cron.txt new file mode 100644 index 0000000..76bebd9 --- /dev/null +++ b/cron.txt @@ -0,0 +1,8 @@ +#minute (0-59), +#| hour (0-23), +#| | day of the month (1-31), +#| | | month of the year (1-12), +#| | | | day of the week (0-6 with 0=Sunday). +#| | | | | commands + +0 0 * * * /home/grizzly/store/browser/update.sh > /dev/null 2>&1 \ No newline at end of file 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 @@ +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 diff --git a/public_html/browser/index.php b/public_html/browser/index.php new file mode 100644 index 0000000..08aecd6 --- /dev/null +++ b/public_html/browser/index.php @@ -0,0 +1,87 @@ + + + + + + + Members websites on tilde.team + + +
    +
    + +
    +
    +
    + you are viewing + + site +
    +
    + + [previous] + + [random] + + [next] + +
    +
    user list cache is updated once a day
    +
    +
    + + + + \ No newline at end of file diff --git a/store/browser/curl.php b/store/browser/curl.php new file mode 100644 index 0000000..2692108 --- /dev/null +++ b/store/browser/curl.php @@ -0,0 +1,20 @@ +~(.*)<\/a><\/li>/', $data, $matches); + +foreach ($matches[1] as $user) { + $stmt = $db->prepare("INSERT INTO `websites` (login_name) VALUES(:login_name)"); + $stmt->bindParam(':login_name', $user); + $stmt->execute(); +} + + +?> \ No newline at end of file diff --git a/store/browser/db.php b/store/browser/db.php new file mode 100644 index 0000000..bfe73d8 --- /dev/null +++ b/store/browser/db.php @@ -0,0 +1,23 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$query = "CREATE TABLE IF NOT EXISTS websites +(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + login_name TEXT +)"; + +$db->exec($query); + +function cleanText($value) { + $value = strip_tags($value); + $value = htmlentities($value, ENT_QUOTES, "UTF-8"); + $value = trim($value); + $value = stripslashes($value); + $value = strval($value); + return $value; +} + +?> \ No newline at end of file diff --git a/store/browser/update.sh b/store/browser/update.sh new file mode 100644 index 0000000..1ea2a64 --- /dev/null +++ b/store/browser/update.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rm /home/grizzly/store/browser/db_websites.sqlite3; +php /home/grizzly/store/browser/curl.php; \ No newline at end of file