<?php

/* DCMS Special
 * Дата последнего редактирования 10.10.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../../sys/inc/$inc.php";
}

$news = $db->get_array($db->query("SELECT * FROM `news` WHERE `id` = '" . intval($_GET['delete']) . "' LIMIT 1"));

$k = $db->super_query("SELECT COUNT(*) as count FROM `news` WHERE `id` = '$news[id]'");

if ($k['count'] == 0) {
    header("Location:?");
    exit;
}
unset($k);

if (access('adm_news_delete')) {
    if (isset($_GET['ok'])) {
        $db->query("DELETE FROM `news_like` WHERE `id_news` = '$news[id]' LIMIT 1");
        $db->query("DELETE FROM `news_hide` WHERE `nid` = '$news[id]' LIMIT 1");
        $db->query("DELETE FROM `news_komm` WHERE `id_news` = '$news[id]' LIMIT 1");
        $db->query("DELETE FROM `news` WHERE `id` = '$news[id]' LIMIT 1");
        
        $_SESSION['message'] = lang('Новость успешно удалена');
        header("Location: ?");
    }

    err();

    #Навигация
    echo "<div class='list-group-item-null list-group-item-grey'><small>";
    echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_NEWS . "'>" . lang('Новости') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='" . DIR_NEWS . "?news=$news[id]'>" . cutStr($news['title'], 30) . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo lang('Удаление');
    echo "</small></div><br />";

    echo "<div class='list-group-item-null list-group-item-grey'>";
    echo lang('Вы действительно хотите удалить эту новость') . "?<br />";
    echo "<a href='?delete=$news[id]&amp;ok' class='btn btn-success btn-sm'><i class='fa fa-trash-o fa-fw'></i> " . lang('Да') . "</a> ";
    echo "<a href='?news=$news[id]' class='btn btn-secondary btn-sm'>" . lang('Нет') . "</a> ";
    echo "</div>";
}

