<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Смайлы';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

$dir = opendir ("image/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 + 10){
$end = $total;
}else{
$end = $start + 10;
}
for ($i = $start; $i < $end; $i++){ 
$smkod=str_replace(".gif","",$a[$i]);
echo'<div class="main"><div class="block_zero">';
echo'<a href="chat.php?nick=:'.$smkod.'&mod=write"><img src="image/smiles/'.$a[$i].'" alt=""></a>'; 
echo' - :'.$smkod.'</div><div class="dot-line"></div>';
echo'</div></div>';
}
$a=count($a);
$ba=ceil($a/10);
$ba2=floor(($a-1)/10)*10;
echo'<br>Страницы:';
$asd=$start-(10*4);
$asd2=$start+(10*5);
if($asd<$a && $asd>0){
echo'<a href="smile.php?start=0&amp;id=">1</a>';
}
for($i=$asd; $i<$asd2;){
if($i<$a && $i>=0){
$ii=floor(1+$i/10);
if ($start==$i){
echo ' <b>'.$ii.'</b>';
}else{
echo " <a href=\"smile.php?start=$i&amp;id=\">$ii</a>";
}
}
$i=$i+10;
}
if($asd2<$a){
echo " ... <a href=\"smile.php?start=$ba2\">$ba</a>";
}
echo "<br/><a href=\"chat.php?\">Назад</a>";
echo'</div></div>';
include($path.'files/down.php');
?>