<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

$set['title']='Смайлы '.$_SERVER['HTTP_HOST'];
include_once '../sys/inc/thead.php';

title();


echo '<div class="menu">';

if(!isset($user)){
	echo '<div class="err">Доступ закрыт</div>';
	}else{

if($user['level']<0){
	$ty = ' WHERE `level` = $user[level]';
	}

echo '<b>Директории смайлов:</b><br/>';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_dir`$ty"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

if($k_post==0){
	echo '<div class="err">Нет директорий.</div>';
	}

$q=mysql_query("SELECT * FROM `smiles_dir`$ty ORDER BY `pos` ASC LIMIT $start, $set[p_str]");
while($post = mysql_fetch_array($q)){
	$smile = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_spis` WHERE `id_dir` = '$post[id]'"),0);
	echo "<img src='/chat/them_00.png' alt='' class='icon'/>\n";
	echo '<a href="dir.php?id='.$post['id'].'">'.esc(stripcslashes(htmlspecialchars($post['name']))).'</a> ('.$smile.')<br/>';
	}

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

echo '</div>';
include_once '../sys/inc/tfoot.php';
?>