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



if (isset($user))$user_blog=$user['id'];
if (isset($_GET['id']))$user_blog=intval($_GET['id']);

if (!isset($user_blog))
{
$set['title']='Ошибка';
require '../sys/inc/thead.php';
title();
echo "Нет такого пользователя";
echo"<div class='foot'>\n";
echo"<a href='index.php'>Дневники</a><br />\n";
echo"</div>\n";
require '../sys/inc/tfoot.php';
exit();
}

$ank_user=get_user($user_blog);
if(!$ank_user)
{
$set['title']='Ошибка';
require '../sys/inc/thead.php';
title();
echo "Нет такого пользователя";
echo"<div class='foot'>\n";
echo"<a href='index.php'>Дневники</a><br />\n";
echo"</div>\n";
require '../sys/inc/tfoot.php';
exit();
}



$set['title']='Блоги обитателя '.$ank_user['nick'].'';
require '../sys/inc/thead.php';
title();
err();
if($user['id'] == $user_blog) $where="WHERE `id_user` = '$user_blog'";
else $where="WHERE `privat` = '0' && `id_user` = '$user_blog'";


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_list` $where"),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)
{
?>
<div class='noy'>У пользователя нету дневников</div>
<?
}

$res = mysql_query("select * from `blog_list` $where order by `time` desc LIMIT $start, $set[p_str];"); 
while ($blog = mysql_fetch_array($res)){
$ank=get_user($blog['id_user']);
if($num==1){
echo '<div class="enk_div">';
$num=0;
}else{
echo '<div class="enk2_div">';
$num=1;}
echo "".avatar2($ank['id'])."<br />";
echo "".on($ank['id'])."\n";
echo "".pol($ank['id'])."";
echo "<a href='/info.php?id=$ank[id]'><span style='color:$ank[ncolor]'>$ank[nick]</span></a> <span class='ank_n'>(".vremja($blog['time']).")</span><br />\n";
if ($blog['read']==0)echo "<img src='images/gall2.gif' alt=''/>\n";
if ($blog['read']==2)echo "<img src='images/gall0.gif' alt=''/>\n";
echo "<a href='list.php?id=".$blog['id']."'>".output_text($blog['name'])."</a> ";
echo"(<a href='komm.php?id=$blog[id]'>Комментарии <b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_blog` = '$blog[id]'"),0)."</b></a>)<br/>";
echo "</div>\n";
}


if (isset($user_blog)) $dop="id=$user_blog&amp;";
else $dop='';
if ($k_page>1)str('?'.$dop.'',$k_page,$page); // Вывод страниц

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