4in1_ws_web/classes/handler/admin/AutoDelete.php
2023-12-30 23:29:31 +00:00

34 lines
722 B
PHP

<?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();
}
}