<?

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

if (!isset ($us)) {
        header ('location: /');
        exit;
}

H ('Новые файлы', 'Новые файлы');

$items = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`time`>'" . (time () - 86400) . "') AND (`dop`='da')");
$items_per_page = 10;
$pages = ceil ( $items / $items_per_page );
$page = (int) $_GET['page'];

if ($page < 1) {
        $page = 1;
}
if ($page > $pages) {
        $page = $pages;
}
$start = $page * $items_per_page - $items_per_page;

if ($items != 0) {
        $query = DB :: $dbs -> query ("SELECT * FROM `zc_f` WHERE (`time`>'" . (time () - 86400) . "') AND (`dop`='da')");
        while ($f = $query -> fetch ()) {
                
                $kat = DB :: $dbs -> queryFetch ("SELECT * FROM `zc_kat` WHERE (`id`='" . $f['id_kat'] . "')");
                $pk  = DB :: $dbs -> queryFetch ("SELECT * FROM `zc_pk`  WHERE (`id`='" . $f['id_pk'] . "')");
                
                echo '<div class="lst">';
                echo 'Файл: <a href="/zc/file' . $f['id'] . '">' . $f['name'] . '</a> (' . datef ($f['time']) . ')<br/>';
                echo 'Категория: <a href="/zc/kat' . $kat['id'] . '">' . $kat['name'] . '</a> / <a href="/zc/pk' . $pk['id'] . '">' . $pk['name'] . '</a>';
                echo '</div>';
        
        }
        echo '<div class="lst">' . pages ('/zc/new') . '</div>';
}
else {
        echo 'Новых файлов нет!';
}

F ();

?>