<?
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;  


$all = mysql_result(mysql_query("SELECT count(*) FROM `photo_album` WHERE `user` = '".$id_session."'"), 0);
if($all==0) {
echo link1 . 'Альбомы еще не созданы' . div;
echo "  <a href=\"new_album.php\">Создать альбом</a><br/>";
} else {
$query = @mysql_query("SELECT * FROM `photo_album` WHERE `user` = '".$id_session."'");
while($result = @mysql_fetch_array($query))
{
    $all_photos = mysql_result(mysql_query("SELECT count(*) FROM `photo_photos` WHERE `album` = '".$result['id']."'"), 0);
$photo_1 = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$result['user']."'"));
if(isset($photo_1['osnov_photo']))
$photo_2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `photo_photos` WHERE `id` = '".$photo_1['osnov_photo']."'"));

if(isset($photo_2['file']))
echo link2 . "<b>Основное фото:</b><br/><img src=\"../pict.php?file=photo/files/$photo_2[file]\" alt=\".\" /><br/>";
echo "<b>Альбом:</b> <a href=\"photos.php?id=".$result['id']."\">".$result['name']."</a> [".$all_photos."] <br/>";


echo "<small>Автор: ";
echo "".user($result['user'])."<br/></small>";
if($result['date'])
echo "<small>".strftime("Создан %d.%m.%y",$result['date'])."</small><br/>";
if($result['obnov'])
echo "<small>".strftime("Изменен %d.%m.%y",$result['obnov'])."</small><br/>";

if($result['prosm'])
echo "<small>Просмотров: ".$result['prosm']."</small><br/>";
echo '</div>';

echo link1 . '<a href="album_edit.php?id='.$result['id'].'&mod=edit">Редактировать</a> | <a href="album_delete.php?id='.$result['id'].'&mod=delete">Удалить</a></div>';
}

}

pod_navig();
foot();
?>