<?
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))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
$ank=get_user($ank[id]);

$set[title]='Дневники Xhata.Su';

include_once '../sys/inc/thead.php';
title();
err();
echo "<div class='tmn'>";
echo "<img src='/style/icons/blogs.gif' alt='' class='icon'/> \n";
echo "<u>Все записи</u> <b>$ank[nick]</b>\n";
echo "</div>\n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev` WHERE `id_user` = '$ank[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
$lim=" LIMIT $start, $set[p_str]";
$q=mysql_query("SELECT * FROM `dnev` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC  $lim");
if (mysql_num_rows($q)==0) {
echo "У $ank[nick] нет записей\n";
}
while ($dnev = mysql_fetch_assoc($q))
{
echo "   <tr>\n";

if($num==1){
echo "  <td class='rer'>\n";
$num=0;
}else{
echo "  <td class='aut'>\n";
$num=1;}


if ($dnev[read]==0)	{
echo "<img src='/style/icons/blogi.png' alt='' class='icon'/>\n";
echo " <a href='dnev.php?id=$dnev[id]'>$dnev[name]</a> <img src='/style/icons/clock.png' alt='' class='icon'/> ".vremja($dnev[time])." (".mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev_kom` WHERE `id_dnev` = '$dnev[id]'"),0).")<br/>\n";
	}

if ($dnev[read]==1)	{
$frend=mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$user[id]' AND `frend` = '$dnev_avt[id]'"),0);
if ($ank[id]==$user[id] || $frend!=0 || $user[level]==10) {
echo "<img src='/style/icons/blogi.png' alt='' class='icon'/>\n";
echo "<a href='dnev.php?id=$dnev[id]'>$dnev[name]</a> <img src='/style/icons/clock.png' alt='' class='icon'/> ".vremja($dnev[time])." (".mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev_kom` WHERE `id_dnev` = '$dnev[id]'"),0).")<br/>\n";
	}
echo "<font color='red'><b>[Только друзьям]</b></font>";
	}

if ($dnev[read]==2)	{
if ($user[id]==$ank[id] || $user[level]==10) {
echo "<img src='/style/icons/blogi.png' alt='' class='icon'/>\n";
echo "<a href='dnev.php?id=$dnev[id]'>$dnev[name]</a> <img src='/style/icons/clock.png' alt='' class='icon'/> ".vremja($dnev[time])." (".mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev_kom` WHERE `id_dnev` = '$dnev[id]'"),0).")<br/>\n";
	}
echo "<font color='red'><b>[Личный]</b></font>";
	}

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev_kom` WHERE `id_dnev` = '$dnev[id]'"),0)!=0) {
$post=mysql_fetch_assoc(mysql_query("SELECT * FROM `dnev_kom` WHERE `id_dnev` = '$dnev[id]' ORDER BY `time` DESC LIMIT 1"));

$ank2=get_user($post['id_user']);


echo "Комментарий <a href='/info.php?id=$ank2[id]' title='Анкета \"$ank2[nick]\"'>$ank2[nick]</a> (".vremja($post['time']).")<br />\n";
	}

}
echo "</table>\n";

if ($k_page>1)str('?id='.$ank['id'].'&amp;',$k_page,$page); // Вывод страниц
if ($ank[id]==$user[id]) {
echo "<div class='foot'>";
echo "<a href='add.php'>Создать</a>";
echo "</div>";
	}

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