<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$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">';

$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
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="search.html"><i class="md-search"></i> Поиск статей</a></ul>';

$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM gazeta_article");
if ($look == 0) {
err('Записей нет!');
} else {
$sql = DB::$dbs->query("SELECT * FROM gazeta_article ORDER BY time DESC LIMIT 5");
while($a = $sql->fetch()) {
echo '<ul class="nav nav-pills nav-stacked"><li><a href="news.html?id='.$a['id'].'"><i class="md-forum"></i>  '.$a['name'].'  ('.vr($a['time']).')</a></ul>';
}
}
// Вывод разделов 
echo '<div class="catSides"><a href="/"><i class="md-format-list-bulleted"></i> Главная </a> - Список разделов</div>';
$looks = DB::$dbs->querySingle("SELECT COUNT(id) FROM gazeta_cat");
if ($looks ==0) {
err('Категорий нет!');
} else {
$array = DB::$dbs->query("SELECT * FROM gazeta_cat ORDER BY id ASC");
while($a = $array->fetch()) {
$D = ($b['level'] > 5 ? '[<a href="?do=delr&id='.$a['id'].'">X</a>] ':NULL);
echo ''.$D.'<ul class="nav nav-pills nav-stacked"><li><a href="category.html?id='.$a['id'].'"><i class="md-folder"></i> '.$a['name'].' ('.DB::$dbs->querySingle("SELECT COUNT(id) FROM gazeta_article WHERE cid = ?", [$a['id']]).(!empty($_new) ? '<font color="red">+'.$_new.'</font>':NULL).')</a> </ul>';
}
}
if ($b['level'] > 4) {
if (isset($_POST['add'])) {
if (empty($_POST['name'])) {
err('Введите название!');
} else {
DB::$dbs->query("INSERT INTO gazeta_cat SET name = ?", [check($_POST['name'])]);
header('location: ?');
}
}
echo '<div class="row text_box"><form action="?" method="POST">Новая категория:<br/> <input type="text" class="form-control" name="name"/> <input type="submit" name="add" class="btn btn-primary" value="Добавить"/></form></div>';
}


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

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