<?
include '../config.php';
include '../func.php';
head();
aut();
ban();
if($error){ echo $error;
}else{
/////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'photo' WHERE `id` = '".$id_session."'");
echo head . "<b>Фотоальбомы</b>" . div . katalog;  
$photo_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_photos` WHERE `id` = '".num($_GET['photo'])."'"));

$album_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_photos` WHERE `id` = '".$photo_info['album']."'"));

if ( !empty($album_info['pass']) AND ($_SESSION['pass_album'] != $album_info['pass']) ) {
    if (empty($_POST['submit'])) {
        echo '<form action="photo.php?id='.$photo_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 'Пароль введен не верно<br/>';
            } else {
                $_SESSION['pass_album'] = $pass;
                header('Location: photo.php?id='.$photo_info['id'].'');
            }
        }
} else {

if(isset($photo_info['id'])){
if($photo_info['id']){
    $photo_info['prosm']++;
    mysql_query("UPDATE `photo_photos` SET `prosm` = '".$photo_info['prosm']."' WHERE `id` = '".$photo_info['id']."'");
}
if($osnov_photo_session==$photo_info['id']){
  echo "[<a href=\"osnov.php?photo=".$photo_info['id']."&v=1\">Не показывать как основное</a>]<br/>";
}else{
if($photo_info['user']==$id_session)
echo "[<a href=\"osnov.php?photo=".$photo_info['id']."&v=2\">Сделать основным</a>]<br/>";
}

if($_SESSION['razm']==0){
  echo "[<a href=\"setting.php?photo=".$photo_info['id']."&mod=razm\">Увеличить</a>]<br/>";
}else{
  echo "[<a href=\"setting.php?photo=".$photo_info['id']."&mod=razm\">Умешьшить</a>]<br/>";
}

if($_SESSION['razm']==0){
    echo '<img src="../resize.php?img=photo/files/'.$photo_info['file'].'&width='.num($_SESSION['y']).'&height='.num($_SESSION['x']).'" alt=""/><br/ >';
} else {
    echo '<img src="../resize.php?img=photo/files/'.$photo_info['file'].'&width=360&height='.num($_SESSION['x']).'" alt=""/><br/ >';
}

$razr = getimagesize("files/".$photo_info['file']."");
echo "".$photo_info['info']."<br/>";
$time = $photo_info['date'];
echo "Добавлено: ".date2($time)." назад<br/>";
echo "Автор: ".user($photo_info['user'])."<br/>";
echo "Разрешение: <b>".$razr['0']."x".$razr['1']."</b><br/>";
echo "Просмотр в: <a href=\"files/".$photo_info['file']."\"><b>Оригинале</b></a><br/>";
echo "Просмотров: ".$photo_info['prosm']."<br/><br/>";

$all_coment = mysql_result(mysql_query("SELECT count(*) FROM photo_coment WHERE `photo` = '".num($photo_info['id'])."'"), 0);
$all_ocenki = mysql_result(mysql_query("SELECT count(*) FROM photo_rayt_list WHERE `photo` = '".num($photo_info['id'])."'"), 0);
echo "<a href=\"coment.php?photo=".$photo_info['id']."\">Коментарии</a> [".$all_coment."]<br/>";

if($photo_info['reyt']>0)
$reyt = $photo_info['reyt'];
else
$reyt = '0';
echo "<img src=\"../images/star.png\" alt=\"\" /> Рейтинг: ".$reyt." / Оценок ".$all_ocenki."<br/>";

mysql_query ("Select * from photo_rayt_list WHERE (user_1 = '".$id_session."')and(user_2 = '".$photo_info['user']."')and(photo = '".$photo_info['id']."')");
if(mysql_affected_rows()==0){
echo "<img src=\"../images/star.png\" alt=\"\" /> <b>Оценка:</b><br/>";
echo "<a href=\"reyt.php?photo=".$photo_info['id']."&a=min2\">-2</a> ";
echo "<a href=\"reyt.php?photo=".$photo_info['id']."&a=min1\">-1</a> | ";
echo "<a href=\"reyt.php?photo=".$photo_info['id']."&a=plus1\">+1</a> ";
echo "<a href=\"reyt.php?photo=".$photo_info['id']."&a=plus2\">+2</a><br/>";
}
echo '<br/>';
if(($photo_info['user']==$id_session) OR ($level_session>3))
echo "[<a href=\"delete.php?act=photo&id=".$photo_info['id']."\">Удалить фото</a>]<br/>";
echo '<br/>';
echo '<br/>';
echo "<a href=\"index.php\">Фотоальбомы</a> -> <a href=\"photos.php?id=".$photo_info['album']."\">Альбом</a> -> <b>Фото</b><br/>";

} else {
    echo 'Данного фото нет в базе';
}
}
}
pod_navig();
foot();
?>
