<?
echo "<div class='app-block'>";
if (isset($_GET['yes']))
{
    if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog_files` WHERE `id_blog` = '".$note['id']."'") > 0)
    {
        $query_f = DB :: $pdo -> query("SELECT * FROM `blog_files` WHERE `id_blog` = '".$note['id']."' ORDER BY `id` DESC");
        while($r_f = $query_f -> fetch())
        {
            if (is_file("".FILES_PATH."/blog_files/".$r_f['id']."_m.jpg"))
            {
                unlink("".FILES_PATH."/blog_files/".$r_f['id']."_m.jpg");
            }
            if (is_file("".FILES_PATH."/blog_files/".$r_f['id'].".jpg"))
            {
                unlink("".FILES_PATH."/blog_files/".$r_f['id'].".jpg");
            }
        }
        DB :: $pdo -> query("DELETE FROM `blog_files` WHERE `id_blog` = '".$note['id']."'");
    }
    if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog_comments` WHERE `id_note` = '".$note['id']."'") > 0)
    {
        DB :: $pdo -> query("DELETE FROM `blog_comments` WHERE `id_note` = '".$note['id']."'");
    }
    
    DB :: $pdo -> query("DELETE FROM `blog` WHERE `id` = '".$note['id']."' LIMIT 1");
    system :: redirect("Запись успешно удалена.", "/blog/?id=".$ank['id']."");
} else {
    ?>
    <div class="list">
        <div class="list_blog66">
            Вы уверены, что хотите удалить эту запись?
        </div>
        <div class="list_blog67">
            <div class="list_blog68">
                <table class="list_blog69"><tr>
                    <td class="list_blog70">
                        <a class="list_blog71" href="/blog/?note=<?echo $note['id'];?>&dell&yes">Да</a>
                    </td>
                    <td class="list_blog72">
                        <a class="list_blog73" href="/blog/?note=<?echo $note['id'];?>">Нет</a>
                    </td>
                </tr></table>
            </div>
        </div>
    </div>
    <?
    echo system :: touch("/blog/?note=".$note['id']."", system :: icon("arr-l")."Назад");
}
require (CORE."foot.php");
?>