View file fotov4/foto/inc/user_show_foto.php

File size: 34.75Kb
<?

/*
 * Autor: Tw1nGo
 * vk.com/tw1ngo93
*/

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(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_foto']))
{
    $it = abs(intval($_GET['id_foto']));
    $foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '".$it."' LIMIT 1"));
    $ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$foto['id_user']."' LIMIT 1"));
}

// Если нет такого фото, то показуем ошибку
if (!isset($foto) || $foto['id'] <= 0){

$set['title'] = 'Фото - Ошибка';
include_once H.'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="/foto/">Фото</a> 
</span> 
</div>

<div class="err" style="padding: 10px;">
        <b>Ошибка!</b> Такого фото не существует!
</div>
</div>
<?

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

// Определяяем галерею фото
$gallery = mysql_fetch_assoc(query("SELECT * FROM `gallery` WHERE `id` = '".$foto['id_gallery']."' AND `id_user` = '".$ank['id']."' LIMIT 1")); 


// Запись просмотра
if (isset($user) && $user['id'] != $ank['id']){
	if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_count` WHERE `id_foto` = '".$foto['id']."' AND `id_user` = '".$user['id']."' LIMIT 1"),0)==0){
		mysql_query("INSERT INTO `gallery_foto_count` (`id_foto`, `id_user`) VALUES ('$foto[id]', '$user[id]')");
		mysql_query("UPDATE `gallery_foto` SET `count` = '".($foto['count']+1)."' WHERE `id` = '$foto[id]' LIMIT 1");
	}
}

// Определяяем ширину и длинну фото
$IS = GetImageSize(H.'sys/gallery/foto/'.$foto['id'].'.'.$foto['ras']);
printf("", $IS[0], $IS[1]);
$w = $IS[0];
$h = $IS[1];


// Изменение и удаление фото только хозяину или администрации
if ((user_access('foto_foto_edit')) || (isset($user) && $ank['id'] == $user['id'])){
	include 'inc/gallery_show_foto_act.php';
}


// Очищаем счетчик этого обсуждения
if (isset($user)){
	query("UPDATE `discussions` SET `count` = '0' WHERE `id_user` = '$user[id]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1");
	query("UPDATE `notification` SET `read` = '1' WHERE `type` = 'foto_komm' AND `id_user` = '$user[id]' AND `id_object` = '$foto[id]'");
}


// Проверка рейтинга фото
$rating = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_rating` WHERE `id_foto` = $foto[id] AND `id_user` = '$user[id]' LIMIT 1"));

// Не для автора фото
if (isset($user) && $user['id'] != $ank['id']){

// Ставим оценку
if (isset($_GET['rating']))
{
	$rate = (int) $_GET['rating'];
	
	if (mysql_result(query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]'"), 0) == 0)
	{	
		if ($rate > 0 && $rate < 7)
		{
			$c = mysql_result(query("SELECT COUNT(*) FROM `user_set` WHERE `id_user` = '$user[id]' AND `ocenka` > '$time'"), 0);
			
			if ($c == 0 && $rate == 6)
			{
      				$_SESSION['message'] = 'Необходимо активировать услугу';
      				header("Location: /user/money/plus5.php");
      				exit;
			}
			
		query("INSERT INTO `gallery_rating` (`id_user`, `id_foto`, `like`, `time`, `avtor`) values('$user[id]', '$foto[id]', '" . intval($_GET['rating']) . "', '$time', $foto[id_user])",$db);
		query("UPDATE `gallery_foto` SET `rating` = '" . ($foto['rating'] + intval($_GET['rating'])) . "' WHERE `id` = '$foto[id]' LIMIT 1",$db);
		$_SESSION['message'] = 'Ваша оценка принята.';
		header("Location: ?");
		exit;
			
		}
	}
}

// Если оценка меньше 5+, то можно повысить
if (isset($_GET['update']) && $rating['like'] > 0 && $rating['like'] <= 5)
{
	$rate = mysql_fetch_assoc(query("SELECT * FROM `gallery_rating` WHERE `id_foto` = $foto[id] AND `id_user` = '$user[id]' LIMIT 1"));
	$c = mysql_result(query("SELECT COUNT(*) FROM `user_set` WHERE `id_user` = '$user[id]' AND `ocenka` > '$time'"), 0);
	$my_ocenka = $rating['like'];
		
	if ($c == 0)
	{
      		$_SESSION['message'] = 'Необходимо активировать услугу';
      		header("Location: /user/money/plus5.php");
      		exit;
	}
		
	mysql_query("UPDATE `gallery_foto` SET `rating` = '".($foto['rating'] - $my_ocenka + 6)."' WHERE `id` = '$foto[id]' LIMIT 1");
	mysql_query("DELETE FROM `gallery_rating` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]' LIMIT 1");
	mysql_query("INSERT INTO `gallery_rating` (`id_user`, `id_foto`, `like`, `time`, `avtor`) values('$user[id]', '$foto[id]', '6', '$time', $foto[id_user])");
			
	$_SESSION['message'] = 'Ваша оценка изменена.';
	header("Location: ?");
	exit;	
}

}
	

// Перекинет на смайлы
if (isset($_POST['smiles'])){
	header("Location: /plugins/smiles/".SID);
	exit;
}
// Перекинет на бб коды
if (isset($_POST['bb_teg'])){
	header("Location: /plugins/rules/bb-code.php".SID);
	exit;
}


// Для юзеров
if (isset($user))
{
    // Ответ
    if (isset($_GET['reply']))
    {
        $r_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_komm` WHERE `id` = '".abs(intval($_GET['reply']))."' LIMIT 1"));
        if (!isset($r_post) || $r_post['id'] <= 0)
        {
            $r_post['id'] = 0;
        } 
        else {
            $r_ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$r_post['id_user']."' LIMIT 1"));
            if (!isset($r_ank) || $r_ank['id'] <= 0)
            {
                $r_post['id'] = 0;
            }
        }
    } 
    else {
        $r_post['id'] = 0;
    }
// Отправка комментария   
if (isset($_POST['msg']))
{
	$msg = $_POST['msg'];

	if ($mat)$err[] = 'В тексте сообщения обнаружен мат: '.$mat;
	if (strlen2($msg) > 1024 ){$err = 'Сообщение слишком длинное';}
	elseif (strlen2($msg) < 2 ){$err = 'Короткое сообщение';}
	elseif (mysql_result(query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$foto[id]' AND `id_user` = '$user[id]' AND `msg` = '".mysql_real_escape_string($msg)."' LIMIT 1"),0)!=0)
	{
		$err = 'Ваше сообщение повторяет предыдущее';
	}
	elseif(!isset($err))
	{		
		
		// Начисление баллов за активность
		include_once H.'sys/add/user.active.php';

		// Уведомления об ответах
		if (isset($ank_reply['id']))
		{
			$notifiacation = mysql_fetch_assoc(query("SELECT * FROM `notification_set` WHERE `id_user` = '" . $ank_reply['id'] . "' LIMIT 1"));
			
			if ($notifiacation['komm'] == 1 && $ank_reply['id'] != $user['id'])
			query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`) VALUES ('$user[id]', '$ank_reply[id]', '$foto[id]', 'foto_komm', '$time')");
			
		}

		// Отправляем друзьям обсуждения
		$q = query("SELECT * FROM `frends` WHERE `user` = '".$gallery['id_user']."' AND `i` = '1'");
		while ($f = mysql_fetch_array($q))
		{
			$a = get_user($f['frend']);
			$discSet = mysql_fetch_array(query("SELECT * FROM `discussions_set` WHERE `id_user` = '".$a['id']."' LIMIT 1")); // Общая настройка обсуждений
			
			if ($f['disc_foto'] == 1 && $discSet['disc_foto'] == 1) 
			{
				if (mysql_result(query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$a[id]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1"),0)==0)
				{
					if ($a['id'] != $user['id'] || $a['id'] != $foto['id_user'])
					query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$a[id]', '$gallery[id_user]', 'foto', '$time', '$foto[id]', '1')"); 
				}
				else{
					$disc = mysql_fetch_array(query("SELECT * FROM `discussions` WHERE `id_user` = '$a[id]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1"));
					
					if ($gallery['id_user'] != $user['id'] || $a['id'] != $foto['id_user'])
					query("UPDATE `discussions` SET `count` = '" . ($disc['count'] + 1) . "', `time` = '$time' WHERE `id_user` = '$a[id]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1");
				}

			}
		}

		// Отправляем автору обсуждения
		if (mysql_result(query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$gallery[id_user]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1"),0)==0)
		{
			if ($gallery['id_user'] != $user['id'])
			query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$gallery[id_user]', '$gallery[id_user]', 'foto', '$time', '$foto[id]', '1')");
		}
		else{
			$disc2 = mysql_fetch_array(query("SELECT * FROM `discussions` WHERE `id_user` = '$gallery[id_user]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1"));
			if ($gallery['id_user'] != $user['id'])
			query("UPDATE `discussions` SET `count` = '".($disc2['count']+1)."', `time` = '$time' WHERE `id_user` = '$gallery[id_user]' AND `type` = 'foto' AND `id_sim` = '$foto[id]' LIMIT 1");
		}

		if (isset($r_post) && $r_post['id'] > 0){		
			mysql_query("INSERT INTO `gallery_komm` (`id_foto`, `id_ank`, `id_user`, `msg`, `time`) values ('".$foto['id']."', '".$r_ank['id']."', '".$user['id']."', '".my_esc($msg)."', '".$time."')");
		}
		else{
			mysql_query("INSERT INTO `gallery_komm` (`id_foto`, `id_user`, `msg`, `time`) values ('".$foto['id']."', '".$user['id']."', '".my_esc($msg)."', '".$time."')");
		}
		
		$_SESSION['message'] = 'Сообщение успешно добавлено';
		header("Location: ?page=".intval($_GET['page']));
		exit;
	}
}

}

// Помечаем жалобу на фото как просмотренную!
if (user_access('foto_foto_edit') || isset($user) && $user['level'] >= 3){
	mysql_query("UPDATE `gallery_foto_complain` SET `read` = '0' WHERE `id_foto` = '".$foto['id']."' LIMIT 1");
}

// Удаление коммента
if ((user_access('foto_komm_del') || isset($user) && $ank['id'] == $user['id']) && isset($_GET['delete']) && mysql_result(query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id`='".intval($_GET['delete'])."' AND `id_foto`='$foto[id]' LIMIT 1"),0)!=0)
{
	query("DELETE FROM `gallery_komm` WHERE `id`='".intval($_GET['delete'])."' LIMIT 1");
	admin_log('Фотогалерея','Фотографии', "Удаление комментария к фото [url=/id$ank[id]]" . user::nick($ank['id'], 0) . "[/url]");
	$_SESSION['message'] = 'Комментарий успешно удален';
	header("Location: ?page=".intval($_GET['page']));
	exit;
}

// Вывод самой страницы с фото
$set['title'] = text($foto['name']);
include_once H.'sys/inc/thead.php';
title();
err();
aut();


// Определяем возраст для метки 18+
if (isset($user)) {
    $user['ank_age'] = 0;
    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;
        } elseif (date("n") == $user['ank_m_r'] && date("j") < $user['ank_d_r']) {
            $user['ank_age'] = $user['ank_age'] - 1;
        }
    }
}


?>
<link rel="stylesheet" href="/foto/style/style-foto.css" type="text/css" />
<script type="text/javascript" src="/foto/style/jquery-1.8.3.js"></script>
<script type="text/javascript" src="/foto/style/Tw1nGo.js"></script>
<div class="foto_head_bg"> 
<?



// Подключаем приватность стр. 
include H.'sys/add/user.privace.php';

// Если установлена приватность альбома
if ($gallery['privat'] == 1 && ($frend != 2 || !isset($user)) && $user['level'] <= $ank['level'] && $user['id'] != $ank['id'])
{
?>
<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($gallery) && $gallery['id'] > 0){
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><?= text($gallery['name'])?></a> 
</span>    
<?
}
else{
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/">Фотографии</a> 
</span>    
<?
}   
?>
</div>                
<?
	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'])
{
?>
<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($gallery) && $gallery['id'] > 0){
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><?= text($gallery['name'])?></a> 
</span>    
<?
}
else{
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/">Фотографии</a> 
</span>    
<?
}   
?>
</div>                
<?
	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['message'] = 'Неверный пароль'; 
			$_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))
{
if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'])){
	if (user_access('foto_foto_edit') || isset($user) && $ank['id'] == $user['id']){
	include 'inc/gallery_show_foto_form.php';
	}
}
?>
<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($gallery) && $gallery['id'] > 0){
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><?= text($gallery['name'])?></a> 
</span>    
<?
}
else{
?>
<span class="lc_brw"> 
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $ank['id']?>/">Фотографии</a> 
</span>    
<?
}   


if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'] || $user['ank_age'] >= 18)){
if (isset($user) && $user['id'] != $ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_complain` WHERE `id_foto` = '".$foto['id']."' AND `id_user` = '".$user['id']."' AND `read` = '1'"), 0) == 0){
	include 'inc/gallery_foto_complain.php';
}
}
?>
</div>
<div class="wrapper">                 
<?





// +5 оценка 
$rat = mysql_result(query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_foto` = $foto[id] AND `like` = '6'"), 0); 

if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'] || $user['ank_age'] >= 18)) // Метка 18+ 
{
?>
<div class="title12 oh black relative text_left "> 
<span class="block-title oh break-word"> 
<!-- --><img src="/foto/style/ico/pic.png" alt="" class="m p16"><!--  -->
<span class="m"><!-- --><?= text($foto['name'])?>.<span class="grey"><?= $foto['ras']?></span> </span>    
<?
if ($foto['metka'] == 1){
?>
<img src="/foto/style/ico/adult.png" class="p16 m" alt="">  
<?
}
if (isset($user) && $user['id'] != $ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_complain` WHERE `id_foto` = '".$foto['id']."' AND `id_user` = '".$user['id']."' AND `read` = '1'"), 0) == 0){
?>
<span class="close_btn">    <a href="?complain" class="inl-link   ">       
<span class="no-text">   <img src="/foto/style/ico/complaint.png " alt="" class="m">   </span>       <!-- --><!-- --><!-- -->
</a><!-- -->  </span>
<?
}
?>   
</span> 
</div>

<div class="block">   
<div class="image_limit t_center font0"> 
<div class="relative inl_bl">

<a class="tdn" href="/foto/foto0/<?= $foto['id']?>.<?= $foto['ras']?>">   
<div class="inl_bl relative"> 
<img src="/foto/foto640/<?= $foto['id']?>.<?= $foto['ras']?>" alt="" class="preview">
<?
if ($rat > 0)echo "<div style='display:inline;margin-left:-45px;vertical-align:top;'><img style='padding-top:15px;' src='/style/icons/5_plus.png'/></div>";
?>   
</div>      
</a>
</div> </div>         <div>  </div>   
<?
		
// Оценка фото
if (isset($user) && $user['id'] != $ank['id'])
{
echo '<div class="pad_t_a t_center">';
if ($user['id'] != $ank['id'] &&  mysql_result(query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]'"), 0)==0)
{
for($i = 6; $i >= 1; $i--) {
?>
<a href="?rating=<?= $i?>" title="<?= $i?>"><img class="" src="/style/icons/<?= $i?>.png" alt=""></a> 
<?
} 

}
else{
$rate = mysql_fetch_assoc(query("SELECT * FROM `gallery_rating` WHERE `id_foto` = $foto[id] AND `id_user` = '$user[id]' LIMIT 1"));
			
if (isset($user) && $user['id'] != $ank['id'])
	echo 'Ваша оценка <img src="/style/icons/' . $rate['like'] . '.png" alt=""/> ';
if ($rating['like'] < 6) {
?>
<span style="padding-left: 5px;">Повысить до <a href="?update"><img src="/style/icons/6.png" alt=""></a><span>
<?
}
}
echo '</div>';
}
		
if ($foto['opis'] != null){
?>
<div class="pad_t_a break-word"> <?= output_text($foto['opis'])?> </div> 
<?
}
?>   
</div>
<?		
}
elseif (!isset($user))
{
?>
<div class="block bord-botm t_center grey">  
<div class="t_center b black upcs"> Материал для взрослых (18+) </div>   
<div class="t_center pad_t_a">      
<span class="no-text">   <img src="/foto/style/ico/attention.png " alt="" class="m">   </span>        
</div>  
<div class="t_center  grey pad_t_a"> Данный файл содержит изображения эротического характера. Только зарегистрированные пользователи старше 18 лет могут просматривать такие файлы.</div> 
</div>
<table class="table__wrap table__links"> <tbody><tr>  
<td class="table__cell" width="50%">     <a href="/aut.php" class="link -full"> <span>Вход</span>  </a>     </td>  
<td class="table__cell table__cell_last" width="50%"> <a href="/reg.php" class="link -full"> <span>Регистрация</span>  </a>  </td>  
</tr> </tbody></table>
<?
}
elseif (isset($user) && $user['ank_age'] < 18) {
?>
<div class="block bord-botm t_center grey">  
<div class="t_center b black upcs"> Материал для взрослых (18+) </div>   
<div class="t_center pad_t_a">      
<span class="no-text">   <img src="/foto/style/ico/attention.png " alt="" class="m">   </span>        
</div>  
<div class="t_center  grey pad_t_a"> Внимание! Этот материал только для взрослых! Нажимая ДА, вы подтверждаете, что вам 18 или более лет. Если вам менее 18 лет - нажмите НЕТ.<br /> Так же Вы можете отключить предупреждения в <a href="/user/info/settings.php">настройках</a>.</div> 
</div>
<table class="table__wrap table__links"> <tbody><tr>  
<td class="table__cell" width="50%">     
<a href="?sess_abuld=1" class="link -full           "> <span><!--     --><img src="/foto/style/ico/ok_blue.png " alt="" class="m"> <!--   --><span class="m blue c-blue">Да</span><!--    --> </span>  </a>     
</td>  
<td class="table__cell table__cell_last" width="50%">     <a href="/" class="link -full           "> <span>Нет</span>  </a>     </td>  
</tr> </tbody></table>
<?
}

	/*----------------------листинг-------------------*/
$listr = mysql_fetch_assoc(query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]' AND `id` < '$foto[id]' ORDER BY `id` DESC LIMIT 1"));
$list = mysql_fetch_assoc(query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]' AND `id` > '$foto[id]' ORDER BY `id`  ASC LIMIT 1"));
$k_1 = mysql_result(query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id` > '$foto[id]' AND `id_gallery` = '$gallery[id]'"),0) + 1;
$k_2 = mysql_result(query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]'"),0);
if (isset($gallery) && $gallery['id'] > 0){
$pag_galler = $gallery['id'];
}
else{
$pag_galler = '0';
}



// Разделяем если стоит метка!
if (($user['abuld'] != 1 && $foto['metka'] != 0 && $foto['id_user'] != $user['id'] && $user['ank_age'] < 18)){
?>
</div>
<?
if (isset($user) && $user['ank_age'] < 18) {
?>
<div class="wrapper-nobg t_center grey"> Чтобы не подтверждать каждый раз возраст, укажите его в <b>   <a href="/user/info/anketa.php" class="inl-link    link-darkblue c-darkblue">  своей анкете<!-- --><!-- --><!-- --></a><!-- --> </b> </div>
<?
}
?>
<div class="wrapper" style="border-top: 0;">                 
<?
}


?>
<div class="bord-top">
<div class="pag"> <div class="pgar oh font0"> 
<table class="table__wrap"> <tbody><tr> 

<td class="table__cell" width="35%"> 
<div class="pagw">  
<?
if($list['id']){
?>
<a href="/foto/<?= $ank['id']?>/<?= $pag_galler?>/<?= $list['id']?>/"> ← Назад </a>
<?
}else{
?>
<a class="m grey">← Назад</a>
<?
}
?>
</div> 
</td> 

<td class="table__cell"> 
<div class="pagw pagwb"> <span class="blk"><?= $k_1?> из <?= $k_2?></span> </div> 
</td> 

<td class="table__cell" width="35%"> 
<div class="pagw">  
<?
if($listr['id']){
?>
<a href="/foto/<?= $ank['id']?>/<?= $pag_galler?>/<?= $listr['id']?>/"> Вперёд → </a>
<?
}else{
?>
<a class="m grey">Вперёд →</a>
<?
}
?> 
</div> 
</td> 
</tr> </tbody></table> 
</div> </div>
</div>
<?
/*--------/-\-------------Tw1nGo--------/-\-------------*/
?>
</div>
<?

if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'] || $user['ank_age'] >= 18))
{

// Автор фото, что-бы не выводить по $ank
$autor_foto = get_user($foto['id_user']);
// Закладки счетчик
$count_bobmarks = mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0);
// Лайки
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_like` WHERE `like` = '1' AND `id_foto` = '".$foto['id']."' LIMIT 1"),0);
$us_like = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_like` WHERE `like` = '1' AND `id_user` = '".$user['id']."' AND `id_foto` = '".$foto['id']."' LIMIT 1"),0);
?>
<div id="download_wrap_9">     
<div class="wrapper">      
<a href="/foto/foto0/<?= $foto['id']?>.<?= $foto['ras']?>" class="link -full  blue      "> 
<span>
<!--     -->
<img src="/foto/style/ico/download2_blue.png" alt="" class="m"> <!--   -->
<span class="m">Скачать (<?=  size_file(filesize(H.'sys/gallery/foto/'.$foto['id'].'.jpg'))?>, <?= $w?>×<?= $h?>)</span>
<!--    -->
</span>  
</a>      
</div>     
</div>

<div class="wrapper"> 

<div class="block"> 
<div class="grey"> Добавлен<?= ($autor_foto['pol'] == 1 ? '' : 'а')?>:  <?= group($autor_foto['id'])?>  
<a href="/info.php?id=<?= $autor_foto['id']?>" class="mysite-link"><b class="nick"><?= $autor_foto['nick']?></b></a>   (<?= vremja($foto['time'])?>) 
</div>
<div class="pad_t_a grey cf"> 
<span class="m">В альбом: 
<!-- -->
<?
if (isset($gallery) && $gallery['id'] > 0){
?>
<a class="arrow_link break-word" href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><span><?= text($gallery['name'])?></span></a>    
<?
}
else{
?>
<a class="arrow_link break-word" href="/foto/<?= $ank['id']?>/"><span>Фотографии</span></a>     
<?
}   
?>
</span>    
</div>
</div>

<div class="block"> 
<table class="signature table__wrap table__wrap-fixed table_no_borders grey"> <tbody><tr>
<td class="table__cell"> 
<img src="/foto/style/ico/eye_small.png" class="p16 m" alt=""> <span class="m"><?= $foto['count']?></span> 
</td>
<td class="table__cell" id="fav_who_<?= $foto['id']?>"> 
<?
if ($count_bobmarks == 0){
?>
<img src="/foto/style/ico/fav_small.png" class="p16 m" alt=""> <span class="m"><?= $count_bobmarks?></span> 
<?
}
else{
?>
<a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/fav/<?= $foto['id']?>/" class="link-stnd "> 
<img src="/foto/style/ico/fav_small_blue.png" class="p16 m" alt=""> <span class="m"><?= $count_bobmarks?></span> </a>
<?
}
?>
</td>
<td class="table__cell" id="like_who_<?= $foto['id']?>"> 
<?
if($like == 0){
?>
<img src="/foto/style/ico/vote_up_small.png" class="p16 m" alt=""> <span class="m"><?= $like?></span> 
<?
}
else{
?>
<a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/like/<?= $foto['id']?>/" class="link-stnd"> <img src="/foto/style/ico/vote_up_dark_blue_small.png" class="p16 m" alt=""> <span class="m"><?= $like?></span> </a>
<?
}
?>   
</td>
</tr> </tbody></table>
</div>
<?


if (isset($user)){
?>
<div class="oh bord-top js-action_bar action-bar"> 
<table class="table__wrap table__wrap-fixed grey"> <tbody><tr> 
<?
if (user_access('foto_foto_edit') && $ank['level'] < $user['level'] || isset($user) && $ank['id'] == $user['id']){
?> 
<td class="table__cell relative m"> 
<a href="?act=rename" class="link cursors" title="Редактировать"> <img src="/foto/style/ico/profile.png" alt="" class="m"> </a> 
</td>       
<?
}
if($ank['id'] != $user['id']){
?> 
<td class="table__cell relative m"> 
<a href="/foto/collections/<?= $user['id']?>/?act=add&photo=<?= $foto['id']?>" class="link cursors" title="Добавить в коллекцию"> <img src="/foto/style/ico/plus_grey.png" alt="" class="m"> </a> 
</td>       
<?
}
?>
<td class="table__cell relative m" id="fav_photo_<?= $foto['id']?>"> 
<?
if (mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0) == 0){
?>
<a onclick="fav_photo(<?= $foto['id']?>);" class="link cursors" title="В закладки"> 
<img src="/foto/style/ico/fav.png" alt="" class="m">  </a> 
<?
}
else{
?>
<a onclick="fav_photo(<?= $foto['id']?>);" class="link cursors" title="Удалить из закладок"> 
<img src="/foto/style/ico/fav_on.png" alt="" class="m">  </a> 
<?
}
?>
</td> 
<?

if ($ank['id'] != $user['id']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_like` WHERE `id_user` = '".$user['id']."' AND `id_foto` = '".$foto['id']."' LIMIT 1"),0) == 0){
$ico_vote_up = 'vote_up';
}else{
if($us_like){
$ico_vote_up = 'vote_up_on';
}
}
}else{
$ico_vote_up = 'vote_up_disabled';
}
?>  
<td class="table__cell relative m bord-right0" id="like_photo_<?= $foto['id']?>">  
<a onclick="like_photo(<?= $foto['id']?>);" class="link m cursors"> <img src="/foto/style/ico/<?= $ico_vote_up?>.png" alt="" class="m p16"> </a> 
</td>   
</tr> </tbody></table>   
<?
if ($ank['id'] != $user['id']){
$add_my = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_collect_foto` WHERE `id_user` = '".$user['id']."' LIMIT 1"),0);
if($add_my < 3){
?>
<div class="busi t_center" id="collections_motivator_<?= $foto['id']?>" style="border: 0;border-top: 1px solid #d9cebf;margin: 0;"> <span class="m">Сохраните этот файл в свою коллекцию. Нажмите кнопку</span> <img src="/foto/style/ico/plus_grey.png" alt="" class="m"> </div>
<?
}
}
?>     
</div>
<?
}
?>
</div>
<?
}


if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'] || $user['ank_age'] >= 18))
{
// Вывод комментариев

$k_post = mysql_result(query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$foto[id]'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

?>
<a name="page-up"></a>
<div class="header oh text_left" id="look_komm"> <b class="upcs m">Комментарии (<?= $k_post?>)</b>     
</div>
<?

if ($k_post > 0){

?>
<div class="wrapper" style="border-bottom: 0;">
<?

$q = query("SELECT * FROM `gallery_komm` WHERE `id_foto` = '$foto[id]' ORDER BY `id` $sort LIMIT $start, $set[p_str]");

while ($post = mysql_fetch_assoc($q))
{
	$post_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$post['id_user']."' LIMIT 1"));
        $post_ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$post['id_ank']."' LIMIT 1"));
	$postBan = mysql_result(query("SELECT COUNT(*) FROM `ban` WHERE (`razdel` = 'all' OR `view` = '0' OR `razdel` = 'foto') AND `id_user` = '$post_user[id]' AND (`time` > '$time' OR `navsegda` = '1')"), 0);

?>
<div id="<?= $post_user['id']?>" data-link="#page-up">
<?
// Блок сообщения
if ($postBan == 0) 
{
?> 
<div class="comm oh"> 
<?
}else{
?> 
<div class="comm oh comm_hidden">
<?
}
?>
<a name="com<?= $post['id']?>"></a>  

<div class="p40 left t-padd_right">      
<a class="tdn" href="/info.php?id=<?= $post_user['id']?>">   
<div class="inl_bl relative"> <?= avatar($post_user['id'],false,50,40)?>   </div>      
</a>        
</div> 

<div class="oh">  
<div> 
 <span> 
<span class="p16"> <?= group($post_user['id'])?></span>  <a href="/info.php?id=<?= $post_user['id']?>" class="mysite-link"><b class="nick black"><?= $post_user['nick']?></b></a>    
<?= medal($post_user['id'])?> <?= online($post_user['id'])?>
</span> 
<div class="right">  
<a class="grey js-link_copy"> <span class="m">  <?= vremja($post['time'])?>  </span> </a>  
</div> 
</div> 
<?
if (isset($post_ank) && $post_ank['id'] > 0){
?>
<div class="grey gl">ответил<?= ($post_user['pol'] == 1 ? '' : 'а')?>  <a class="b" href="/info.php?id=<?= $post_ank['id']?>"><?= $post_ank['nick']?></a>  </div> 
<?
}
?> 
</div>    
<div class="cl">     
<div style="padding-top: 5px;"> 
<?
// Блок сообщения
if ($postBan == 0) 
{
?>
<?= output_text($post['msg'])?>
<?
}else{
?> 
<div class="cl">    <div>Комментарий скрыт</div>  </div>
<?
}
?>
</div>       
</div>  
<?
if (isset($user)){
?>
<div class="oh pad_t_a">  
<?
if ($postBan == 0) 
{
if($user['id'] != $post_user['id']){
?>
<a href="?reply=<?echo $post['id'];?>#komm_otv" class="link-grey js-comm_reply">Ответить</a>  
<?
if (user_access('foto_komm_del') || $ank['id'] == $user['id']) {
echo ' | ';
}
}
}
if (user_access('foto_komm_del') || $ank['id'] == $user['id'] || $user['level'] >= 4) {
?>
<span class="slb"><a href="?delete=<?= $post['id']?>">Удалить</a>  </span>
<?
}
?>
</div>
<?
}
?>
</div>   </div>
<?
}
?>
</div>
<?	
}
?>
<a name="page-down"></a>
<?

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



if (isset($user))
{
?>
<div class="comm_form" id="komm_otv">   
<div>  
<div id="comments_form_wrap">
<div id="comments_form">  
<?
if (isset($r_post) && $r_post['id'] > 0){
?>
<form action="?page=<?=  $pageEnd?>&reply=<?echo $r_post['id'];?>" method="post" name="message">  
<div class="wrapper block pd0">  
<div id="comments_form_reply" class="stnd_padd pdb"> 
<span class="grey">Ответить на комментарий</span> 
<span id="comments_form_user"> <span class="p16"><?= group($r_ank['id'])?></span>
<a href="/info.php?id=<?= $r_ank['id']?>" class="mysite-link"><b class="nick black"><?= text($r_ank['nick'])?></b> </a> 
</span> </div>
<? 
}
else{
?>
<form action="?page=<?=  $pageEnd?>" method="post" name="message">  
<div class="wrapper block pd0"> 
<?
}
?>  
<div class="block  js-toolbar_wrap">  <div class="text-input__wrap"> 
<div class="cl" style="margin-bottom: 5px;"> <div class="relative">  
<div class="input-txt_wrapper"> 
<textarea class="input-txt" tabindex="1" name="msg" rows="4" id="textarea" data-maxlength="1000" data-toolbar="{hide:true,disable:{}}" cols="17" placeholder="Напишите комментарий"></textarea> 
</div> 
</div> </div>    
</div> </div>    

<div class="block wide pdt">   
<div class="cf "> 
<span class="form-tools__left left">  <!-- --><!-- --><!-- --><!-- --><!-- -->
<button name="smiles" value="" class="  url-btn     " id="smiles_btn"><!--   -->
<img src="/foto/style/ico/smile.png" alt="" class="m"> <!--   --><span class="m"> </span><!-- -->
</button><!-- --><!-- -->  </span>   
<span class="form-tools__left left"><span class="js-bb_toggle"> <!-- --><!-- --><!-- --><!-- --><!-- -->
<button name="bb_teg" value="" class="  url-btn     " id="response_btn"><!--   -->
<img src="/foto/style/ico/a.png" alt="" class="m"> <!--   --><span class="m"> </span><!-- -->
</button><!-- --><!-- --> </span> 
</span>   
<input value="Отправить" class="main_submit right" type="submit">  
</div> </div> </div>   
</form> </div></div>  </div>   </div>
<?
}
	
}

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

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