diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-19 08:31:56 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-19 08:31:56 +0200 |
| commit | 98074f4ba13d5937b51dd1da98a4abb08beece5e (patch) | |
| tree | 5e99fc2a9415e6856b9253dd2d866a3696a0aa61 | |
| parent | b7e04cbf3824a8d5cd535c8cb00a6a697b977bf9 (diff) | |
| download | nowayforward_human-98074f4ba13d5937b51dd1da98a4abb08beece5e.tar nowayforward_human-98074f4ba13d5937b51dd1da98a4abb08beece5e.tar.gz nowayforward_human-98074f4ba13d5937b51dd1da98a4abb08beece5e.zip | |
feat(archive_page): Add archived pages to the database
| -rw-r--r-- | controllers/archive_page.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/controllers/archive_page.php b/controllers/archive_page.php index ff766dd..7f62d7b 100644 --- a/controllers/archive_page.php +++ b/controllers/archive_page.php @@ -4,7 +4,7 @@ function on_post() { $WEBSITE_CATEGORY = 'page_url'; $DOWNLOADS_FOLDER = getenv('ARCHIVES_DIR'); $website_url = $_POST[$WEBSITE_CATEGORY]; - $currentPage = new DownloadPage($website_url, "test2.zip", $DOWNLOADS_FOLDER); + $currentPage = new DownloadPage($website_url, $DOWNLOADS_FOLDER); } class DownloadPage { @@ -13,12 +13,12 @@ class DownloadPage { private $page_url; private $page_contents; - function __construct($page_url, $zip_name, $zip_location) { + function __construct($page_url, $zip_location) { $this->zip_location = $zip_location; - $this->zip_name = $zip_name; $this->page_url = $page_url; list($website_exists, $this->page_url) = $this->does_website_exist($this->page_url); if ($website_exists) { + $this->zip_name = Database\Webpage::create($zip_location, $page_url, 1) . '.zip'; $this->page_contents = file_get_contents($this->page_url); $zip = $this->create_zip_archive(); } else { @@ -76,7 +76,7 @@ class DownloadPage { function create_zip_archive() { // Creates and returns a zip object resulted from zipping the page that was downloaded $zip = new ZipArchive(); - if ($zip->open($this->zip_location . '/' . $this->zip_name, ZipArchive::CREATE | ZipArchive::OVERWRITE) == TRUE) { + if ($zip->open($this->zip_location . '/' . $this->zip_name, ZipArchive::CREATE) === TRUE) { $zip->addFromString('index.html', $this->page_contents); $zip->close(); echo "Archived {$this->page_url}"; |
