<?
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']='Список смайлов';
include_once '../sys/inc/thead.php';
title();
err();
aut();
$config_smilelist=10;
$dir = opendir ("../img/smiles");
while ($file = readdir ($dir)) 
{ if (ereg (".gif$", "$file"))
{$a[]=$file;}}  
closedir ($dir); 
sort($a);

$total = count($a); 
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $config_smilelist){ $end = $total; }
else {$end = $start + $config_smilelist; }
for ($i = $start; $i < $end; $i++){ 

$smkod=str_replace(".gif","",$a[$i]);

echo '<img src="../img/smiles/'.$a[$i].'" alt="">'; 
echo '- :'.$smkod.'<br>';
}


echo'<hr>';
# постраничный вывод    
if ($start != 0) {echo '<a href="smiles.php?start='.($start - $config_smilelist).'&amp;'.SID.'">&lt;-Назад </a> ';}else{echo'&lt;-Назад ';}
echo'|'; 
if ($total > $start + $config_smilelist) {echo ' <a href="smiles.php?start='.($start + $config_smilelist).'&amp;'.SID.'"> Далее-&gt;</a>';}else{echo' Далее-&gt;';} 


$a=count($a);
$ba=ceil($a/$config_smilelist);
$ba2=floor(($a-1)/$config_smilelist)*$config_smilelist;

echo'<br><hr>Страницы:';
$asd=$start-($config_smilelist*4);
$asd2=$start+($config_smilelist*5);

if($asd<$a && $asd>0){echo ' <a href="smiles.php?start=0&amp;'.SID.'">1</a> ... ';}

for($i=$asd; $i<$asd2;)
{
if($i<$a && $i>=0){
$ii=floor(1+$i/$config_smilelist);

if ($start==$i) {
echo ' <b>'.$ii.'</b>';
               }
                else {
echo ' <a href="smiles.php?start='.$i.'&amp;'.SID.'">'.$ii.'</a>';
                     }}


$i=$i+$config_smilelist;}
if($asd2<$a){echo ' ... <a href="smiles.php?start='.$ba2.'&amp;'.SID.'">'.$ba.'</a>';}

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