<?
if (!isset($user) && !isset($_GET['id_user'])){header("Location: /xxxfoto/?".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: /xxxfoto/?".SID);exit;}
$gallery['id']=intval($_GET['id_gallery']);

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



$set['title']=$ank['nick'].' - Фотоальбом'; // заголовок страницы

include_once '../sys/inc/thead.php';
title();

include 'inc/gallery_show_act.php';
err();

echo "<div class='menu_razd'>\n";
echo "<img src='/img/add_fav.gif' alt='' class='icon'/> <span style=\"color:$ank[mcolor]\">".$gallery['name']."</span><br />\n";
echo "</div>\n";
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']){
$set['p_str'] = 20;
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `gallerea_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";
echo "<div class='dnev'>\n";

if ($k_post==0)
{
echo "Нет фотографий\n";
}

$q=mysql_query("SELECT * FROM `gallerea_foto` WHERE `id_gallery` = '$gallery[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{

//echo "   <tr>\n";

//echo '<tr><td class="icon14">';
echo " \n";
echo "<a href='/xxxfoto/$ank[id]/$gallery[id]/$post[id]/'><img src='/xxxfoto/foto128/$post[id].$post[ras]' alt='Фото_$post[id]' width='60' height='58' /></a>";
//echo "   </center>\n";
//echo "<img src='/style/icons/chat.gif' alt='' class='icon'/><a href='/foto/$ank[id]/$gallery[id]/komm/$post[id]/'> <u>".mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"),0)."</u></a><br />\n";
//echo '</td><td class="anput">';

//echo "<img src='/style/icons/konkurs16.png' alt='' class='icon'/> <span class=\"ank_n\">Рейтинг:</span> <font color='red'>$post[rating]</font><br />\n";
//echo "<img src='/style/icons/foto.png' alt='' class='icon'/>\n";

//echo " $post[name]<br />\n";

//if ($post['opis']==null)
//echo "Описание отсутствует =(<br />\n";
//else 
//echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['opis']))))))))."<br />\n";
//echo '</td></tr>';
}
echo "</div>\n";
echo "</table>\n";


if ($k_page>1)str('?',$k_page,$page); // Вывод страниц


include 'inc/gallery_show_form.php';

echo "<div class='aut'>\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href='/xxxfoto/$ank[id]/'>К альбомам</a> ($ank[nick])<br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
exit;
   }
   }
?>