24 lines
598 B
PHP
24 lines
598 B
PHP
<?php
|
|
require_once __DIR__ . '/auth.php';
|
|
requireLogin();
|
|
|
|
$db = getDB();
|
|
$postId = intval($_GET['id'] ?? 0);
|
|
|
|
if ($postId > 0) {
|
|
// Verify post exists
|
|
$stmt = $db->prepare("SELECT id, cover_image FROM blog_posts WHERE id = :id LIMIT 1");
|
|
$stmt->execute([':id' => $postId]);
|
|
$post = $stmt->fetch();
|
|
|
|
if ($post) {
|
|
// Delete post
|
|
$stmt = $db->prepare("DELETE FROM blog_posts WHERE id = :id");
|
|
$stmt->execute([':id' => $postId]);
|
|
$_SESSION['flash'] = 'Artículo eliminado correctamente.';
|
|
}
|
|
}
|
|
|
|
header('Location: ' . BLOG_URL . '/admin/');
|
|
exit;
|