<?

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

//Если вы в бане 
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'foto' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0)!=0){
header('Location: /user/ban.php?'.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: /modules/photo/' . $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'] = '' . text($gallery['name']); 

//Редактирование альбома и загрузка фото
include 'inc/gallery_show_act.php';

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

//Формы
include 'inc/gallery_show_form.php';

$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){
echo '<div class="block2">Нет публикаций</div>';
}else{

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

//Вывол фотографий
echo '<div class="album">';
while ($post = mysql_fetch_assoc($q)){

echo '<a class="flowap-album_item" href="/modules/photo/' . $ank['id'] . '/' . $gallery['id'] . '/' . $post['id'] . '/">';
echo '<div class="flowap-album_thumb_wrap">';
echo '<div class="flowap-album_thumb flowap-album-fill">';
echo '<img class="flowap-album_thumb_img" src="/modules/photo/foto/' . $post['id'] . '.' . $post['ras'] . '">';
echo '</div>';
echo '</div>';
echo '</a>';

}

}

echo '</div>';
	
# Навигация
if ($k_page > 1)str('?', $k_page, $page); 

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

?>