<?
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_komm` WHERE `id_group` = '".$group['id']."' AND `id` = '".intval($_GET['dell_komm'])."'") > 0)
{
    if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_files` WHERE `id_post` = '".intval($_GET['dell_komm'])."'") > 0)
    {
        $query_f = DB :: $pdo -> query("SELECT * FROM `groups_files` WHERE `id_post` = '".intval($_GET['dell_komm'])."' ORDER BY `id` DESC");
        while($r_f = $query_f -> fetch())
        {
            if (is_file("".FILES_PATH."/groups/files/".$r_f['id'].".jpg"))
            {
                unlink("".FILES_PATH."/groups/files/".$r_f['id'].".jpg");
            }
            DB :: $pdo -> query("DELETE FROM `groups_files` WHERE `id` = '".$r_f['id']."' LIMIT 1");
        }
    }
    DB :: $pdo -> query("DELETE FROM `groups_komm` WHERE `id_group` = '".$group['id']."' AND `id_post` = '".intval($_GET['dell_komm'])."'");
    DB :: $pdo -> query("DELETE FROM `groups_komm` WHERE `id_group` = '".$group['id']."' AND `id` = '".intval($_GET['dell_komm'])."' LIMIT 1");
}
  system :: redirect("Запись успешно удалена.", "/groups/?group=".$group['id']."");
