<?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="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> :: Галерея</div></div></div>';
$sql = DB::$dbs->query("SELECT * FROM album_cat ORDER BY id ASC");
echo'<div class="tile-body"><div class="count-box bg-blue"><div class="row text-center">';
if ($sql->rowCount() == 0) {
err('Альбомов нет');
} else {
while($a = $sql -> fetch()) {

echo'<a href="action.html?id='.$a['id'].'"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">'.DB::$dbs->querySingle("SELECT COUNT(id) FROM album_foto WHERE cid = ?", [$a['id']]).'</h3><small>'.$a['name'].'</small></div></div></a>';
}
}
echo'</div></div>';
if ($b['level']>2) {
if (isset($_POST['add'])) {
if (empty($_POST['name'])) {
err('Введите название!');
} else {
DB::$dbs->query("INSERT INTO album_cat SET name = ?", [check($_POST['name'])]);
header('location: ?');
}
}
echo '<div class="list-group-item media"><form action="?" method="POST">Новый раздел:<br/> <input type="text" class="form-control m-b-10"name="name"/> <input type="submit" name="add" class="btn btn-primary"value="Добавить"/></form></div>';
}


echo'<div class="tile"><div class="action-header clearfix"><h2 class="ah-label">Новые работы мастеров</h2></div><div class="t-body tb-padding"><div class="lightbox photos">';

$sql = DB::$dbs->query("SELECT * FROM album_foto ORDER BY id DESC LIMIT 100");
if ($sql->rowCount() == 0) {
err('Альбомов нет');
} else {
while($fotos = $sql -> fetch()) {
$screen = DB::$dbs->queryFetch("SELECT * FROM `album_foto` WHERE `id` = ? ORDER BY `id` DESC LIMIT 50",[$fotos['id']]);

echo'<a href="/'.$screen['path'].'" class="col-md-2 col-sm-4 col-xs-6 p-item"><img src="/'.$screen['path'].'" width="380" height="250" alt="" /></a>';
}
}
echo'</div><div class="clearfix"></div>
                    </div>
                </div>';
$title->GetMenu();
$title->GalleryFooter();
?>