From d7c2e638a5ea39caeadd40406f840e9b90f893d5 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 15:04:59 +0200 Subject: feat(views/archive): Implement archive deletion --- controllers/archive.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'controllers') diff --git a/controllers/archive.php b/controllers/archive.php index fd278ff..367acc7 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -23,6 +23,40 @@ function on_post() { exit(); } +function on_delete() { + global $TOKEN; + global $METHOD; + global $page_status; + + $webpage = null; + try { + $webpage = Database\Webpage::fromDBwid($METHOD['wid']); + } + catch(Exception $e) { + $page_status = "This webpage doesn't exist!"; + return; + } + + $user = null; + try { + $user = Database\Cookie::fromDB($TOKEN); + } + catch(Exception $e) { + $list_status = "Invalid cookie!"; + return; + } + + if ($user->Role !== 'Admin') { + $list_status = "You're not authorized to delete archives!"; + return; + } + + $webpage->delete(); + + header('Location: /archive/?url=' . $webpage->URL); + exit(); +} + class DownloadPage { private $folder_location; private $folder_name; -- cgit v1.2.3