<?
require_once"../system/start.php";
require_once"../system/sid.php";
require("../config.php");
$tyu="left";
$title="Форум";
head();
list($row, $myid, $ps, $fs1, $fs2) = check_login($link);
echo $fs1;
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic` where `login` = '".$myid."';"),0);

echo "$div1 <b>Мои темы ($k_post)</b> $div9<br />";

if (empty($row['max'])) $row['max']=10;
$max = $row['max'];

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic` where `login` = '".$myid."';"),0);
$k_page=k_page($k_post,$max);
$page=page($k_page);
$start=$max*$page-$max;

$q=mysql_query("SELECT * FROM `forum_topic` where `login` = '".$myid."' ORDER BY `time` DESC  LIMIT $start, ".$max."");
if (mysql_num_rows($q)==0) {
echo "Нет тем\n";
}
while ($them = mysql_fetch_array($q))
{


$forum=mysql_fetch_array(mysql_query("SELECT * FROM `forum_sections` WHERE `id` = '$them[section]' LIMIT 1"));
$razdel=mysql_fetch_array(mysql_query("SELECT * FROM `forum_subfor` WHERE `id` = '$them[subfor]' LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = $them[login] LIMIT 1"));

echo "$div2<a href='./tema/".$them['id']."'>$them[name]</a> <a href='./tema/".$them['id']."/end'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_message` WHERE `section` = '$forum[id]' AND `subfor` = '$razdel[id]' AND `topic` = '$them[id]'"),0).")</a>$div9\n";




echo "<a href='subfs/".$them['section']."'>$forum[name]</a> &gt; <a href='temes/".$them['subfor']."'>$razdel[name]</a><br />\n";

//$post1=mysql_fetch_array(mysql_query("SELECT * FROM `forum_message` WHERE `topic` = '$them[id]' AND `subfor` = '$razdel[id]' AND `section` = '$forum[id]' AND `login` = '$them[login]' LIMIT 1"));
//$ank=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = $them[login] LIMIT 1"));
//echo "Автор: <a href='".H."$ank[id]' title='Анкета \"$ank[user]\"'>$ank[user]</a> (".date("d.m в H:i", $post1['time']).")<br />\n";

$post=mysql_fetch_array(mysql_query("SELECT * FROM `forum_message` WHERE `topic` = '$them[id]' AND `subfor` = '$razdel[id]' AND `section` = '$forum[id]' ORDER BY `time` DESC LIMIT 1"));
$ank2=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = $post[login] LIMIT 1"));
echo "Посл.: <a href='".H."$ank2[id]' title='Анкета \"$ank2[user]\"'>$ank2[user]</a> (".date("d.m в H:i", $post['time']).")<br />\n";
echo'';
}
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц

echo "<br />$div1<img src=\"../img/naz.gif\" alt=\"[N]\"/> <a href=\"./index.php\">Форум</a>$div9";
if($autorize){ echo "$div1<img src=\"../img/naz.gif\" alt=\"[N]\"/> <a href=\"../enter.php\">На Главную</a>$div9";}

foot ();
?>