<?php
define('NTLCMS', 1);
$module = 'delete';
include ('../system/start.php');
include ('../system/function.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
if ($_USER['admin'] == '1'){
$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT) : '0';
if (isset($_GET['id']) && DB :: run() -> querySingle("select * from `chat` where `id` = ?", array($id)) != 0){
DB :: run() -> query("delete from `chat` where `id` = ? limit 1", array($id));
header('Location: '.URL.'/chats');
$_SESSION['success'] = 'Пост успешно удален!';
} else {
header('Location: '.URL.'/chats');
$_SESSION['fail'] = 'Пост не удален!';
}
} else {
header('Location: '.URL);
$_SESSION['fail'] = 'Доступ запрещен!';
}
?>