<?
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();
err();

echo "<div class='menu_razd'>";
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";

echo "</div>";

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev`"),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 `dnev` WHERE `look` = '0' ORDER BY $order  $lim");
if (mysql_num_rows($q)==0) 
{
echo "No status\n";
}

while ($dnev = mysql_fetch_assoc($q))
{
echo "   <tr>\n";
echo "  <td class='linechat'>\n";
echo "  <div class='hello'>\n";
echo "<a href='dnev.php?id=$dnev[id]'>$dnev[name]</a> <br />\n";;
echo "</div>\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 (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";
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"));

	}
}
echo "</table>\n";
if ($k_page>1)str("?id=$dnev[id]&amp;",$k_page,$page); // Вывод страниц

echo "<div class='foot'>";

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

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


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