<?

/*===========================
##        Автор скрипта Искатель           ##
##     Автор  модификатор Dcms Blog   ##
##                      Dark_AKC                 ##
===========================*/

include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';

/* Бан пользователя */ 
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0')"), 0)!=0)
{
header('Location: /ban.php?'.SID);exit;
}

$notes = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id` = '". intval($_GET['id']) ."' LIMIT 1"));

if (!isset($notes['id'])){
	header('Location: index.php');
	exit;
}

$avtor=get_user($notes['id_user']);
if (isset($user))
$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_count` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0);
 // Закладки
$markinfo=mysql_result(mysql_query("SELECT COUNT(*) FROM `mark_notes` WHERE `id_list` = '".$notes['id']."'"),0);

if (isset($user))
mysql_query("UPDATE `notification` SET `read` = '1' WHERE `type` = 'notes_komm' AND `id_user` = '$user[id]' AND `id_object` = '$notes[id]'");/*
================================
Модуль жалобы на пользователя
и его сообщение либо контент
в зависимости от раздела
================================
*/
if (isset($_GET['spam'])  &&  isset($user))
{
$mess = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog_komm` WHERE `id` = '".intval($_GET['spam'])."' limit 1"));
$spamer = get_user($mess['id_user']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `spamus` WHERE `id_user` = '$user[id]' AND `id_spam` = '$spamer[id]' AND `razdel` = 'notes_komm' AND `spam` = '".$mess['msg']."'"),0)==0)
{
if (isset($_POST['msg']))
{
if ($mess['id_user']!=$user['id'])
{
$msg=mysql_real_escape_string($_POST['msg']);

if (strlen2($msg)<3)$err='Укажите подробнее причину жалобы';
if (strlen2($msg)>512)$err='Длина текста превышает предел в 512 символов';

if(isset($_POST['types'])) $types=intval($_POST['types']);
else $types='0'; 
if (!isset($err))
{
mysql_query("INSERT INTO `spamus` (`id_object`, `id_user`, `msg`, `id_spam`, `time`, `types`, `razdel`, `spam`) values('$notes[id]', '$user[id]', '$msg', '$spamer[id]', '$time', '$types', 'notes_komm', '".my_esc($mess['msg'])."')");
$_SESSION['message'] = 'Заявка на рассмотрение отправлена'; 
header("Location: ?id=$notes[id]&page=".intval($_GET['page'])."&spam=$mess[id]");
exit;
}
}
}
}
$set['title']='Блог' . htmlspecialchars($notes['name']) . '';

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

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `spamus` WHERE `id_user` = '$user[id]' AND `id_spam` = '$spamer[id]' AND `razdel` = 'notes_komm'"),0)==0)
{
echo "<div class='mess'>Ложная информация может привести к блокировке ника. 
Если вас постоянно достает один человек - пишет всякие гадости, вы можете добавить его в черный список.</div>";
echo "<form class='nav1' method='post' action='?id=$notes[id]&amp;page=".intval($_GET['page'])."&amp;spam=$mess[id]'>\n";
echo "<b>Пользователь:</b> ";
echo " ".status($spamer['id'])."  ".group($spamer['id'])." <a href=\"/id$spamer[id]\">$spamer[nick]</a>\n";
echo "".medal($spamer['id'])." ".online($spamer['id'])." (".vremja($mess['time']).")<br />";
echo "<b>Нарушение:</b> <font color='green'>".output_text($mess['msg'])."</font><br />";
echo "Причина:<br />\n<select name='types'>\n";
echo "<option value='1' selected='selected'>Спам/Реклама</option>\n";
echo "<option value='2' selected='selected'>Мошенничество</option>\n";
echo "<option value='3' selected='selected'>Оскорбление</option>\n";
echo "<option value='0' selected='selected'>Другое</option>\n";
echo "</select><br />\n";
echo "Комментарий:$tPanel";
echo "<textarea name=\"msg\"></textarea><br />";
echo "<input value=\"Отправить\" type=\"submit\" />\n";
echo "</form>\n";
}else{
echo "<div class='mess'>Жалоба на <font color='green'>$spamer[nick]</font> будет рассмотрена в ближайшее время.</div>";
}

echo "<div class='foot'>\n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='?id=$notes[id]&amp;page=".intval($_GET['page'])."'>Назад</a><br />\n";
echo "</div>\n";
include_once '../../sys/inc/tfoot.php';
exit;
}
/*
==================================
The End
==================================
*/ // Запись просмотра
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_count` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `blog_count` (`id_notes`, `id_user`) VALUES ('$notes[id]', '$user[id]')");
mysql_query("UPDATE `blog` SET `count` = '".($notes['count']+1)."' WHERE `id` = '$notes[id]' LIMIT 1");
}

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

$set['title']='Блог- ' . htmlspecialchars($notes['name']) . '';
$set['meta_description'] = htmlspecialchars($notes['msg']);

include_once '../../sys/inc/thead.php';
if (isset($_POST['msg']) && isset($user))
{
$msg=$_POST['msg'];

if (strlen2($msg)>1024){$err='Сообщение слишком длинное';}

elseif (strlen2($msg)<2){$err='Короткое сообщение';}

elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_notes` = '".intval($_GET['id'])."' AND `id_user` = '$user[id]' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}

elseif(!isset($err)){

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

/*
====================================
Обсуждения
====================================
*/
$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '".$notes['id_user']."' AND `i` = '1'");
while ($f = mysql_fetch_array($q))
{
$a=get_user($f['frend']);
$discSet = mysql_fetch_array(mysql_query("SELECT * FROM `discussions_set` WHERE `id_user` = '".$a['id']."' LIMIT 1")); // Общая настройка обсуждений

if ($f['disc_notes']==1 && $discSet['disc_notes']==1) /* Фильтр рассылки */
{
//---------друзьям автора--------------//
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$a[id]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1"),0)==0)
{
if ($notes['id_user'] != $a['id']  || $a['id'] != $user['id'])
mysql_query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$a[id]', '$notes[id_user]', 'notes', '$time', '$notes[id]', '1')"); 
}
else
{
$disc = mysql_fetch_array(mysql_query("SELECT * FROM `discussions` WHERE `id_user` = '$a[id]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1"));
if ($notes['id_user'] != $a['id'] || $a['id'] != $user['id'])
mysql_query("UPDATE `discussions` SET `count` = '".($disc['count']+1)."', `time` = '$time' WHERE `id_user` = '$a[id]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1");
}
//-------------------------------------//
}
}

//-------------отправляем автору------------//
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$notes[id_user]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1"),0)==0)
{
if ($notes['id_user'] != $user['id'])
mysql_query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$notes[id_user]', '$notes[id_user]', 'notes', '$time', '$notes[id]', '1')"); 
}
else
{
$disc = mysql_fetch_array(mysql_query("SELECT * FROM `discussions` WHERE `id_user` = '$notes[id_user]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1"));
if ($notes['id_user'] != $user['id'])
mysql_query("UPDATE `discussions` SET `count` = '".($disc['count']+1)."', `time` = '$time' WHERE `id_user` = '$notes[id_user]' AND `type` = 'notes' AND `id_sim` = '$notes[id]' LIMIT 1");
}
mysql_query("INSERT INTO `blog_komm` (`id_user`, `time`, `msg`, `id_notes`) values('$user[id]', '$time', '".my_esc($msg)."', '".intval($_GET['id'])."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['message'] = 'Сообщение успешно отправлено';
header("Location: list.php?id=$notes[id]&page=".intval($_GET['page'])."");
exit;
}
}

if (isset($user))
$frend=mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$user[id]' AND `frend` = '$avtor[id]') OR (`user` = '$avtor[id]' AND `frend` = '$user[id]') LIMIT 1"),0);title();
aut(); // форма авторизации
err();
if ($notes['private']==1 && $user['id']!=$avtor['id'] && $frend!=2  && !user_access('notes_delete')){
msg('Блог доступен только для друзей');
echo "  <div class='foot'>\n";
echo "<a href='index.php'>Назад</a><br />\n";
echo "   </div>\n";
include_once '../../sys/inc/tfoot.php';
exit;
}
if ($notes['private']==2 && $user['id']!=$avtor['id']  && !user_access('notes_delete')){
msg('Пользователь запретил просмотр блога');
echo "  <div class='foot'>\n";
echo "<a href='index.php'>Назад</a><br />\n";
echo "   </div>\n";
include_once '../../sys/inc/tfoot.php';
exit;
}
if (isset($_GET['delete']) && ($user['id']==$avtor['id'] || user_access('notes_delete'))){

echo "Вы действительно хотите удалить блог " . output_text($notes['name']) . "?<br />";
echo "[<a href='delete.php?id=$notes[id]'><img src='/style/icons/ok.gif'> удалить</a>] [<a href='list.php?id=$notes[id]'><img src='/style/icons/delete.gif'> отмена</a>] \n";

include_once '../../sys/inc/tfoot.php';
}
//////////////  Модерация ///////////////////////////
if (isset($_GET['mod']) && user_access('notes_delete')){
if ($_GET['mod'] == 'da' && user_access('notes_delete')){
mysql_query("UPDATE `blog` SET `mod` = '1' WHERE `id` = '".$notes['id']."' LIMIT 1");
header("Location: list.php?id=$notes[id]");

if($user['id']==$avtor['id'])$mod = $user['id'];
$blog_mod = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id_user` = '".$user['id']."' ORDER BY `id` DESC LIMIT 1"));
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$mod."', 'Ваша  [url=http://".$_SERVER['HTTP_HOST']."/plugins/blog/list.php?id=".$blog_mod['id']."]статья[/url] успешно прошла модерацию.', '$time')");
}

echo "<div class='mess'>Перед тем как пропустить публикацию статьи, вы должны прочитать ее и проверить на соответствие правилам сайта. <br>Пропустить статью?<br>";
echo "[<a href='?id=$notes[id]&amp;mod=da'><img src='/style/icons/ok.gif'> Да</a>] [<a href='list.php?id=$notes[id]'><img src='/style/icons/delete.gif'> Нет</a>] </div>\n";
include_once '../../sys/inc/tfoot.php';
}


/////////////////////  Блок ///////////////////////////
if (isset($_GET['block']) && user_access('notes_delete')){
if ($_GET['block'] == 'da' && user_access('notes_delete')){
mysql_query("UPDATE `blog` SET `block` = '1' WHERE `id` = '".$notes['id']."' LIMIT 1");
header("Location: list.php?id=$notes[id]");

if($user['id']==$avtor['id'])$block= $user['id'];
$blog_block = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id_user` = '".$user['id']."'"));
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$block."', 'Ваша статья [b]".$blog_block['name']."[/b] заблокирована модератором.', '$time')");
}

echo "<div class='mess'>Вы можете заблокировать статью за нарушение правил сайта. Она будет видна только модераторам. Заблокировать?<br>";
echo "[<a href='?id=$notes[id]&amp;block=da'><img src='/style/icons/ok.gif'> Да</a>] [<a href='list.php?id=$notes[id]'><img src='/style/icons/delete.gif'> Нет</a>] </div>\n";
include_once '../../sys/inc/tfoot.php';
}


/////////////////////  Разблок ///////////////////////////
if (isset($_GET['unblock']) && user_access('notes_delete')){
if ($_GET['unblock'] == 'da' && user_access('notes_delete')){
mysql_query("UPDATE `blog` SET `block` = '0' WHERE `id` = '".$notes['id']."' LIMIT 1");
header("Location: list.php?id=$notes[id]");

if($user['id']==$avtor['id'])$block= $user['id'];
$blog_block = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id_user` = '".$user['id']."'"));
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$block."', 'Ваша статья [b]".$blog_block['name']."[/b] разблокирована модератором.', '$time')");
}

echo "<div class='mess'>Вы уверены что хотите разблокировать данную статью? Она станет доступной для всех.<br>";
echo "[<a href='?id=$notes[id]&amp;unblock=da'><img src='/style/icons/ok.gif'> Да</a>] [<a href='list.php?id=$notes[id]'><img src='/style/icons/delete.gif'> Нет</a>] </div>\n";
include_once '../../sys/inc/tfoot.php';
}
/////////////////////////////////////////////////////////

if (isset($user))
{
//------------------------like-----------------//
if (isset($_GET['like']) && $_GET['like'] == 1){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `blog_like` (`id_notes`, `id_user`, `like`) VALUES ('$notes[id]', '$user[id]', '1')");
mysql_query("UPDATE `blog` SET `count` = '".($notes['count']+1)."' WHERE `id` = '$notes[id]' LIMIT 1");
$_SESSION['message'] = 'Ваш голос засчитан';
header("Location: list.php?id=$notes[id]&page=".intval($_GET['page'])."");
exit;
}
}
//-----------------------------------------------//


//------------------------dlike-----------------//
if (isset($_GET['like']) && $_GET['like'] == 0){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `blog_like` (`id_notes`, `id_user`, `like`) VALUES ('$notes[id]', '$user[id]', '0')");
mysql_query("UPDATE `blog` SET `count` = '".($notes['count']-1)."' WHERE `id` = '$notes[id]' LIMIT 1");
$_SESSION['message'] = 'Ваш голос засчитан';
header("Location: list.php?id=$notes[id]&page=".intval($_GET['page'])."");
exit;
}
}
//-----------------------------------------------//
//-----------------------добавляем в закладки------------//
if (isset($_GET['fav']) && $_GET['fav']==1){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mark_notes` WHERE `id_user` = '".$user['id']."' AND `id_list` = '".$notes['id']."' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `mark_notes` (`id_list`, `id_user`, `time`) VALUES ('$notes[id]', '$user[id]', '$time')");
$_SESSION['message'] = 'Блог добавлен в закладки';
header("Location: list.php?id=$notes[id]&page=".intval($_GET['page'])."");
exit;
}
}
//-------------------------------------------------------//

//-----------------------удаляем из закладок------------//
if (isset($_GET['fav']) && $_GET['fav']==0){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mark_notes` WHERE `id_user` = '".$user['id']."' AND `id_list` = '".$notes['id']."' LIMIT 1"),0)==1){
mysql_query("DELETE FROM `mark_notes` WHERE `id_user` = '$user[id]' AND  `id_list` = '$notes[id]' ");
$_SESSION['message'] = 'Блогудален из закладок';
header("Location: list.php?id=$notes[id]&page=".intval($_GET['page'])."");
exit;
}
}
//-------------------------------------------------------//
}

echo "<div class=\"foot\">\n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='index.php'>Блоги</a>";
echo "</div>\n";

$dir = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog_dir` WHERE `id` = '".$notes['id_dir']."' "));


if($notes['block'] == '1'){ echo '<div class="err">Статья заблокирована за нарушение правил</div>';
if(isset($user) && $user['level'] > '1'){
echo "<div class=\"mess\"><center><b><font size='3'>" . output_text($notes['name']) . "</font></b><br>\n";
if($notes['mod'] == 0)echo '(<font color=red>Модерация не пройдена</font>)';
echo '<br></center>';
echo status($avtor['id']).group($avtor['id'])."<a href='/id$avtor[id]'>".$avtor['nick']."</a> ".online($avtor['id']);
echo medal($avtor['id'])." (".vremja($notes['time']).")<br>\n";
echo 'Раздел:<a href="/plugins/blog/dir.php?id='.$notes['id_dir'].'"> '.$dir['name'].'</a>';
echo "</div>\n";

echo '<div class="mess">' . output_text($notes['msg']) , '</div>'; // вывод статьи со всем форматированием
if($notes['istochnik'] != NULL)echo '<div class="mess">Источник:<br> <b>'.htmlspecialchars($notes['istochnik']).'</b></div>';
}
}else{

echo "<div class=\"mess\"><center><b><font size='3'>" . output_text($notes['name']) . "</font></b><br>\n";
if($notes['mod'] == 0)echo '(<font color=red>Модерация не пройдена</font>)';
echo '<br></center>';
echo status($avtor['id']).group($avtor['id'])."<a href='/id$avtor[id]'>".$avtor['nick']."</a> ".online($avtor['id']);
echo medal($avtor['id'])." (".vremja($notes['time']).")<br>\n";

echo 'Раздел:<a href="/plugins/blog/dir.php?id='.$notes['id_dir'].'"> '.$dir['name'].'</a>';
echo "</div>\n";

echo '<div class="mess">' . output_text($notes['msg']) , '</div>'; // вывод статьи со всем форматированием
if($notes['istochnik'] != NULL)echo '<div class="mess">Источник:<br> <b>'.htmlspecialchars($notes['istochnik']).'</b></div>';
}



/*----------------------листинг-------------------*/

$listr = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id` < '$notes[id]' ORDER BY `id` DESC LIMIT 1"));
$list = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog` WHERE `id` > '$notes[id]' ORDER BY `id`  ASC LIMIT 1"));
echo '<div class="c2" style="text-align: center;">';
echo '<span class="page">'.($list['id']?'<a href="list.php?id='.$list['id'].'">&laquo; Пред.</a> ':'&laquo; Пред. ').'</span>';

$k_1=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog` WHERE `id` > '$notes[id]'"),0)+1;
$k_2=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog`"),0);
echo ' ('.$k_1.' из '.$k_2.') ';

echo '<span class="page">' . ($listr['id'] ? '<a href="list.php?id=' . $listr['id'] . '">След. &raquo;</a>' : ' След. &raquo;') . '</span>';
echo '</div>';

/*----------------------alex-borisi---------------*/
if (isset($user) && (user_access('notes_delete') || $user['id']==$avtor['id'])){
echo "<div class='blog_msg'>";
echo "Инструменты: ";
echo " [<a href='edit.php?id=$notes[id]'><img src='/style/icons/edit.gif'> ред</a>] [<a href='?id=$notes[id]&amp;delete'><img src='/style/icons/delete.gif'> удл</a>] \n";
if (isset($user) && user_access('notes_delete') && $notes['mod'] == '0')echo " [<a href='?id=$notes[id]&amp;mod'><img src='/style/icons/delete.gif'> мод</a>]";
if (isset($user) && user_access('notes_delete') && $notes['block']=='0') echo "[<a href='?id=$notes[id]&amp;block'><img src='/style/icons/delete.gif'> блок</a>]";
if (isset($user) && user_access('notes_delete') && $notes['block']=='1') echo "[<a href='?id=$notes[id]&amp;unblock'><img src='/style/icons/delete.gif'> разблок</a>]";

echo "</div>";
}
echo "<div class='blog_msg'>";
echo "Просмотры: $notes[count] <br>";
if (isset($user) && $user['id']!=$avtor['id']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)==0)
echo "[<img src='/style/icons/like.gif' alt='*' /> <a href='list.php?id=$notes[id]&amp;like=1'>Нравится</a>] [<a href='list.php?id=$notes[id]&amp;like=0'><img src='/style/icons/dlike.gif' alt='*' /></a>]<br />\n";
else
echo "[<img src='/style/icons/like.gif' alt='*' /> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `like` = '1' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)."] [<img src='/style/icons/dlike.gif' alt='*' /> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `like` = '0' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)."]\n";
}else{
echo "[<img src='/style/icons/like.gif' alt='*' /> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `like` = '1' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)."] [<img src='/style/icons/dlike.gif' alt='*' /> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `like` = '0' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)."]\n";

}
echo '<br>';
//--------------------------В закладки-----------------------------//
if (isset($user)){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mark_notes` WHERE `id_user` = '".$user['id']."' AND `id_list` = '".$notes['id']."' LIMIT 1"),0)==0)
echo "<a href='list.php?id=$notes[id]&amp;fav=1'>Добавить в закладки</a> (<a href='list.php?id=$notes[id]&amp;markinfo'>$markinfo</a>)\n";
else
echo "<a href='list.php?id=$notes[id]&amp;fav=0'>Удалить из закладок</a> (<a href='list.php?id=$notes[id]&amp;markinfo'>$markinfo</a>)";

}
//-------------------------------------------------------------//

echo '<br>';
echo 'Поделится:<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
<span class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="none" data-yashareQuickServices="vkontakte,twitter,odnoklassniki,moimir"></span>';
echo "</div>";/*
===================================
Комментарии блогов
===================================
*/
if($notes['block'] =='1'){
echo '<div class="mess">Комментарии недоступны</div>';
}else{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_notes` = '".intval($_GET['id'])."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo '<div class="foot">';
echo "Комментарии\n";
echo '</div>';

if ($k_post==0)
{
echo '<div class="mess">';
echo "Нет сообщений\n";
echo '</div>';
}else if (isset($user)){
/*------------сортировка по времени--------------*/
if (isset($user)){
echo "<div id='comments' class='menus'>";
echo "<div class='webmenu'>";
echo "<a href='list.php?id=$notes[id]&amp;page=$page&amp;sort=1' class='".($user['sort']==1?'activ':'')."'>Внизу</a>";
echo "</div>"; 
echo "<div class='webmenu'>";
echo "<a href='list.php?id=$notes[id]&amp;page=$page&amp;sort=0' class='".($user['sort']==0?'activ':'')."'>Вверху</a>";
echo "</div>"; 
echo "</div>";
}
/*---------------alex-borisi---------------------*/
}$q=mysql_query("SELECT * FROM `blog_komm` WHERE `id_notes` = '".intval($_GET['id'])."' ORDER BY `time` $sort LIMIT $start, $set[p_str]");
echo "<table class='post'>\n";
while ($post = mysql_fetch_assoc($q))
{
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));

/*-----------зебра-----------*/ 
	if ($num==0){
		echo '<div class="nav1">';
		$num=1;
	}
	elseif ($num==1){
		echo '<div class="nav2">';
		$num=0;
	}
/*---------------------------*/

echo group($ank['id'])." <a href='/id$ank[id]'>$ank[nick]</a> ";
if (isset($user) && $ank['id'] != $user['id'])echo "<a href='?id=$notes[id]&amp;response=$ank[id]'>[*]</a> \n";

echo "".medal($ank['id'])." ".online($ank['id'])." (".vremja($post['time']).")<br />";$postBan = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE (`razdel` = 'all' OR `razdel` = 'notes') AND `post` = '1' AND `id_user` = '$ank[id]' AND (`time` > '$time' OR `navsegda` = '1')"), 0);
if ($postBan == 0) // Блок сообщения
{	
echo output_text($post['msg'])."<br />\n";
}else{
	echo output_text($banMess).'<br />';
}

if (isset($user))
{
echo '<div style="text-align:right;">';

if ($ank['id']!=$user['id'])
echo "<a href=\"?id=$notes[id]&amp;page=$page&amp;spam=$post[id]\"><img src='/style/icons/blicon.gif' alt='*' title='Это спам'></a> "; 

	if (isset($user) && (user_access('notes_delete') || $user['id']==$notes['id_user']))
		echo '<a href="delete.php?komm='.$post['id'].'"><img src="/style/icons/delete.gif" alt="*"></a>';
	

echo "</div>\n";
}
echo "</div>\n";
}
echo "</table>\n";
if ($k_page>1)str("list.php?id=".intval($_GET['id']).'&amp;',$k_page,$page); // Вывод страниц



if ($notes['private_komm']==1 && $user['id']!=$avtor['id'] && $frend!=2  && !user_access('notes_delete')){
msg('Комментировать могут только друзья');
echo "  <div class='foot'>\n";
echo "<a href='index.php'>Назад</a><br />\n";
echo "   </div>\n";
include_once '../../sys/inc/tfoot.php';
exit;
}

if ($notes['private_komm']==2 && $user['id']!=$avtor['id'] && !user_access('notes_delete')){
msg('Пользователь запретил комментирование дневника');
echo "  <div class='foot'>\n";
echo "<a href='index.php'>Назад</a><br />\n";
echo "   </div>\n";
include_once '../../sys/inc/tfoot.php';
exit;
}

if (isset($user))
{
echo "<form method=\"post\" name='message' action=\"?id=".intval($_GET['id'])."&amp;page=$page".$go_otv."\">\n";
if (is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';

echo "<br><input value=\"Отправить\" type=\"submit\" />\n";
echo "</form>\n";
}
}
echo "<div class=\"foot\">\n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='index.php'>Блоги</a> | <a href='/id$avtor[id]'>$avtor[nick]</a>\n";
echo ' | <b>' . output_text($notes['name']) . '</b>';
echo "</div>\n";

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