diff options
| -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}"; |
