<?php
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';

$set['title'] = 'Комментарии';
include_once '../../sys/inc/thead.php';

title();
aut();



if(!isset($user)){
echo '<div class="err">Доступ закрыт.</div>';
}else{
$lenta_komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta_komm` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);

echo "<div class=\"foot\"><a href='index.php'>Друзья (".$lenta.")</a> | <b>Комментарии (".$lenta_komm.")</b></div>";




echo '<table class="post">';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta_komm` WHERE `id_kont` = '".$user['id']."'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

if ($k_post==0)
{
	echo "   <tr>
	<td class='p_t'>
	Нет результатов
	</td>
	</tr>\n";
}
$num=0;
$q=mysql_query("SELECT * FROM `lenta_komm` WHERE `id_kont` = '".$user['id']."' ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q)){
//-----------зебра-----------//
if ($num==0)
{
if ($post['read']==0)
echo "  <div class='main_love'>\n";
else
echo "  <div class='nav1'>\n";
$num=1;
}elseif ($num==1)
{
if ($post['read']==0)
echo "  <div class='main_love'>\n";
else
echo "  <div class='nav2'>\n";
$num=0;}
//---------------------------//
if ($post['id_user']==0)
{
$ank['id']=0;
$ank['pol']='1';
$ank['nick']='Система';
$ank['ncolor']='blue';
$ank['ncolor2']='000000';
}
else
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]'"));


if ($set['set_show_icon']==2){
avatar($ank['id']);
}
elseif ($set['set_show_icon']==1)
{
echo "".status($ank['id'])."";
}


echo "<a href='/info.php?id=$ank[id]'>" . GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]") . "</a> ";
echo "".online($ank['id'])." (".vremja($post['time']).") ";
echo "<a href='del.php?del=$post[id]' title='Удалить'>[x]</a><br />";

echo ''.output_text($post['msg']).'';
echo "  </div>\n";
}
echo "</table>";

if($k_page>1){
	str("komm.php?id=".$user['id']."&amp;",$k_page,$page);
}
}
mysql_query("UPDATE `lenta_komm` SET `read` = '1' WHERE `id_kont` = '".$user['id']."' AND `read` = '0'");

echo "<div class='foot'>";
echo "<a href='del_komm.php?del_all=$user[id]'>Очистить ленту</a>";
echo "</div>";

mysql_query("OPTIMIZE TABLE `lenta`");
include_once '../../sys/inc/tfoot.php';
?>