<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;

$newkom = DB::$dbs->querySingle("SELECT count(id) FROM `magazin_komm` WHERE `time` > ?", [time()-86400]);
$list = ['kat','dir','file','buy','addfiles','addfiles','newkomm','rules','newtovc','usinf','uskab','search','screen','refile','seller','whobuy','corz','mybuy','myout','ustovc','zip','Chaindel'];
$do = isset($_GET['do']) ? htmlspecialchars($_GET['do']) : false;
$act = isset($_GET['act']) ? htmlspecialchars($_GET['act']) : false;
if (in_array($do, $list)) {
require_once('../market/incfiles/'.$do.'.php');
} else {
$title->SetTitle(''.homeurl.' - Онлайн маркет');

///Подключаем шапку
$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>Главная маркета </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">Онлайн маркет</span></li></ol></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="/"><i class="md-format-list-bulleted"></i> Главная </a> - Маркет</div>';
echo'<ul class="nav nav-pills nav-stacked"><li><a href="newkomm"><i class="md-question-answer"></i>  Новые комментарии '.$nkom = ($newkom > 0 ? '('.$newkom.'</b>)':NULL).'</ul></a>';
echo'<ul class="nav nav-pills nav-stacked"><li><a href="search"><i class="md-search"></i>  Поиск товаров</a></ul>';
echo'<ul class="nav nav-pills nav-stacked"><li><a href="rules"><i class="md-class"></i>  Пользовательское соглашение</a></ul>';
echo'<div class="catSides"><i class="md-format-list-bulleted"></i> Список категорий</div>';
if (DB::$dbs->querySingle("SELECT count(id) FROM `magazin_r`")== 0){
echo '<div class="error">Категорий нет</div>';
} else {
$query = DB::$dbs -> query("SELECT * FROM `magazin_r` ORDER BY `id` DESC");
while ($row = $query -> fetch()) {
echo '<div class="row text_box"><a href="kat/'.$row['id'].'"> <i class="md-folder"></i>   '.$row['name'].' ('.DB::$dbs->querySingle("SELECT count(id) FROM `magazin_file` WHERE `id_r`  = ?",[$row['id']]).')</a></br>'.$row['opis'].' </div>';
}
}
if($b == true) {
echo'<div class="catSides"><i class="md-format-list-bulleted"></i>  Меню продавца</div>';
$tovc = DB::$dbs->querySingle("SELECT count(id) FROM `magazin_file` WHERE `time` > ?", [time()-86400]);
echo'<ul class="nav nav-pills nav-stacked"><li><a href="/seller/'.$b['id'].'"><i class="md-shuffle"></i> Моя страница</a></ul>';
echo'<ul class="nav nav-pills nav-stacked"><li><a href="uskab"><i class="md-shuffle"></i>  Кабинет</a></ul>';
echo'<ul class="nav nav-pills nav-stacked"><li><a href="newtovc"><i class="md-shuffle"></i> Новые товары '.($tovc>0 ? '('.$tovc.')':'').'</a></ul>';
}
}
///Подключаем меню
$title->GetMenu();

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