<?php

/* DCMS Special
 * Дата последнего редактирования 01.10.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../../sys/inc/$inc.php";
}

$set['title'] = lang('Смайлы');

require_once H . 'sys/inc/thead.php';

only_reg();
aut();
err();

$k_post = $db->super_query("SELECT COUNT(*) as count FROM smiles_dir");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Смайлы');
echo "</small></div><br />";

if ($k_post == 0) {
    $doc->NoResult();
}

$q = $db->query("SELECT * FROM `smiles_dir` ORDER BY `pos` ASC LIMIT $start, $set[p_str]");

echo "<div class='list-group-item-null'>";
echo "<img src='/style/icons/smile.png' style='margin-top: -10px;margin-left: -10px;margin-bottom: -16px;'/>";
echo "</div>";

while ($post = $db->get_array($q)) {
    $smile = $db->super_query("SELECT COUNT(*) as count FROM `smiles_spis` WHERE `id_dir` = '$post[id]'");
    $smile = $smile['count'];

    echo "<table class='list-group-item'><tr><td class='icon14'>";
    echo "<img src='/style/smiles/$post[id].png'/>";
    echo "</td><td class='null'>";
    echo "<a href='dir.php?id=$post[id]'> $post[name] <span class='tag tag-info right'>$smile</span></a> ";
    echo "</td></tr></table>";
}

if ($k_page > 1) {
    str('index.php?', $k_page, $page);
}

require_once H . 'sys/inc/tfoot.php';
