<?
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';
include $_SERVER['DOCUMENT_ROOT']."/anti_ hacker.php"; 
if(isset($_GET['s']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id` = '".intval($_GET['s'])."' LIMIT 1"),0)==1)
{
$s=intval($_GET['s']);
$soo=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `id` = '$s' LIMIT 1"));
include_once 'inc/ban.php';
$set['title']="".filter_var($soo['name'], FILTER_SANITIZE_SPECIAL_CHARS)." - Новые темы на форуме"; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
if($soo['konf_soo']==0 || isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 || isset($user) && $user['id']==$soo['admid']  || isset($user) && $user['level']>0)
{

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_thems` WHERE `id_soo`='$s'"),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 `soo_forum_thems` WHERE `id_soo`='$s' ORDER BY `time` 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 `soo_forums` WHERE `id` = '$them[id_forum]' 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 ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";
echo "<img src='/style/themes/$set[set_them]/forum/48/them_$them[up]$them[close].png' />";
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "  <td class='icon14'>\n";
echo "<img src='/style/themes/$set[set_them]/forum/14/them_$them[up]$them[close].png' alt='' />";
echo "  </td>\n";
}


echo "  <td class='p_t'>\n";
echo "<a href='forum.php?s=$s&id_forum=$forum[id]&id_them=$them[id]'>".filter_var($them['name'], FILTER_SANITIZE_SPECIAL_CHARS)."</a> <a href='forum.php?s=$s&id_forum=$forum[id]&id_them=$them[id]&page=end'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_mess` WHERE `id_forum` = '$forum[id]' AND `id_soo`='$s' AND `id_them` = '$them[id]'"),0).")</a>\n";
echo "  </td>\n";
echo "   </tr>\n";


echo "   <tr>\n";
if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";


echo "<a href='forum.php?s=$s'>Форум</a> &gt; <a href='forum.php?s=$s&id_forum=$forum[id]'>".filter_var($forum['name'], FILTER_SANITIZE_SPECIAL_CHARS)."</a><br />\n";

$post1=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_soo` = '$s' 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 "Автор: <a href='/info.php?id=$ank[id]' title='Анкета \"$ank[nick]\"'>$ank[nick]</a> (".vremja($them['time_create']).")<br />\n";

$post=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_soo` = '$s' 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]\"'>$ank2[nick]</a> (".vremja($post['time']).")<br />\n";
echo "  </td>\n";
echo "   </tr>\n";

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




echo "<div class=\"foot\">\n";
echo "&raquo;<a href=\"new_t.php?s=$soo[id]\">Новые темы</a><br />\n";
echo "&laquo;<a href=\"index.php?s=$s\" title=\"Вернуться в сообщество\">В сообщество</a><br />\n";
echo "</div>\n";
}
else
{
echo'Вам недоступен просмотр новых тем данного сообщества';
}
}
else
{
header("Location:index.php");
}
include_once '../sys/inc/tfoot.php';
?>