<?
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';
only_reg();
$set['title']='Микроблоги';
include_once '../sys/inc/thead.php';
title();
aut();

if (!isset($_GET['id']) || !is_numeric($_GET['id']))
{
header("Location: /index.php");
}
$id=intval($_GET['id']);
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$id' LIMIT 1"));

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog` WHERE `uid` = '$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='p_m'><center>";
echo "".online($ank['id'])." ";
echo "<a href='/info.php?id=$id'>";
echo "$ank[nick]";
echo "</a>";
echo "</center></div>";
echo "<div class='p_t'>";
echo '<img src="/img/act.edit.png" alt="" /> Всего '.$k_post.' микроблогов';
echo "</div>";
if ($k_post==0)echo'<div class="err">Нет микроблогов</div>';
$q=mysql_query("SELECT * FROM `microblog` WHERE `uid` = '$id' ORDER BY `id` DESC  LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[uid]' LIMIT 1"));

echo "<div class='triangle2'></div><a href='microblog.php?id=$post[id]'><div class='trianglerect2'>";
echo "".esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['text']))))))))."</div></a>";
$komms=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_komm` WHERE `id_blog` = '$post[id]'"),0);
$superall=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_klass` WHERE `id_blog` = '$post[id]'"),0);
$superyou=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_klass` WHERE `id_blog` = '$post[id]' AND `uid` = '$user[id]'"),0);
$see=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_see` WHERE `id_blog` = '$post[id]'"),0);
$superother=$superall-$superyou;
echo "<img src='/img/bubl.png' alt='' /> $komms &bull; ";
if ($superyou!=0)
{
echo "<img src='/img/cls.png' alt='' /> Вы <span style='text-decoration:underline'>и ещё <a href='klasslist.php?id=$post[id]'>$superother чел.</a></span>";
}
if ($superyou==0)
{
echo "<img src='/img/cls.png' alt='' /> <a href='klass.php?id=$post[id]'>Kласс!</a> <span style='text-decoration:underline'><a href='klasslist.php?id=$post[id]'>$superother чел.</a></span>";
}
echo " &bull; <span style='color:red'>".vremja($post['time'])."</span>";
echo " &bull; <img src='/img/eye.png' alt='' /> <a href='see.php?id=$post[id]'>$see</a>";
echo "</div>";
if (isset($user) && $user['id']==$post['uid'])
{
echo "<img src='/img/deletemail.gif' alt='' /> <a href='delete_mcrbl.php?id=$post[id]'>Удалить микроблог</a>";
}
echo "<br />";

echo "<div class='hr'></div>";
}

if ($k_page>1)str("?id=$id&amp;",$k_page,$page); // Вывод страниц
echo "<div class='p_m'>";
if ($user['id']==$id)
{
echo "- <a href='create.php'>Создать микроблог</a><br />";
}
echo "- <a href='/info.php?id=$id'>На личную страничку</a></div>";
include_once '../sys/inc/tfoot.php';
?>