summaryrefslogtreecommitdiff
path: root/handler/admin/AutoDelete.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
commitf7bfdf58def6aadc922e1632f407d1418269a0d7 (patch)
treed7a0b2819e6a26c11d40ee0b27267ea827fbb345 /handler/admin/AutoDelete.php
initial
Diffstat (limited to 'handler/admin/AutoDelete.php')
-rw-r--r--handler/admin/AutoDelete.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/handler/admin/AutoDelete.php b/handler/admin/AutoDelete.php
new file mode 100644
index 0000000..80c8eef
--- /dev/null
+++ b/handler/admin/AutoDelete.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace handler\admin;
+
+use csrf;
+use NotFoundException;
+use pages;
+use posts;
+use RedirectResponse;
+use Response;
+
+class AutoDelete extends AdminRequestHandler {
+
+ public function get(): Response {
+ list($name) = $this->input('short_name');
+
+ $post = posts::getPostByName($name);
+ if ($post) {
+ csrf::check('delpost'.$post->id);
+ posts::delete($post);
+ return new RedirectResponse('/');
+ }
+
+ $page = pages::getPageByName($name);
+ if ($page) {
+ csrf::check('delpage'.$page->shortName);
+ pages::delete($page);
+ return new RedirectResponse('/');
+ }
+
+ throw new NotFoundException();
+ }
+
+} \ No newline at end of file