<?

$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(isset($_GET['t']) && is_numeric($_GET['t']) && isset($user))$t=intval($_GET['time']);

else{

header("Location: ../?");exit;

}

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` WHERE `time_last` >= '$t';");


$k_them = mysql_result($q3, 0);

if ($k_them>0){

$k_p_str=$user['forum_k_t'];
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` WHERE `time_last` >= '$t' 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 "(Прокомментировало $k_p человек)<br />\n";


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

echo "<br />\n";

echo "Автор темы $thema[autor]<br />\n";

}

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

echo "<hr />\n<div class=\"str\">";
str("time.php?t=$t&amp;",$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();
?>
