<?
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]='Дневники Xhata.Su';

include_once '../sys/inc/thead.php';
title();
err();
echo "<div class='menu_razd'>";
echo "<img src='/style/icons/top10.png' alt='' class='icon'/> <a href='/top/top_blog.php'>Топ Блогеров</a> | \n";
echo "<a href='/top/top_komm_blog.php'>Комментаторов</a>\n";
echo "</div>";
echo "<div class='tmn'>";
echo "Сорт:\n";
if (!isset($_GET[time])) echo "<a href='?time'>Время</a>\n";
if (isset($_GET[time])) echo "<font color='red'>Время</font>\n";

echo "\n|\n";

if (!isset($_GET[komm])) echo "<a href='?komm'>Комментарии</a>\n";
if (isset($_GET[komm])) echo "<font color='red'>Комментарии</font>\n";

echo "\n|\n";

if (!isset($_GET[look])) echo "<a href='?look'>Просмотры</a>\n";
if (isset($_GET[look])) echo "<font color='red'>Просмотры</font>\n";
if (isset($user)) {
echo "<br/><img src='/style/icons/plus.gif' alt='' class='icon'/>\n";
echo "<a href='add.php'>Новая запись</a>";
	}
echo "</div>";

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog` WHERE `read` = '0'"),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]";

$order='`time` DESC';
if (isset($_GET[time])) $order='`time` DESC';
if (isset($_GET[komm])) $order='`komm` DESC';
if (isset($_GET[look])) $order='`look` DESC';

$q=mysql_query("SELECT * FROM `microblog` WHERE `read` = '0' ORDER BY $order  $lim");
if (mysql_num_rows($q)==0) {
echo "Нет дневников\n";
}
while ($dnev = mysql_fetch_assoc($q))
{
echo "   <tr>\n";
echo "  <td class='linechat'>\n";
$ank=get_user($dnev['id_user']);
echo " ".online($ank['id'])." <a href='/info.php?id=$ank[id]' title='Анкета \"$ank[nick]\"'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a>\n";
if ($ank['obit']==0)
{
if ($ank['group_access']>1)echo "<img src='/style/adm.png'>\n";
}
if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
if ($ank['brak']!=NULL)echo "<img src='/style/icons/rings.gif' alt='' class='icon'/> \n";
if ($ank['braks']!=NULL)echo "<img src='/style/icons/rings.gif' alt='' class='icon'/> \n";
if ($ank['stran']==0)echo "\n";
if ($ank['stran']==1)echo "<img src='/style/strana/ru.png'>\n";
if ($ank['stran']==2)echo "<img src='/style/strana/ua.png'>\n";
if ($ank['stran']==3)echo "<img src='/style/strana/by.png'>\n";
if ($ank['stran']==4)echo "<img src='/style/strana/az.png'>\n";
if ($ank['stran']==5)echo "<img src='/style/strana/kz.png'>\n";
if ($ank['stran']==6)echo "<img src='/style/strana/uz.png'>\n";
if ($ank['stran']==7)echo "<img src='/style/strana/england.png'>\n";
if ($ank['stran']==8)echo "<img src='/style/strana/de.png'>\n";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
echo "<font color='red'>[BAN]</font>\n";
echo "<br/>\n";
echo "<img src='/style/icons/blogi.png' alt='' class='icon'/>\n";

echo "<a href='blog.php?id=$dnev[id]'>$dnev[name]</a><br/>\n";


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

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

echo "<div style='text-align: right;'>";
echo " ".online($ank2['id'])." <a href='/info.php?id=$ank2[id]' title='Анкета \"$ank2[nick]\"'><span style=\"color:$ank2[ncolor]\">$ank2[nick]</span></a> <img src='/style/icons/chat.gif' alt='' class='icon'/> ".mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_kom` WHERE `id_dnev` = '$dnev[id]'"),0)."<br />\n";
	}
echo "<font color='#afb0a3'>".vremja($dnev[time])."</font> <img src='/style/icons/clock.png' alt='' class='icon'/>   </div>";
}
if ($k_page>1)str("?id=$dnev[id]&amp;",$k_page,$page); // Вывод страниц
echo "</table>\n";
echo "<div class='aut'>";

$all_dnev=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog` WHERE `read` = '0'"),0);

$new_d=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog` WHERE `time` > '".(time()-86400)."' AND `read` = '0'"), 0);

$all_dnev_k=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_kom`"),0);

$new_d_k=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_kom` WHERE `time` > '".(time()-86400)."' "), 0);

echo "Всего дневников $all_dnev <font color='red'>+$new_d Сегодня</font><br/>Всего комментариев $all_dnev_k <font color='red'>+$new_d_k Сегодня</font>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>