<?
if (!isset($user) && !isset($_GET['id_user'])){header("Location: /foto/?".SID);exit;}
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id_user']))$ank['id']=intval($_GET['id_user']);
$ank=get_user($ank['id']);
if (!$ank){header("Location: /foto/?".SID);exit;}
$gallery['id']=intval($_GET['id_gallery']);

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /foto/$ank[id]/?".SID);exit;}
$gallery=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"));

if($gallery['set_password']==1){if($_POST['foto_pass']!==$gallery['foto_password'] ) {echo "";}  }
if($gallery['set_password']==1 && !isset($_POST['foto_pass']))
{

echo "Пользователь в качестве приватности поставил пароль на фотоальбом<br/>Введите пожалуйста пароль чтобы войти в альбом" ;
echo "<br><form action=\"$SCRIPT_NAME\" method=\"post\"> <input type=\"text\" name=\"foto_pass\"><br><input type=\"submit\" name=\"go\">";}

else
{

if($gallery['set_password']==0 or $_POST['foto_pass']===$gallery['foto_password']){

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";

if ($k_post==0)
{
echo "Нет фотографий\n";
}
$q=mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]' ORDER BY rand() DESC LIMIT 10");
while ($post = mysql_fetch_assoc($q))
{

//echo "   <tr>\n";

echo "<a href='/foto/$ank[id]/$gallery[id]/$post[id]/'><img src='/foto/foto48/$post[id].$post[ras]' alt='Фото_$post[id]' width='20' height='18' /></a>";

}

echo "</table>\n";


echo "<div class=\"foot\">\n";
echo "<a href='/foto/$ank[id]/'>Альбомы</a> $ank[nick]<br />\n";
echo "</div>\n";

include_once '../sys/inc/tfoot.php';
exit;
   }}
   
?>