<?
include '../config.php';
include '../func.php';

head();
aut();
ban();

switch ($_GET['mod']) {
    
    case 'new':
    echo head . 'Фотоальбомы / <b>ТОП-Новые</b>' . div;
    $allr = mysql_result(mysql_query("SELECT count(*) FROM `photo_photos`"), 0);
    if ( $allr > 0 ) {
    
    if($allr){
    $onpage = 5;
    $allpage = ceil($allr/$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 `photo_photos` ORDER BY `id` DESC limit ".num($start).",".num($onpage)."");
    while ($b = mysql_fetch_array($result))
    {
    echo link2 . '<a href="photo.php?photo='.$b['id'].'"><img src="../resize.php?img=photo/files/'.$b['file'].'&width='.num($_SESSION['y']).'&height='.num($_SESSION['x']).'" alt=""/></a><br/ >';
    echo user($b['user']);
    echo '</div>';
    }
    echo link1 . '<b>Страницы:</b> ';
    navigation($allpage,"top.php?mod=new&p={p}",1,1);
    }

    
    }
    break;
    
    case 'best':
    echo head . 'Фотоальбомы / <b>ТОП-Лучшие</b>' . div;
    $allr = mysql_result(mysql_query("SELECT count(*) FROM `photo_photos`"), 0);
    if ( $allr > 0 ) {
    if($allr){
    $onpage = 5;
    $allpage = ceil($allr/$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 `photo_photos` ORDER BY `reyt` DESC limit ".num($start).",".num($onpage)."");
    while ($b = mysql_fetch_array($result))
    {
    echo link2 . '<a href="photo.php?photo='.$b['id'].'"><img src="../resize.php?img=photo/files/'.$b['file'].'&width='.num($_SESSION['y']).'&height='.num($_SESSION['x']).'" alt=""/></a><br/ >';
    echo 'Рейтинг: <b>'.$b['reyt'].'</b> ';
    echo user($b['user']);
    echo '</div>';
    }
    echo link1 . '<b>Страницы:</b> ';
    navigation($allpage,"top.php?mod=best&p={p}",1,1);
    }    

    echo div;
    }
    break;
    
    case 'popular':
    echo head . 'Фотоальбомы / <b>ТОП-Популярные</b>' . div;
    $allr = mysql_result(mysql_query("SELECT count(*) FROM `photo_photos`"), 0);
    if ( $allr > 0 ) {
    echo link1 . '<b>Лучшее фото:</b>' . div;
    
    if($allr){
    $onpage = 5;
    $allpage = ceil($allr/$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 `photo_photos` ORDER BY `reyt` DESC limit ".num($start).",".num($onpage)."");
    while ($b = mysql_fetch_array($result))
    {
    echo link2 . '<a href="photo.php?photo='.$b['id'].'"><img src="../resize.php?img=photo/files/'.$b['file'].'&width='.num($_SESSION['y']).'&height='.num($_SESSION['x']).'" alt=""/></a><br/ >';
    echo 'Рейтинг: <b>'.$b['reyt'].'</b> ';
    echo user($b['user']);
    echo '</div>';
    }
    echo link1 . '<b>Страницы:</b> ';
    navigation($allpage,"top.php?mod=popular&p={p}",1,1);
    }    
    echo div;
    }
    break;
    
}

navig();
foot();
?>