<?
include '../config.php';
include '../func.php';
head();
aut();
ban();

/////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'photo' WHERE `id` = '".$id_session."'");
echo head . "<b>Фотоальбомы</b>" . div;  

$id_album = num($_GET['id']);

$album_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_album` WHERE `id` = '".$id_album."'"));

if ( !empty($album_info['pass']) AND ($_SESSION['pass_album'] != $album_info['pass']) ) {
    if (empty($_POST['submit'])) {
        echo '<form action="photos.php?id='.$album_info['id'].'" method="POST" name="form">';
        echo '<b>Введите пароль:</b><br/>
        <input name="pass" type="text" maxlength="30" /><br/>';
        echo '<input type="submit" name="submit" value="ОК"></form><br/>';
        } else {
            $pass = html($_POST['pass']);
            
            if ($pass != $album_info['pass']) {
                echo link1 . 'Пароль введен не верно.';
            } else {
                $_SESSION['pass_album'] = $pass;
                header('Location: photos.php?id='.$album_info['id'].'');
            }
        }
pod_navig();
foot();
exit();
}


if($album_info['id'])
{
    $album_info['prosm']++;
    mysql_query("UPDATE `photo_album` SET `prosm` = '".$album_info['prosm']."' WHERE `id` = '".$id_album."'");
}

$all = mysql_result(mysql_query("SELECT count(*) FROM `photo_photos` WHERE `album` = '".$id_album."' AND `user` = '".$album_info['user']."'"), 0);
if($all==0)
echo link1 . 'Фото еще не загружены.';

if($all){
$onpage = 5;
$allpage = ceil($all/$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; 
$query = @mysql_query("SELECT * FROM `photo_photos` WHERE `album` = '".$id_album."' AND `user` = '".$album_info['user']."' order by id desc limit ".num($start).",".num($onpage)."");
while($result = @mysql_fetch_array($query))
{
echo link2 . "<a href=\"photo.php?photo=".$result['id']."\"><img src=\"../resize.php?img=photo/files/".$result['file']."&width=".num($_SESSION['y'])."&height=".num($_SESSION['x'])." alt=\"\"/></a><br/>";

echo "Описание: ".$result['info']."<br/>";
echo "Добавлено: ".date2($result['date'])."<br/>";
echo "Просмотров: ".$result['prosm']."</small><br/><br/>";

echo "</div>";
}
echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"photos.php?id=".$id_album."&p={p}",1,1);
}    




pod_navig();
foot();
?>