<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
if (empty($id)) {
header ('location: /index.html');
exit;
}
$query = DB :: $dbs -> query ("SELECT * FROM `down_pr` WHERE `id`= ?", [$id]);
if ($query -> rowCount () == 0) {
header ('location: /index.html');
exit;
}
$pr = $query -> fetch ();
$title->SetTitle('Загруз-центр - '.$pr['name']);
$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> :: '.$pr['name'].'</div></div></div>';

if($b == true) {
echo'<div class="list-group-item media"><a href="upload.html?id='.$id.'"><span class="label label-danger">Новое</span> Загрузить файл</a></div>'; }
$k_post = DB::$dbs->querySingle("SELECT COUNT(id) FROM `downs` WHERE `prid` = ? AND `mod` = ?", [$id,0]);
if ($k_post == 0) {
err('В данной категории нет файлов!');
}
$num = 10;
echo'<div class="t-body"><div class="list-group lg-alt">';
$k_page = k_page($k_post, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM `downs` WHERE `prid` = ? AND `mod` = ? ORDER BY `time` DESC LIMIT $start,$num",[$id,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('?id='.$id.'&',$k_page,$page);
}
$title->GetMenu();
$title->GetFooter();
?>