aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 15:04:59 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 15:05:05 +0200
commitd7c2e638a5ea39caeadd40406f840e9b90f893d5 (patch)
tree3568f96aa508e01b9c7ee34cba261f4e16d186a2 /controllers
parentd6dcab722a4e4f3472d3e4128bd6f4a6d5661a31 (diff)
downloadnowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.tar
nowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.tar.gz
nowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.zip
feat(views/archive): Implement archive deletion
Diffstat (limited to 'controllers')
-rw-r--r--controllers/archive.php34
1 files changed, 34 insertions, 0 deletions
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;