<?
if(isset($_GET['cats'])){


if(isset($_GET['cat']) && intval($_GET['cat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_sm_cat` WHERE `id` = '".intval($_GET['cat'])."'"),0)!=0)
{
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_sm_cat` WHERE `id` = '".intval($_GET['cat'])."'"));



echo "<div class='event'><h1>Смайлы/Категории</h1></div>";
echo "<div class='block'>";
echo "<a href='?smiles'>Смайлы</a>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_smiles` WHERE `id_cat` = '$cat[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}

$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_smiles` WHERE `id_cat` = '$cat[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
echo "<div class='block'><img src='img/smiles/$post[id].png' alt='o'> <span class='title'>".hsc($post['name'])."</span><div style='clear:both'></div></div>";
}
echo "</div>";
include_once 'inc/foot.php';
if ($k_page>1)str("?smiles&cat=$cat[id]&",$k_page,$page); // Вывод страниц
}

echo "<div class='event'><h1>Категории</h1></div>";
echo "<div class='block'>";
echo "<a href='?smiles'>Смайлы</a> | <b>Категории</b>";

$q=mysql_query("SELECT * FROM `kolhoz_sm_cat`");
while($post=mysql_fetch_array($q))
{
echo "<div class='block'><img src='img/icons/right.png' alt='o'> <a href='?smiles&cats&cat=$post[id]'><span>".hsc($post['name'])."</span></a></div>";
}
echo "</div>";



include_once 'inc/foot.php';
}



echo '<div class="event"><h1>Список всех смайлов</h1></div><div class="content"><ul class="block">';
echo "<b>Смайлы</b> | <a href='?smiles&cats'>Категории</a>";
//if($ku[dostup]==1){echo "<TABLE WIDTH='100%'><TR><TD><center><div class='feedback'><img src='img/icons/smiles.png'> <a href='?adm_smile'>Редактировать</a></div></center></TD></TR></TABLE>";}
$q=mysql_query("SELECT * FROM `kolhoz_smiles` ORDER BY `id` ASC");
while($post=mysql_fetch_array($q))
{
$n=explode(',',$post['name']);
$nn=NULL;
foreach($n as $key => $value)
{
$nn=($nn!=NULL?$nn." или ":null)."$value";
}
$post['name']=$nn;
echo "<div class='block'><img src='img/smiles/$post[img]' alt='o'> ".hsc($post['name'])."</div>";
}
include_once 'inc/foot.php';
?>