<?

include_once '../system/sys.php';
include '../system/funcs.php';

if (!isset ($us)) {
    
    header ('location: /error.php');
    
    exit;

}

H ('Загруз-центр', 'Загруз-центр');

echo '
<div class="raz">
    <img src="/images/finds.png" alt=""/> <a href="/zc/search.php">Поиск файлов</a><br/>
    <img src="/images/tab_new.png" alt=""/> <a href="/zc/new.php">Новые файлы</a><br/>
</div>
<div class="menu2">Категории</div>
<div class="ram">
';

if (DB :: $dbs->querySingle("SELECT COUNT(*) FROM `zc_kat`") == 0){
    echo '
    <div class="raz">
        Подкатегорий нет!
    </div>
    ';

}
else {

    $query = DB :: $dbs -> query ("SELECT * FROM `zc_kat` ORDER BY `id`");
    while ($kat = $query -> fetch ()) {

        $c_f = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`id_kat`='" . $kat['id'] . "') AND (`dop`='da')");
        $n_f = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`id_kat`='" . $kat['id'] . "') AND (`dop`='da') AND (`time`>'" . (time () - 86400) . "')");

        echo '
        <div class="raz">
            <img src="/images/unknown.png" alt=""/> <a href="/zc/kat' . $kat['id'] . '">' . $kat['name'] . ' </a> (' . $c_f . ($n_f != 0 ? '/<b style="color:red;">+' . $n_f . '</b>' : '') . ')
            <div class="lst">' . $kat['opis'] . '<br/>
        ';
            
        if ($kat['mod'] != 0)
            echo '
            Модератор: ' . uNick ($kat['mod']) . '</div>
            ';
            
        echo '
        </div>
        ';

    }

    echo '
    <div class="raz">
        Всего файлов: ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`dop`='da')") . ', (под)Категорий: ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_kat`") . '</div>
    </div>
    ';

}

F ();

?>