View file fotov4/foto/inc/user_gallery_show.php

File size: 10.27Kb
<?
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;}

// Если вы в бане 
if (isset($user) && 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: /ban.php?'.SID);
	exit;
}


// Альбом
if (isset($_GET['id_gallery']))
{
$it = intval($_GET['id_gallery']);
$gallery = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '".$it."' LIMIT 1"));
} 
else {
$gallery['id'] = 0;
}
if (!isset($gallery) || $gallery['id'] <= 0)
{
	header('Location: /foto/' . $ank['id'] . '/?' . SID);
	exit;
}


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


// заголовок страницы
$set['title'] = text($gallery['name']) . ' :  Фото '; 

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



?>
<link rel="stylesheet" href="/foto/style/style-foto.css" type="text/css" />
<div class="foto_head_bg">    
<?


?>
<div class="lc_br wbg font0 relative oh" id="header_path">  
<a href="/" style="font-size:0;"> <img src="/foto/style/ico/home.png" alt=""> </a>     
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/info.php?id=<?= $ank['id']?>"><?= $ank['nick']?></a> 
</span>     
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/">Фото</a> 
</span>    
<?
if(isset($user) && $user['id'] == $ank['id']){
if (isset($_GET['edit']) && $_GET['edit'] == 'rename'){
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">Редактируем папку <?= text($gallery['name'])?></span> 
</span>
<?
}
}
?>   
</div>                 
<?

err();

// Создание альбомов
include 'inc/gallery_new.php';

include 'inc/gallery_show_form.php';

?>
<div class="wrapper-nobg t_center break-word"> 
<img src="/foto/style/ico/dir.png" alt="" class="p16 m"> 
<b class="upcs m"><!--   --><span><?= text($gallery['name'])?></span> </b>  
<?
if (isset($user) && (user_access('foto_alb_del') || $user['id'] == $ank['id'])){
?>  
<a href="?edit=rename" class="inl-link " style="margin-left:5px;">       
<span class="no-text">   <img src="/foto/style/ico/profile.png" alt="" class="m">   </span>     <!-- --><!-- --><!-- -->
</a><!-- --> 
<?
}
?>
<br>
<?= output_text($gallery['opis'])?>
</div>
<?

if (isset($user) && $ank['id'] == $user['id']){
if ($gallery['my'] == 0){
?>
<div class="wrapper">   
<table class="table__wrap table__links"> <tbody><tr>  
<td class="table__cell" width="50%">     
<a href="?act=create" class="link -full  blue      "> 
<span><!--     --><img src="/foto/style/ico/dir_create.png" alt="" class="m"> <!--   --><span class="m">Создать папку</span><!--    --></span>  
</a>    
</td>  
<td class="table__cell table__cell_last" width="50%">     
<a href="?act=upload" class="link -full  blue      "> 
<span><!--     --><img src="/foto/style/ico/upload_blue.png" alt="" class="m"> <!--   --><span class="m"> Добавить файл</span><!--    --></span>  
</a>    
</td> 
</tr> </tbody></table>    
</div>
<?
}
else{
?>
<div class="wrapper">   
<table class="table__wrap table__links"> <tbody><tr>  
<td class="table__cell table__cell_last" width="100%">     
<a href="?act=upload" class="link -full  blue      "> 
<span><!--     --><img src="/foto/style/ico/upload_blue.png" alt="" class="m"> <!--   --><span class="m"> Добавить файл</span><!--    --></span>  
</a>    
</td>  
</tr> </tbody></table>    
</div>
<?
}

}


// Приватность
$uSet = mysql_fetch_array(mysql_query("SELECT * FROM `user_set` WHERE `id_user` = '$ank[id]'  LIMIT 1"));
$frend = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$user[id]' AND `frend` = '$ank[id]') OR (`user` = '$ank[id]' AND `frend` = '$user[id]') LIMIT 1"),0);
$frend_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE (`user` = '$user[id]' AND `to` = '$ank[id]') OR (`user` = '$ank[id]' AND `to` = '$user[id]') LIMIT 1"),0);

/*
* Если установлена приватность альбома
*/	
if ($gallery['privat'] == 1 && ($frend != 2 || !isset($user)) && $user['level'] <= $ank['level'] && $user['id'] != $ank['id'])
{
	echo '<div class="mess" style="padding: 10px;margin: 5px;">';
	echo 'Просматривать альбом пользователя могут только его друзья!';
	echo '</div>';

	$block_foto = true;
}
elseif ($gallery['privat'] == 2 && $user['id'] != $ank['id'] && $user['level'] <= $ank['level'])
{
	echo '<div class="mess" style="padding: 10px;margin: 5px;">';
	echo 'Пользователь запретил просмотр этого альбома!';
	echo '</div>';
	
	$block_foto = true;
}

/*--------------------Альбом под паролем-------------------*/
if ($user['id'] != $ank['id'] && $gallery['pass'] != NULL)
{
	if (isset($_POST['password']))
	{
		$_SESSION['pass'] = my_esc($_POST['password']);
		
		if ($_SESSION['pass'] != $gallery['pass'])
		{
			$_SESSION['err'] = 'Неверный пароль'; 
			$_SESSION['pass'] = NULL;
		}
		header("Location: ?");
	}

	if (!isset($_SESSION['pass']) || $_SESSION['pass'] != $gallery['pass'])
	{
	?>
	<div class="oh busi">
	<form action="?" method="POST">
	<div class="stnd_padd" style="padding: 0 0 10px;">
	<span>Пароль:<span><br />
	<input type="pass" name="password" value="" />
	</div>
	<button type="submit" value="Продолжить" class="  submit_link" id="pcfms"><span class="m">Продолжить</span><!-- --></button>
	</form>
	</div>
	<?

		include_once '../sys/inc/tfoot.php';
		exit;
	}
}
/*---------------------------------------------------------*/

if (!isset($block_foto))
{

    $q = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '".$ank['id']."' AND `my` = '".$gallery['id']."' ORDER BY `id` DESC");
    while ($post = mysql_fetch_assoc($q))
    {
        $list[] = array('kat' => 1, 'post' => $post);
    }
    $q = mysql_query("SELECT * FROM `gallery_foto` WHERE `id_user` = '".$ank['id']."' AND `id_gallery` = '".$gallery['id']."' ORDER BY `id` DESC");
    while ($post = mysql_fetch_assoc($q))
    {
        $list[] = array('kat' => 0, 'post' => $post);
    }
    if (!isset($list))
    {
        $k_post = 0;
    } else {
        $k_post = sizeof($list);
    }



if ($k_post == 0)
{
?>
<div class="wrapper"> <div class="block grey"> Список пуст. </div> </div>
<?
}
else{

    $set['p_str'] = '30';
    $k_page = k_page($k_post,$set['p_str']);
    $page = page($k_page);
    $start = $set['p_str']*$page-$set['p_str'];

?>
<div class="wrapper">
<div id="sz_gallery_loader" data-type="user" class="wbg oh tiles_block">
<?

    for ($i=$start; $i<$k_post && $i<$set['p_str']*$page; $i++)
    {

        if ($list[$i]['kat'] == 1)
        {

                $post = $list[$i]['post'];
                $k_c = 0;
                $k_c = $k_c+mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '".$ank['id']."' AND `id_gallery` = '".$post['id']."'"), 0);
                if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '".$ank['id']."' AND `my` = '".$post['id']."'"), 0) > 0)
                {
                    $q2 = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '".$ank['id']."' AND `my` = '".$post['id']."' ORDER BY `id` DESC");
                    while ($post2 = mysql_fetch_assoc($q2))
                    {
                        $k_c = $k_c+mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '".$post2['id']."'"), 0);
                    }
                }   
    
// Cчетчик фотографий
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"),0);
$files = array('файл', 'файла', 'файлов');

if($post['pass'] != null){
$ico_name = 'dir_password';
}
else{

if($post['privat'] == 1){
$ico_name = 'dir_friends';
}
elseif($post['privat'] == 2){
$ico_name = 'dir_locked';
}
else{
$ico_name = 'dir_all';
}

}
// Хозяин
$ank_id = get_user($post['id_user']);

?>
<a class="link arrow oh" href="/foto/<?= $ank['id']?>/<?= $post['id']?>/"> 
<div class="left">   <img src="/foto/style/ico/<?= $ico_name?>.png" class="m p40" alt="">  </div> 
<div class="oh pre_content_wrap grey"> 
<b class="darkblue break-word"> <?= text($post['name'])?> </b>
<div class="pd_t5"> <?= des2num($k_c, $files)?> </div>
</div>
</a> 
<?

}
else{



$post = $list[$i]['post'];
$ank = get_user($post['id_user']);
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"),0);


?>
<div class=" tiled_item tiled_item-200" style="padding-top: 5px;">  
<div class="tiled_inner t_center relative">  
<span class="relative" style="display: inline-block;max-width: 100%; width: 100%;overflow: hidden;"> 
<div class="inl_bl22">        
<a class="tdn" href="/foto/<?= $ank['id']?>/<?= $post['id_gallery']?>/<?= $post['id']?>/">   
<img src="/foto/foto640/<?= $post['id']?>.<?= $post['ras']?>" class="preview preview99 s201_200"> 
<?
if ($post['metka'] == 1){
?> 
<img src="/foto/style/ico/adult.png" class="p16 f_18p" alt="">    
<?  
}
?>   
</a>             
</div>   
</span>   
<div class="tile_descr">        
<div class="pl_photo_image_info oh">  
<span class="tf grey"> 
<?
if($post['count'] > 0){
?>
<span class="inl_bl">  <img src="/foto/style/ico/eye.png" alt="" class="m">  <span class="m"><?= $post['count']?></span> </span>    
<?
}
if($comm > 0){
?>  
<span class="t-padd_left"> <img src="/foto/style/ico/com.png" class="m" alt=""> <span class="m"><?= $comm?></span> </span>    
<?
}
?>
</span>   
</div>   </div>   
</div> 
</div>
<?


}

}

?>
</div>
</div>
<?    

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

}

?>
<a href="/foto/<?= $ank['id']?>/" class="link darkblue return full_link">  <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back">   Назад  </a>
<div style="height: 1px;"></div>   
</div>
<?

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