<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Загруз-центр - Свежие файлы');
$title->GetHeader();
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/downs"style="text-decoration:none; color:white;"> Загрузки</a> :: Свежие файлы</div></div></div>';

$date = time() - 3600 * 72;
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM `downs` WHERE `time` > ? AND `mod` = ?", [$date,0]);
if ($look == 0) {
err('Нет новых файлов!');
}
echo'<div class="t-body"><div class="list-group lg-alt">';
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM `downs` WHERE `time` > ? AND `mod` = ? ORDER BY `time` DESC LIMIT $start,$num",[$date,0]);
while($a = $sql->fetch()) {
//$mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM `down_komm` WHERE `file` = ?", [$a['id']]);
$screen = DB::$dbs->queryFetch("SELECT * FROM `down_screen` WHERE `fid` = ? ORDER BY `id` DESC LIMIT 1",[$a['id']]);
echo'<a href="file.html?id='.$a['id'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/'.$screen['file'].'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$a['name'].' ('.get_size($a['size']).')  </div><small class="list-group-item-text">('.vr($a['time']).') </small></div></a>';
}
echo'</div></div>';
if ($k_page > 1) {
str('?',$k_page,$page);
}
$title->GetMenu();
$title->GetFooter();
?>