<?
//Подключаемые файлы 
if (isset($user['id']) && isset($_GET['setts']))
{require('inc/setts.php');exit;} //Настройки
else if (isset($user['id']) && isset($_GET['add_group']))
{require('inc/add_group.php');exit;} //Добавить группу
else if (isset($_GET['id']))
{require('inc/my.php');exit;} //Мои группы
else if (isset($_GET['group']))
{require('inc/group.php');exit;} //Группа

$title = $l ="Группы"; #Тайтл
$lBack = profile :: getLink($user); #Профиль назад
require (CORE."head.php");

?>
<div class="app-block">
<div class="list tab">
        <a class="tab_active" href="/groups/">Группы</a>
 <? if (isset($user['id']))
            {
            ?> <a class="" href="/groups/?setts">Управления группами</a>
            <?}?>
    
     
</div>
<?
$total = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups` WHERE `block` = '0'");
if ($total == 0)
{
?>
    <div class="list _gray _font-s _center">Группы не найдены!</div>
<?
} else {
    if ($total > 10)
    {
        $p = (($_GET['p']) ? intval($_GET['p']) : 1);
        $pagination = new pagination(10, $total, $p);
        $total_lin = $pagination -> limit;
    } else {
        $total_lin = '';
    }
    $query = DB :: $pdo -> query("SELECT * FROM `groups` WHERE `block` = '0' ORDER BY `id` DESC ".$total_lin."");
    while($group = $query -> fetch())
    {
    $k_pc = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `groups_users` WHERE `id_group` = '".$group['id']."'");

     echo system :: touch("/groups/?group={$group['id']}","
                <div class=\"post-l\">
                  ".group :: Avatar($group,0)."
                </div>
                <div class=\"post-c\">
                    
                    <div>".group :: getName($group)."</div>
                    <div class=\"_gray\">участников: {$k_pc}</div>

                </div>
                ");
    
    
    
    
    

    }
    if ($total > 10)
    {
        echo $pagination -> printPages("/groups/?"); 
    }
}

require (CORE."foot.php");
?>