diff options
Diffstat (limited to 'handler/admin/AutoDelete.php')
-rw-r--r-- | handler/admin/AutoDelete.php | 34 |
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 |