<?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> :: <a href="/smiles"style="text-decoration:none; color:white;">Смайлики</a> :: <a href="bbcodes"style="text-decoration:none; color:white;"> Список BB кодов</a></div></div>';
if ($b['level']>2) {
echo '<div class="list-group-item media"><span class="label label-danger">Новый</span> <a href="/administration/smiles.html"> Добавить смайл</a> </div>';
}
 
$inf = DB::$dbs->queryFetch("SELECT * FROM `smiles_r` WHERE `id` = ? LIMIT 1", [$id]);
if (!$inf) {
header('location: /');
}
if (isset($_GET['del'])) {
if ($b['level'] < 3) {
header('location: /');
}
$arr = DB::$dbs->queryFetch("SELECT * FROM smiles WHERE id = ? LIMIT 1", [abs((int)$_GET['del'])]);
if (!empty($arr['id'])) {
unlink($_SERVER['DOCUMENT_ROOT'].'/assets/smiles/'.$arr['file']);
DB::$dbs->query("DELETE FROM smiles WHERE id = ?", [$arr['id']]);
header('location: ?id='.$id.'');
}
}
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM smiles WHERE cid = ?", [$id]);
if ($look == 0) {
err('Новых смайлов нет!');
}
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM smiles WHERE cid = ? ORDER BY id ASC LIMIT $start,$num", [$id]);
while($a = $sql->fetch()){
echo '<div class="list-group-item media"> '.($b['level'] > 4 ? '[<a href="?id='.$id.'&del='.$a['id'].'">Удл</a>]':NULL).' <img src="/assets/smiles/'.$a['file'].'" alt="not found"/> -   '.$a['name'].'</div>';
}
if ($k_page > 1) {
str('?id='.$id.'&',$k_page,$page);
}
$title->GetMenu();
$title->GetFooter();
?>
