<?
$title = $l ="Удалить - ".group :: getName($group)."";
$lBack = profile :: getLink($ank);
require (CORE."head.php");
if (isset($_GET['yes']))
{
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_komm` WHERE `id_group` = '".$group['id']."'") > 0)
{
$query_f = DB :: $pdo -> query("SELECT * FROM `groups_komm` WHERE `id_group` = '".$group['id']."' ORDER BY `id` DESC");
while($r_f = $query_f -> fetch())
{
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_files` WHERE `id_post` = '".$r_f['id']."'") > 0)
{
$query_f2 = DB :: $pdo -> query("SELECT * FROM `groups_files` WHERE `id_post` = '".$r_f['id']."' ORDER BY `id` DESC");
while($r_f2 = $query_f2 -> fetch())
{
if (is_file("".FILES_SERVER."/groups/files/".$r_f2['id'].".jpg"))
{
unlink("".FILES_SERVER."/groups/files/".$r_f2['id'].".jpg");
}
DB :: $pdo -> query("DELETE FROM `groups_files` WHERE `id` = '".$r_f2['id']."' LIMIT 1");
}
}
}
DB :: $pdo -> query("DELETE FROM `groups_komm` WHERE `id_group` = '".$group['id']."'");
}
DB :: $pdo -> query("DELETE FROM `groups_users` WHERE `id_group` = '".$group['id']."'");
DB :: $pdo -> query("DELETE FROM `groups` WHERE `id` = '".$group['id']."' LIMIT 1");
system :: redirect("Группа успешно удалена.", "/groups/");
} else {
?>
<div class="app-block"><div class="touch"><a href="/id83" class="touch-cont _oh">
<div class="post-l">
<?=group :: Avatar($group, 0)?>
</div>
<div class="post-c">
<div class="_name _bold"><?=group :: getName($group)?></div>
<div class="_gray">Участников: <?echo DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_users` WHERE `id_group` = '".$group['id']."'");?></div>
<div class="_gray">Дата создания: <?=system :: times($group['time'])?></div>
<div class="_gray">Статус блокировки: 0</div>
</div>
</a></div> <div>
<div class="list">
<div class="_dib _oh"><a href="/groups/?group=<?echo $group['id'];?>&del_gr&yes"><input type="submit" class="main-btn" value="Да, удалить"></a></div>
<div class="_dib _oh"><a href="/groups/?group=<?echo $group['id'];?>"><input type="submit" name="cancel" class="action-btn" value="Отменить"></div>
</div>
</div>
<?
echo system :: touch("/groups/?group=".$group['id']."", system :: icon("arr-l")."Назад");
}
require (CORE."foot.php");