<?
echo "<div class='tmn'>\n";

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

$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 `read` = '0' ORDER BY rand() LIMIT 1");
if (mysql_num_rows($q)==0) {
echo "Нет дневников\n";
}
while ($dnev = mysql_fetch_assoc($q))
{
echo "   <tr>\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/dnev.gif' alt='' class='icon'/>\n";

echo "<span style=\"color:$ank[mcolor]\">";

echo output_text(cut_text(($dnev[msg])))."...\n";
echo " <a href='dnev/dnev.php?id=$dnev[id]'>Читать далее &raquo;</a></span><br/>";
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 "</div>";


?>