Просмотр файла social/foto/inc/user_show_foto.php

Размер файла: 25.92Kb
<?

/*
* Autor :: Tw1nGo
* Sait ::: xSimka.Ru
*/

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

$gallery['id'] = intval($_GET['id_gallery']);

if (mysql_result(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(query("SELECT * FROM `gallery` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1")); 
$foto['id'] = intval($_GET['id_foto']);

if (mysql_result(query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id` = '$foto[id]' LIMIT 1"),0)==0)
{
	header("Location: /foto/$ank[id]/$gallery[id]/?".SID);
	exit;
}

$foto = mysql_fetch_assoc(query("SELECT * FROM `gallery_foto` WHERE `id` = '$foto[id]'  LIMIT 1"));


/*
================================
Закладки
================================
*/

// Добавляем в закладки
if (isset($_GET['fav']) && $_GET['fav'] == 1)
{ 
	if (mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0) == 0)
	{
		query("INSERT INTO `mark_foto` (`id_foto`, `id_user`, `time`) VALUES ('$foto[id]', '$user[id]', '$time')");
		$_SESSION['message'] = 'Фото добавлено в закладки'; 
		header("Location: /foto/$ank[id]/$gallery[id]/$foto[id]/?page=" . intval($_GET['page']));
		exit;
	}
}

// Удаляем из закладок
if (isset($_GET['fav']) && $_GET['fav'] == 0)
{ 
	if (mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0) == 1)
	{
		query("DELETE FROM `mark_foto` WHERE `id_user` = '$user[id]' AND  `id_foto` = '$foto[id]' ");
		$_SESSION['message'] = 'Фото удалено из закладок'; 
		header("Location: /foto/$ank[id]/$gallery[id]/$foto[id]/?page=" . intval($_GET['page']));
		exit;
	}
}


$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]'");
}
/*---------------------------------------------------------*/

/*
==========================
Оценка к фото
==========================
*/
	
if (isset($user) && $user['id'] != $ank['id'] && mysql_result(query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]'"), 0) == 0)
{	
	if ( isset($_GET['rating']) && $_GET['rating'] > 0 && $_GET['rating'] < 7 )
	{
		$c = mysql_result(query("SELECT COUNT(*) FROM `user_set` WHERE `id_user` = '$user[id]' AND `ocenka` > '$time'"), 0);
		
		if ($c == 0 && $_GET['rating'] == 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;
	}
}


if (isset($_GET['act']) && $_GET['act'] == 'ava_no'){
if ($user['id']==$ank['id']){
mysql_query("UPDATE `gallery_foto` SET `avatar` = '0' WHERE `id_user` = '$user[id]'");
$_SESSION['message'] = 'Фотография успешно удалена с Аватара..';
}
header("Location: ?");
exit;
}


/*
==========================
Комментарий
==========================
*/

if (isset($_POST['msg']) && isset($user))
{
	$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");
		}
		
// Выводим в комменты ник отвечающему езеру :: Tw1nGo	
if ($insert != NULL)$insertq='[blue][b]'.$insert.'[/b][/blue]';	
query("INSERT INTO `gallery_komm` (`id_foto`, `id_user`, `time`, `msg`) values('$foto[id]', '$user[id]', '$time', '".$insertq." ".my_esc($msg)."')");
		$_SESSION['message'] = 'Сообщение успешно добавлено..';
		header("Location: ?page=".intval($_GET['page']));
		exit;
	}
}


if ((user_access('foto_komm_del') || $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($gallery['name']) . ' - ' . text($foto['name']); // заголовок страницы
include_once '../sys/inc/thead.php';
title();
err();
aut();

?>
<link rel="stylesheet" href="/foto/Tw1nGo.css" type="text/css" />

<div class="lc_br wbg relative oh" id="header_path">  
<a href="/" style="font-size:0;" title="Главная"> <img src="/foto/img/home.png" alt="Tw1nGo"> </a>     
<span class="lc_brw"> <img src="/foto/img/sep.png" alt="Tw1nGo" class="lc_br_sep"> 
<a href="/info.php?id=<?= $ank['id']?>"><?= text($ank['nick'])?></a> </span>     
<span class="lc_brw"> <img src="/foto/img/sep.png" alt="Tw1nGo" class="lc_br_sep"> 
<a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><?= text($gallery['name'])?></a> </span>  
<span class="lc_brw"> <img src="/foto/img/sep.png" alt="Tw1nGo" class="lc_br_sep">
<a style="color: #000;"><?= text($foto['name'])?>  
<?
if ($foto['metka'] == 1){
?><img src="/foto/img/adult_ico.png" alt="Tw1nGo" style="float:right;" title="Доступно только +18"><?
}
?>
</a></span>
</div>
<?


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

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

	$block_foto = true;
}
elseif ($gallery['privat'] == 2 && $user['id'] != $ank['id'] && $user['level'] <= $ank['level'])
{
	echo '<div class="mess">';
	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'])
	{
		echo '<form action="?" method="POST">Пароль:<br /><input type="pass" name="password" value="" /><br />		
		<input type="submit" value="Войти"/></form>';
		
		echo '<div class="foot">';
		echo '<img src="/style/icons/str2.gif" alt="*"> ' . user::nick($ank['id']) . ' | <a href="/foto/' . $ank['id'] . '/">Альбомы</a> | <b>' . text($gallery['name']) . '</b>';
		echo '</div>';

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

if (user_access('foto_foto_edit') && $ank['level'] < $user['level'] || isset($user) && $ank['id'] == $user['id']){
include 'inc/gallery_show_foto_form.php';
}	


$avatarka = mysql_fetch_array(mysql_query("SELECT id,id_gallery,ras FROM `gallery_foto` WHERE `id_user` = '$ank[id]' AND `id` = '$foto[id]' AND `avatar` = '1' LIMIT 1"));
if (!isset($block_foto))
{
	// +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'])) // Метка 18+ 
	{
?>
<div class="tw1ngo_bg">
<div class="widgets-group widgets-group_top-mrg"><div class="block" style="text-align: center;">
<?
if ($webbrowser == 'web' && $w > 128)
{
echo "<a href='/foto/foto0/$foto[id].$foto[ras]' title='Скачать оригинал'><img style='max-width: 100%;max-height: 350px;' src='/foto/foto640/$foto[id].$foto[ras]'/></a>";
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>";
}else{
echo "<a href='/foto/foto0/$foto[id].$foto[ras]' title='Скачать оригинал'><img style='max-width: 100%;max-height: 250px;' src='/foto/foto128/$foto[id].$foto[ras]'/></a>";
if ( $rat > 0 )echo "<div style='display:inline;margin-left:-25px;vertical-align:top;'><img style='padding-top:10px;' src='/style/icons/6.png'/></div>";
}

		// Оценка фото
		if (isset($user) && $user['id'] != $ank['id'])
		{
			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)
			{
				echo "<br /><a href=\"?rating=6\" title=\"5+\"><img src='/style/icons/6.png' alt=''/></a>";
				echo "<a href=\"?rating=5\" title=\"5\"><img src='/style/icons/5.png' alt=''/></a>";
				echo "<a href=\"?rating=4\" title=\"4\"><img src='/style/icons/4.png' alt=''/></a>";
				echo "<a href=\"?rating=3\" title=\"3\"><img src='/style/icons/3.png' alt=''/></a>";
				echo "<a href=\"?rating=2\" title=\"2\"><img src='/style/icons/2.png' alt=''/></a>";
				echo "<a href=\"?rating=1\" title=\"1\"><img src='/style/icons/1.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 '<br />Ваша оценка <img src="/style/icons/' . $rate['like'] . '.png" alt=""/></a>';
			}
		}

echo '</div>';	
if ($foto['opis'] != null){
?>
<div class="block"><span style="padding-left:15px;"><?= output_text($foto['opis'])?></span></div>
<?
}	

	}
	elseif (!isset($user))
	{
		echo '<div class="mess">';
		echo '<img src="/style/icons/small_adult.gif" alt="*"><br /> Данный файл содержит изображения эротического характера. Только зарегистрированные пользователи старше 18 лет могут просматривать такие файлы. <br />';
		echo '<a href="/aut.php">Вход</a> | <a href="/reg.php">Регистрация</a>';
		echo '</div>';
	}
	else
	{
		echo '<div class="mess">';
		echo '<img src="/style/icons/small_adult.gif" alt="*"><br /> 
		Данный файл содержит изображения эротического характера. 
		Если Вас это не смущает и Вам 18 или более лет, то можете <a href="?sess_abuld=1">продолжить просмотр</a>. 
		Или Вы можете отключить предупреждения в <a href="/user/info/settings.php">настройках</a>.';
		echo '</div>';
	}
?></div><?

// --> Листинг ::  Tw1nGo
$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);
$Tw1nGo_zakladki = mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0);
?>
<div>
<div class="pgn">
<table class="table__wrap pgn__table">
<tr>
<?
if ($list['id'] > 0){ 
?>
<td class="table__cell" width="35%" style="border:0;">
<a class="pgn__link pgn__link_hover pgn__link_next" href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/<?= $list['id']?>/"> Предыдущая</a>
</td>
<?
}else{
?>
<td class="table__cell" width="35%" style="border:0;">
<div class="pgn__link pgn__link_prev pgn__link_disabled"> Предыдущая </div></td>
<?
}
?>
<td class="table__cell bez_kuya" style=""><div class="pgn__counter pgn__range">
<?= $k_1?> из <?= $k_2?>
</div></td>
<?
if ($listr['id'] != 0){ 
?>
<td class="table__cell table__cell_last" width="35%" style="border:0;">
<a class="pgn__link pgn__link_hover pgn__link_next" href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/<?= $listr['id']?>/">Следующая</a>
</td>
<?
}else{
?>
<td class="table__cell table__cell_last" width="35%" style="border:0;">
<div class="pgn__link pgn__link_prev pgn__link_disabled">Следующая </div>
</td>
<?
}
?></tr></table>
</div></div>
<?


if (($user['abuld'] == 1 || $foto['metka'] == 0 || $foto['id_user'] == $user['id'])){
?>
<div class="widgets-group">
<div class="mail__msg_w_chb content-bl content-bl__sep contact_item list-link_diz o_vis js-mail_body mail__old_msg" style="">
Фото добавлено: <?=group($ank['id'])?> <a href="/info.php?id=<?= $ank['id']?>"><?= text($ank['nick'])?></a> <?=online($ank['id'])?>
<span class="mail__service mail__date m"><?= vremja($foto['time'])?></span>
<br />
В фотоальбом: <img class="middle" src="/foto/img/folder.gif"> 
<a href="/foto/<?= $ank['id']?>/<?= $gallery['id']?>/"><?=text($gallery['name'])?></a>
</div>
<a class="Tw1nGo-str__link list-link-darkblue" href="/foto/foto0/<?= $foto['id']?>.<?= $foto['ras']?>" title="Скачать оригинал">
<img src="/foto/img/dload.gif" alt="Tw1nGo" class="lc_br_sep"> 
<span class="cvet_bukv">Скачать (<?= $w?>x<?= $h?>, <?= size_file(filesize(H.'sys/gallery/foto/'.$foto['id'].'.jpg'))?>)</span>
</a>
<?
if (isset($user)){
if (mysql_result(query("SELECT COUNT(*) FROM `mark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"),0) == 0){
?>
<a class="Tw1nGo-str__link list-link-darkblue" href="?fav=1&amp;page=<?=  $pageEnd?>">
<img src="/foto/img/action_fav_gray.gif" alt="Tw1nGo" class="lc_br_sep"/> <span class="cvet_bukv">Добавить в закладки</span>  
<span class="cnt" id="right"><?= $Tw1nGo_zakladki?></span></a>
<?
}else{
?>
<a class="Tw1nGo-str__link list-link-darkblue" href="?fav=0&amp;page=<?=  $pageEnd?>">
<img src="/foto/img/action_fav_gray.gif" alt="Tw1nGo" class="lc_br_sep"/> <span class="cvet_bukv">Удалить из закладок</span>  
<span class="cnt" id="right"><?= $Tw1nGo_zakladki?></span></a>
<?
}
}
$Tw1nGo_avatarka = mysql_fetch_array(mysql_query("SELECT id,id_gallery,ras FROM `gallery_foto` WHERE `id_user` = '$ank[id]' AND `id` = '$foto[id]' AND `avatar` = '1' LIMIT 1"));
if (isset($user) && $user['id'] == $ank['id']){ 
if ($Tw1nGo_avatarka <= 1 ){
?>
<a href="?act=avatar" class="Tw1nGo-str__link list-link-darkblue" title="Поставить на Аватар">
<img src="/foto/img/foto.png" alt="Tw1nGo" class="lc_br_sep"> <span class="cvet_bukv">Поставить на аватар </span></a>
<?
}else{
?>
<a href="?act=ava_no" class="Tw1nGo-str__link list-link-darkblue" title="Убрать с Аватара">
<img src="/foto/img/piu.png" alt="Tw1nGo" class="lc_br_sep"> <span class="cvet_bukv">Убрать с аватара </span></a>
<?
}
}
?></div> <?
if (user_access('foto_foto_edit') && $ank['level'] < $user['level'] || isset($user) && $ank['id'] == $user['id']){
?>
<div class="btn-single__wrap" style="margin: 10px 0;"><div class="btn-single__table-wrap dropdown-menu_top"><div class="user__tools  tl bb0 bt0" > 
<table class="table__wrap34"> <tbody><tr>  
<td class="table__cell345 tc" width="50%">  
<a class="list-link-blue    btn-single hover-item korob" style=" margin-right: 10px;" href="?act=rename">              
<img src="/foto/img/k_edit.png" alt="Tw1nGo" class="lc_br_sep">      <span class="t list-link-blue">Редактировать</span></a> </td>  
<td class="table__cell345 tc" width="50%">  
<a class="list-link-blue    btn-single hover-item korob" href="?act=delete">             
<img src="/foto/img/garbage.png" alt="Tw1nGo" class="lc_br_sep">     <span class="t list-link-blue">Удалить</span></a> </td>  
</tr> </tbody></table> 
</div></div></div> 
<?
}
}


$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'];
?>
<div class="sub-title sub-title_main text_left oh"> 
<b>Комментарии</b> <span class="cnt cnt_title cnt_title_comm js-comments_cnt"><?= $k_post?></span>
</div>
<?
if (isset($user)){
?>
<div class="widgets-group">
<form class="js-attaches_form js-attach_dnd" action="?page=<?= $pageEnd?>&amp;<?= REPLY?>" method="post" name="message">
<div class="comm pd0 comm_indent shdw ovis"> 
<div class="stnd-block mail__form-item suggest_parent js-toolbar_wrap js-input_error_wrap  js-comment_form" > <div class="cl"> 
<textarea name="msg" data-maxlength="1000" class="text-inputka placeholder js-resize_ta form_submit" style="font-size:13px;z-index: inherit;" placeholder="Напишите комментарий.."></textarea>
</div>  <br />
<div> 
<?
if ($insert != NULL){   
$br = ''; 		
?>
<span class="post_btn"> Ответ для <span class="post-author"><?= $insert?></span>
<a href="?"><img src="/foto/img/ss.png" alt="Tw1nGo" width="14" class="lc_br_sep"></a></span>
<?
}else{
$br = '<div style="padding:20px 0;"></div>'; 
}
?>
<input value="Отправить" class="btn right" type="submit">  </div> </div>  <?= $br?> </div>
</form></div>
<?
}

if ($k_post == 0){
?>
<div class="widgets-group"><div class="busi"> Фотографию еще не обсуждали...</div></div>
<?
}else{
if (isset($user)){
?>
<div class="sub-title sub-title_main text_left oh">  Новые: 
<a href="?page=<?= $page?>&amp;sort=1"><span class="<?= ($user['sort'] == 1 ? 'comm_new' : null)?>">Внизу</span></a> | 
<a href="?page=<?= $page?>&amp;sort=0"><span class="<?= ($user['sort'] == 0 ? 'comm_new' : null)?>">Вверху</span></a>
</div>
<?
}
}




$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)){
$ank2 = mysql_fetch_assoc(query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
$avatar = mysql_fetch_array(mysql_query("SELECT id,id_gallery,ras FROM `gallery_foto` WHERE `id_user` = '$ank2[id]' AND `avatar` = '1' LIMIT 1"));

?>
<div class="cont_usr">
<a href="/info.php?id=<?= $ank2['id']?>" class="lafac-news_link">
<div class="content-item3" style="margin-bottom:2px; padding:7px;"> 
<div class="user__ava user__ava_big"> 
<div class="change_avatar_link js-my_avatar">
<img class="preview s41_40" style="border-radius: 5px;padding:0 1px;" src="/foto/img.php?size=50&id=<?= $avatar['id']?>.<?= $avatar['ras']?>">

</div></div>
<div class="user__info" style="padding-left: 10px;">
<span class="comment_date"><?= vremja($post['time'])?></span>
<span class="status_ico"><?= group($ank2['id'])?></span> <span class="post-author"><?= text($ank2['nick']) . online($ank2['id'])?></span>
<div class="mail__service mail__date m">
<?
$postBan = mysql_result(query("SELECT COUNT(*) FROM `ban` WHERE (`razdel` = 'all' OR `razdel` = 'foto') AND `post` = '1' AND `id_user` = '$ank2[id]' AND (`time` > '$time' OR `navsegda` = '1')"), 0);	
// Блок сообщения
if ($postBan == 0) {echo output_text($post['msg']); }else{ echo output_text($banMess) . '';}   
?>
</div></div></div>
</a>
<div class="user__tools user__tools_last"> 
<table class="table__wrap23 horiz_menu"> <tbody><tr>
<?
if (isset($user) && $user['id'] != $ank2['id']){
?>
<td class="table__cell" width="50%" style="border-left: 0;margin:0px;">
<a class="user__tools-link mail__button" href="?response=<?= $ank2['id']?>&amp;page=<?= $page?>" title="Ответить на комментарий">
<img src="/foto/img/comm_ico.png" alt="Tw1nGo"></a>
</td>
<?
}
if ($ank2['id'] == $user['id']){ $rtrt= 'border-right: 0;border-left: 0;'; }else{$rtrt= 'border-right: 0;';}
if (isset($user)){
if (user_access('foto_komm_del') || $ank['id'] == $user['id']){
?>
<td class="table__cell" width="50%" style="<?= $rtrt?> margin:0px;">
<a class="user__tools-link mail__button" rel="delete" href="?delete=<?= $post['id']?>&amp;page=<?= $page?>" title="Удалить комментарий">
<img src="/foto/img/garbage.png" alt="Tw1nGo"></a></td>
<?
}}
?>
</tr>
</table></div></div>
<?



/*
		// Лесенка
		echo '<div class="' . ($num % 2 ? "nav1" : "nav2") . '">';
		$num++;
		
		echo group($ank2['id']) . user::nick($ank2['id']);
		
		if (isset($user) && $user['id'] != $ank2['id'])
		echo ' <a href="">[*]</a> ';
		
		echo medal($ank2['id']) . online($ank2['id']) . ' (' . vremja($post['time']) . ')<br />';
		
		$postBan = mysql_result(query("SELECT COUNT(*) FROM `ban` WHERE (`razdel` = 'all' OR `razdel` = 'foto') AND `post` = '1' AND `id_user` = '$ank2[id]' AND (`time` > '$time' OR `navsegda` = '1')"), 0);
		
		// Блок сообщения
		if ($postBan == 0) 
		{
			echo output_text($post['msg']);
		}
		else
		{
			echo output_text($banMess) . '<br />';
		}

		if (isset($user))
		{
			echo '<div class="right">';
			if (user_access('foto_komm_del') || $ank['id'] == $user['id']) 
			echo '<a rel="delete" href="?delete=' . $post['id'] . '&amp;page=' . $page . '" title="Удалить комментарий"><img src="/style/icons/delete.gif" alt="*"></a>';
			echo '</div>';
		}
		echo '</div>';
		*/
	}

?>
</div>
<?

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

}


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