diff options
Diffstat (limited to 'store/browser')
-rw-r--r-- | store/browser/curl.php | 20 | ||||
-rw-r--r-- | store/browser/db.php | 23 | ||||
-rw-r--r-- | store/browser/update.sh | 3 |
3 files changed, 46 insertions, 0 deletions
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 @@ +<?php + +require_once ('/home/grizzly/store/browser/db.php'); + +$c = curl_init(); +curl_setopt($c, CURLOPT_URL,'https://tilde.team/'); +curl_setopt($c, CURLOPT_RETURNTRANSFER, true); +$data = curl_exec($c); +curl_close($c); + +preg_match_all('/<li><a href="\/~(.*)\/" class=\"list-group-item col-xs-6 col-sm-4 col-md-2\">~(.*)<\/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 @@ +<?php + +$db = new PDO('sqlite:db_websites.sqlite3'); + +$db->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 |