<?
require("config.php");
require("func.php");
head();
aut();
ban();
####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = 'smiles' WHERE `id` = '".$id_session."'");
####################################################

echo "<div class=\"head\">Список смайлов</div>";

if ( empty ($_GET['cat']) ) {
    echo link1 . '<b>Каталоги:</b>' . div;
$all = mysql_result(mysql_query("SELECT count(*) FROM `smile_cat`"), 0);
if($all > 0) {
$result = mysql_query("SELECT * FROM `smile_cat`");
while($cat = mysql_fetch_assoc($result)){
###############
$alls = mysql_result(mysql_query("SELECT count(*) FROM `smiles` WHERE `cat` = '".$cat['id']."'"), 0);
echo '<div class="'.($i++ % 2 ? 'link2' : 'link2').'">';
echo " <a href=\"smiles.php?cat=".$cat['id']."\">".$cat['name']."</a> [".$alls."]</div>";
##############
}
} else {
    echo link2 . 'Категории не созданы' . div;
}

} else {
    echo link1 . 'Смайлы:' . div;
    $all = mysql_result(mysql_query("SELECT count(*) FROM `smiles` WHERE `cat` = '".num($_GET['cat'])."'"), 0);
    if($all > 0) {
        
        $onpage = 10;
        $allpage = ceil($all/$onpage);
        $this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
        if($this_page < 1 || $this_page > $allpage)$this_page = 1;
        $start = $this_page*$onpage - $onpage;
    $result = mysql_query("SELECT * FROM `smiles` WHERE `cat` = '".num($_GET['cat'])."'  limit ".num($start).",".num($onpage)."");
    while($smile = mysql_fetch_assoc($result)){
    ###############
    
    echo '<div class="'.($i++ % 2 ? 'link2' : 'link2').'">';
    echo "<img src='/smiles/".$smile['smile']."' alt='user' />: ".$smile['name']." ".$smile['name1']." ".$smile['name2']." ".$smile['name3']."</div>";
    ##############
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"smiles.php?cat=".num($_GET['cat'])."&p={p}",1,1);
echo div;

echo link1 . "<a href=\"smiles.php\">В смайлы</a>" .div;

} else {
    echo link1 . 'Категории не созданы' . div;
}
}

navig();
foot();
?>