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

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

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

include 'inc/gallery_act.php';
err();
aut();




$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$ank[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)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет фотоальбомов\n";
echo "  </td>\n";
echo "   </tr>\n";

}

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

echo "   <tr>\n";
if ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";

$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$post[id]' ORDER BY RAND()"));
if ($foto==null){
echo "<img src='/foto/foto48/0.png' alt='Нет фото' />";
}
else
{
echo "<img src='/foto/foto48/$foto[id].$foto[ras]' alt='Фото_$foto[id]' />";
}


echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{

echo "  </td>\n";
}
if($num==1){ 
echo "<div class='rowdown'>"; 
$num=0;
}else{ 
echo "<div class='rowup'>"; 
$num=1;}

$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$post[id]' ORDER BY RAND()"));
if ($foto==null){
echo "<img src='/foto/foto128/0.png'  align='left' width='45' height='45' alt=''style='margin-right:4px;border-right:px solid #99ccff /><a href='/foto/foto48/$foto[id].$foto[ras]'>";
}
else
{
echo "<img src='/foto/foto128/$foto[id].$foto[ras]' alt='Фото_$foto[id]'  align='left' width='45' height='45' alt=''style='margin-right:4px/><a href='/foto/foto48/$foto[id].$foto[ras]'>";
}



echo "<a href='/foto/$ank[id]/$post[id]/'>$post[name]</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"),0)." фото)\n";


echo "  <br>\n";

if ($set['set_show_icon']==1)

if ($post['opis']==null)
echo "Без описания<br />\n";
else 
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['opis']))))))))."<br />\n";
echo "Создан: ".vremja($post['time_create']);echo "</div>\n";
echo "  </td>\n";
echo "   </tr>\n";

}
echo "</table>\n";




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


include 'inc/gallery_form.php';

echo "<div class=\"foot\">\n";
echo "&laquo;<a href='/foto/'>Все альбомы</a><br />\n";
echo "</div>\n";

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