<?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="container-fluid page_header"><div class="container"><div class="row"><div class="col-xs-12 col-sm-8 col-md-9 col-lg-9"><h1>Подкатегория - '.$pr['name'].' </h1><ol class="breadcrumb" xmlns:v="http://'.homeurl.'/#"><li typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">'.homeurl.'</a></li><li class="active" typeof="v:Breadcrumb"><span property="v:title">'.$pr['name'].'</span></li></ol></div><div class="col-xs-12 col-sm-4 col-md-3 col-lg-3 text-right page_header_sidebar"></div></div></div></div>';
echo'<div class="container page_body"><div class="row"><div class="col-xs-12 page_content col-lg-9"><div class="navbar page_content_navbar collapse hidden-lg"><div class="container-fluid"><div class="navbar-collapse"></div></div></div><div class="text_box hidden-lg pr_block_small hidden"></div><div class="container-fluid cols_table">';

echo '<div class="catSides"><a href="/downs"><i class="md-format-list-bulleted"></i> Загруз-центр</a> - Подкатегория - '.$pr['name'].'</div>';
if($b == true) {
echo'<ul class="nav nav-pills nav-stacked"><li><a href="upload.html?id='.$id.'"><i class="md-apps"></i> Загрузить файл</a></ul>'; }
$k_post = DB::$dbs->querySingle("SELECT COUNT(id) FROM `downs` WHERE `prid` = ? AND `mod` = ?", [$id,0]);
if ($k_post == 0) {
err('В данной категории нет файлов!');
}
$num = 10;
$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 '<div class="row"><div class="col-xs-3 col-sm-1"><div class="user_brief"><div class="userpic" style="height: 50px;padding: 4px;width: 50px;"><a href="/'.$screen['file'].'"><img class="img-responsive" src="/'.$screen['file'].'" alt="" ></a></div></div></div><div class="col-xs-9 col-sm-8"><a class="title" href="file.html?id='.$a['id'].'"> '.$a['name'].' ('.get_size($a['size']).')</a><div class="text-muted"><span> '.slv($mess, 'Комментарий','Комментария','Комментариев').'</span></div></div><div class="col-sm-3 text-muted text-right hidden-xs"><span data-toggle="tooltip" title="Время отправки">('.vr($a['time']).')
</span></div></div>';
}



if ($k_page > 1) {
str('?id='.$id.'&',$k_page,$page);
}

///Подключаем меню
$title->GetMenu();


///Подключаем футер
$title->GetFooter();
?>