<?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';

if(isset($_GET['id'])){
	$id = intval($_GET['id']);
	}else{
		header("Location: /index.php");
		}

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

title();
aut();



$dir = mysql_fetch_array(mysql_query("SELECT * FROM `smiles_dir` WHERE `id` = '".$id."'"));
if(!isset($user)){
	echo '<div class="err">Доступ закрыт.</div>';
	}else if($id==0 || $id<0){
		echo '<div class="err">Директория не найдена.</div>';
		}else if($id!=$dir['id']){
			echo '<div class="err">Директория не найдена.</div>';
			}else if($user['level']!=$dir['level'] && $user['level']<0){
				echo '<div class="err">Эти смайлы не для Вас.</div>';
				}else{

echo '<div class="main_menu"><b>Директория</b>: '.esc(stripcslashes(htmlspecialchars($dir['name']))).'<br/>';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_spis` WHERE `id_dir` = '$id'"),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_spis` WHERE `id_dir` = '$id' ORDER BY `id` ASC LIMIT $start, $set[p_str]");
while($post = mysql_fetch_array($q)){
	echo '<img src="/style/smiles/'.$post['name'].'.gif" alt="'.$post['name'].'"/> '.$post['sim'].'<br/>';
	}
echo '</div>';
if($k_page>1){
	str('dir.php?id='.$id.'&amp;',$k_page,$page);
	}

echo '<div class="foot">&#187;&nbsp;<a href="index.php">Все директории</div></a>';
}
if(isset($_SESSION['refer']) && $_SESSION['refer']!=NULL && otkuda($_SESSION['refer']))
{
echo "<div class=\"foot\">\n";
echo "&laquo;<a href='$_SESSION[refer]'>".otkuda($_SESSION['refer'])."</a><br />\n";

}


echo"<a href='javascript:history.back(1)'>Назад</a><br/></DIV>";

include_once '../sys/inc/tfoot.php';
?>