<?php

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

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

$news = mysql_fetch_array(mysql_query("SELECT * FROM `news` WHERE `id` = '" . intval($_GET['delete']) . "' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` = '$news[id]'"), 0) == 0) {
    header("Location:?");
    exit;
}

if (access('adm_news_delete')) {
    if (isset($_GET['ok'])) {
        mysql_query("DELETE FROM `news_like` WHERE `id_news` = '$news[id]' LIMIT 1");
        mysql_query("DELETE FROM `news_hide` WHERE `nid` = '$news[id]' LIMIT 1");
        mysql_query("DELETE FROM `news_komm` WHERE `id_news` = '$news[id]' LIMIT 1");
        mysql_query("DELETE FROM `news` WHERE `id` = '$news[id]' LIMIT 1");
        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='/modules/news/'>" . lang('Новости') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
    echo "<a href='/modules/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 "Вы действительно хотите удалить эту новость?<br />";
    echo "<a href='?delete=$news[id]&amp;ok' class='btn btn-success btn-sm'><i class='fa fa-trash-o fa-fw'></i>Да</a> ";
    echo "<a href='?news=$news[id]' class='btn btn-secondary btn-sm'>Нет</a> ";
    echo "</div>";
}

