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

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

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

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


$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'];
if ($k_post==0)
{
?>
<div class='noy'>Нет фотографий</div>
<?
}

$q=mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
echo "<a href='/foto/$ank[id]/$gallery[id]/$post[id]/'>";
if($num==1){
echo "<div class='enk_div'>\n";
$num=0;
}else{
echo "<div class='enk2_div'>\n";
$num=1;}
################################################################################
if($user['ank_d_r']!=NULL && $user['ank_m_r']!=NULL && $user['ank_g_r']!=NULL){
$user['ank_age']=date("Y")-$user['ank_g_r'];
if(date("n")<$user['ank_m_r']){
$user['ank_age']=$user['ank_age']-1;
}else if(date("n")==$user['ank_m_r']&& date("j")<$user['ank_d_r']){
$user['ank_age']=$user['ank_age']-1;
}
}

if ($post['sex']==1 && $user['ank_age']<18 && $user['id']!=$ank['id'] && $user['level']<1){
echo "<img src='/style/images/+18.jpg' alt='ENK'><br />";
}else{
echo "<img src='/foto/foto48/$post[id].$post[ras]' alt='Фото_$post[id]' /><br />";
}
echo "<img src='/style/images/ic_m26.gif' alt='enk'> $post[name] (".mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"),0).")<br />\n";
echo "<img src='/style/images/k.gif' alt='ENK'> ";
if ($post['opis']==null)
echo "Без описания<br />\n";
else 
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['opis']))))))))."<br />\n";
if($post['sex']==1){
echo "<img src='/style/images/18.gif' alt='enk'> <b>Файл 18+</b><br />";
}
echo "<img src='/style/images/ret.png' alt='enk'> Рейтинг: $post[rating]\n";
echo "</div></a>\n";
}



if ($k_page>1)str('?',$k_page,$page);
include_once 'inc/gallery_show_form.php';


echo "<div class='fyt'>\n";
echo "• <a href='/foto/$ank[id]/'>К фотоальбомам</a><br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
exit;
?>