<?
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();
echo "<div class=\"rekl\">\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href=\"index.php\" title=\"Вернуться к подфорумам\">Форум</a><br />\n";
echo "</div>\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);
}

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t`$adm_add2"),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";
$q=mysql_query("SELECT * FROM `forum_t`$adm_add2 ORDER BY `time_create` DESC  LIMIT $start, $set[p_str]");
if (mysql_num_rows($q)==0) {
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет тем\n";
echo "  </td>\n";
echo "   </tr>\n";
}
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"));
//$them=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '$post[id_them]' LIMIT 1"));
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $them[id_user] LIMIT 1"));


echo "   <tr>\n";
if ($user['zebra_forum']==0)
{
if($num==1){ 
echo "<td class='linechat'>"; 
$num=0;
}else{ 
echo "<td class='linechat'>"; 
$num=1;}
}

if ($user['zebra_forum']==1)
{
if($num==1){ 
echo "<td class='forumwup'>"; 
$num=0;
}else{ 
echo "<td class='forumdiv'>"; 
$num=1;}
}
$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"));
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 "".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['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['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";
echo "(".vremja($them['time_create']).")<br/>\n";
echo "<img src='/style/themes/$set[set_them]/forum/14/them_$them[up]$them[close].png' alt='' />";

echo " <a href='/forum/$forum[id]/$razdel[id]/$them[id]/'><b>$them[name]</b></a> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end'>(".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).")</a><br/>\n";


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



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




echo "<div class=\"rekl\">\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href=\"index.php\" title=\"Вернуться к подфорумам\">Форум</a><br />\n";
echo "</div>\n";

include_once '../sys/inc/tfoot.php';
?>