<?
$k_page=1;
include_once "../SYSTEM/include/functions.php";
include_once "../SYSTEM/include/mysql.php";
include_once "../SYSTEM/include/param.php";
include_once "../SYSTEM/include/ban.php";
include_once "../SYSTEM/include/sess.php";
include_once "../SYSTEM/include/ban_2.php";
include_once "../SYSTEM/include/theme.php";
$title='Форум';
$mesto='В форуме';
head();
echo "<div class=\"h\">Новые темы в форуме</div><hr />\n";


if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";
$q3 = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]forum_t` ORDER BY time_last DESC;");

if (isset($_GET['id_forum']))
{
$id_forum=intval($_GET['id_forum']);
$q3 = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]forum_t` WHERE `id_f` = '$id_forum' ORDER BY time_last DESC;");

}


$k_them = mysql_result($q3, 0);
if ($k_them>0)
{

if (isset($user))
{
$k_p_str=$user['forum_k_t'];
}
else
{
$k_p_str=$set['k_p_s'];
}
if ($k_them!="0")
{
$v_pages_okr=$k_them/$k_p_str%100;
$v_pages_tochn=$k_them/$k_p_str;
if ($v_pages_okr==$v_pages_tochn)
{
$k_page=$v_pages_okr;
}
else
{
$k_page=$v_pages_okr+1;
}
}

if (isset($_GET['page']) && $_GET['page']!='')
{
if ($_GET['page']=='end')
{
$page=$k_page;
}
else
{
$page=intval($_GET['page']);
}
}
else
{$page=1;}
if ($k_page<$page){$page=$k_page;}
if (0>$page){$page=1;}

$i=$k_p_str*$page-$k_p_str;
$q = mysql_query("SELECT * FROM `$mysql[pref]forum_t` ORDER BY time_last DESC LIMIT $i, $k_p_str;");
if (isset($_GET['id_forum']))
{
$q = mysql_query("SELECT * FROM `$mysql[pref]forum_t` WHERE `id_f` = '$id_forum' ORDER BY time_last DESC LIMIT $i, $k_p_str;");
}

while ($thema = mysql_fetch_array($q))
{
echo "<div class=\"mess\">\n";
$id_forum=$thema['id_f'];
$id_razd=$thema['id_r'];

if (isset($user) && $user['level']>0 && $user['slinks']==0)
{
echo "<a href=\"set_t.php?id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$thema[id]\">\n";
}
echo "<img src=\"../SYSTEM/themes/$them/img/forum/them_$thema[close]$thema[crep].gif\" alt=\"\" />";
if (isset($user) && $user['level']>0 && $user['slinks']==0)
{

echo "</a>\n";

}

echo " <a href=\"index.php?id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$thema[id]\"><b><span style=\"color:$color[forum_theme_name]\">".$thema['name']."</span></b></a>\n";

$id_them=$thema['id'];

$g = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]forum_p` WHERE `id_f` = '$id_forum' AND `id_r` = '$id_razd' AND `id_t` = '$id_them';");

$k_p=mysql_result($g, 0);

if ($k_p>0)

{

$g = mysql_query("SELECT MAX(id) FROM `$mysql[pref]forum_p` WHERE `id_f` = '$id_forum' AND `id_r` = '$id_razd' AND `id_t` = '$id_them';");

$id_p=mysql_result($g, 0);

$g = mysql_query("SELECT * FROM `$mysql[pref]forum_p` WHERE `id_f` = '$id_forum' AND `id` = '$id_p' AND `id_r` = '$id_razd' AND `id_t` = '$id_them';");

$last_post = mysql_fetch_array($g);


echo "(<a href=\"index.php?id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$thema[id]&amp;page=end\">>>></a>)<br />\n";

echo "(Прокомментировано <font color=\"#FF0000\">$k_p</font> раз' -а)<br />\n";


echo "Последнее сообщение <font color=\"#00ff00\">$last_post[nick]</font> <small><span style=\"color:$color[post_time]\">(".vremja($last_post['time']+$timesdvig).")</span></small>";

echo "<br />\n";

echo "<font color=\"#FF0000\">Автор темы</font> <font color=\"#FFA500\">$thema[autor]</font><br />\n";

echo ":::::.......::::::<br />";

}

else

{


}


echo "</div>\n";

echo "<br />\n";

}

}

else

{
echo "Нет тем<br />\n";
}

echo "<hr />\n<div class=\"str\">";
str("new.php?",$k_page,$page);
echo "</div>\n";
echo "<hr />\n";


echo "<a href=\"index.php\">В форум</a><br />\n";
echo "<a href=\"../index.php\">&lt;&lt; На главную</a>\n";

foot();
?>
