24 lines
720 B
PHP
24 lines
720 B
PHP
<?php
|
|
|
|
phpb_requires_authenticated();
|
|
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
|
|
http_response_code(405);
|
|
exit();
|
|
}
|
|
if (!phpb_validate_csrf()) {
|
|
http_response_code(403);
|
|
exit();
|
|
}
|
|
|
|
$deleted = false;
|
|
try {
|
|
if (isset($_POST['id']) && is_string($_POST['id']) && ctype_digit($_POST['id']) && (int) $_POST['id'] > 0) {
|
|
$deleted = (new \Plugi\Extensions\Blog\PostsRepository())->destroy((int) $_POST['id']);
|
|
}
|
|
} catch (\Throwable) {
|
|
$deleted = false;
|
|
}
|
|
phpb_redirect(phpb_url('website_manager', ['tab' => 'ext--blog', 'action' => 'posts']), [
|
|
'message-type' => $deleted ? 'success' : 'error',
|
|
'message' => $deleted ? 'Post deleted.' : 'The post could not be deleted.',
|
|
]); |