<?
echo "<div class='linegreen1'>Актуальная тема обсуждения</div>\n";
echo "<div class='statuskomm'>\n";

$adm_add=NULL;
$adm_add2=NULL;
if (!isset($user) || $user['level']==0){
$q222=mysql_query("SELECT * FROM `forum_f` WHERE `adm` = '1'");
while ($adm_f = mysql_fetch_assoc($q222))
{
$adm_add[]="`id_forum` <> '$adm_f[id]'";
}
if (sizeof($adm_add)!=0)
$adm_add2=' WHERE'.implode(' AND ', $adm_add);
}

$q=mysql_query("SELECT * FROM `forum_t`$adm_add2 ORDER BY `time` DESC LIMIT 1");

while ($them = mysql_fetch_assoc($q))
{

$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '$them[id_forum]' LIMIT 1"));
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '$them[id_razdel]' LIMIT 1"));
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $them[id_user] LIMIT 1"));

echo "<img src='/style/themes/$set[set_them]/forum/14/them_$them[up]$them[close].png' />";

echo " <a href='/forum/$forum[id]/$razdel[id]/$them[id]/'><font color='#990d1a'>$them[name]</font></a> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end'><font color='#a8a6a6'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_them` = '$them[id]'"),0).")</font></a>\n";

echo "&gt; <a href='/forum/$forum[id]/$razdel[id]/'>$razdel[name]</a><br />\n";

$post1=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post1[id_user] LIMIT 1"));
echo "<font color='#a8a6a6'>Автор:</font> <a href='/info.php?id=$ank[id]' title='Анкета \"$ank[nick]\"'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a> /\n";

$post=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` DESC LIMIT 1"));
$ank2=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
echo " <a href='/info.php?id=$ank2[id]' title='Анкета \"$ank2[nick]\"'><span style=\"color:$ank2[ncolor]\">$ank2[nick]</span></a>\n";
echo "<br/><font color='#a8a6a6'><u>Время создания: ".vremja($them['time_create'])."</u></font>";
}
echo "</div>\n";
?>