<?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 = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_dir`"), 0);
$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 = mysql_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 = mysql_fetch_array($q)) {
    $smile = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_spis` WHERE `id_dir` = '$post[id]'"), 0);

    echo "<table class='list-group-item-null'><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='count'>$smile</span></a> ";
    echo "</td></tr></table>";
    echo "<div class='hr'></div>";
}

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

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