diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-26 16:46:05 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-26 16:46:05 +0200 |
| commit | 229266ebc87133e3f81d19d5e1750fa8419b5b0f (patch) | |
| tree | 2765ea5b448618a4680562d4fbf11cef0c7478b0 /controllers/archive.php | |
| parent | 6596a76c856e2ddfccbc5f03d12a524fdf80e1bf (diff) | |
| download | nowayforward_human-229266ebc87133e3f81d19d5e1750fa8419b5b0f.tar nowayforward_human-229266ebc87133e3f81d19d5e1750fa8419b5b0f.tar.gz nowayforward_human-229266ebc87133e3f81d19d5e1750fa8419b5b0f.zip | |
feat(archive): Set the user when someone logged-in archives
Diffstat (limited to 'controllers/archive.php')
| -rw-r--r-- | controllers/archive.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/controllers/archive.php b/controllers/archive.php index 0d21a1e..6057a4a 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -2,12 +2,20 @@ namespace Controller; use Database; use DOMDocument; +use Exception; function on_post() { $WEBSITE_CATEGORY = 'page_url'; $DOWNLOADS_FOLDER = getenv('ARCHIVES_DIR'); $website_url = $_POST[$WEBSITE_CATEGORY]; - $currentPage = new DownloadPage($website_url, $DOWNLOADS_FOLDER); + $uid = 1; + if (array_key_exists('token', $_POST) && strlen($_POST['token']) === 36) { + try { + $uid = Database\Cookie::fromDB($_POST['token'])->UID; + } + catch (Exception $e) {} + } + $currentPage = new DownloadPage($website_url, $DOWNLOADS_FOLDER, $uid); } class DownloadPage { @@ -18,7 +26,7 @@ class DownloadPage { private $favicon_path; private $page_title; - function __construct($page_url, $folder_location) { + function __construct($page_url, $folder_location, $requester_uid) { $this->folder_location = $folder_location; $this->page_url = $page_url; list($website_exists, $this->page_url) = $this->doesWebsiteExist($this->page_url); @@ -34,7 +42,7 @@ class DownloadPage { // Fallback and try to download them from the server directly $this->tryDownloadFavicon(); } - Database\Webpage::create($folder_location, $page_url, 1, $this->favicon_path, $this->page_title); + Database\Webpage::create($folder_location, $page_url, $requester_uid, $this->favicon_path, $this->page_title); } else { echo "Website does not exist"; } |
