<?

$isc = $_SERVER['DOCUMENT_ROOT'];
require_once $isc.'/sys/inc/start.php';
require_once $isc.'/sys/inc/compress.php';
require_once $isc.'/sys/inc/sess.php';
require_once $isc.'/sys/inc/home.php';
require_once $isc.'/sys/inc/settings.php';
require_once $isc.'/sys/inc/db_connect.php';
require_once $isc.'/sys/inc/ipua.php';
require_once $isc.'/sys/inc/fnc.php';
require_once $isc.'/sys/inc/user.php';
only_reg();

$set['title']='Закладки';
require_once $isc.'/sys/inc/thead.php';
title();


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_user` = '$user[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
?><div class='ankus'>Нет закладок</div><?
}
$q=mysql_query("SELECT * FROM `forum_zakl` WHERE `id_user` = '$user[id]' ORDER BY `time_obn` DESC LIMIT $start, $set[p_str]");
while ($zakl = mysql_fetch_assoc($q))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id` = '$zakl[id_them]' LIMIT 1"),0)==1)
{

$them=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '$zakl[id_them]' LIMIT 1"));
$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"));






$k_p=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);
$k_n_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_them` = '$them[id]' AND `time` > '$zakl[time]'"),0);

$page_z=k_page($k_p-$k_n_p+1,$set['p_str']);
if ($k_n_p==0)$k_n_p=NULL;else $k_n_p="/+$k_n_p";





echo "  <div class='hmenu'>\n";
echo "<a href='/modules/forum/class.php?id=$them[id]&page=$page_z'>$them[name] ($k_p$k_n_p)</a>\n";
echo "  </div>\n";


echo "  <div class='ankus'>\n";
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $them[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 `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `id` 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 "  </div>\n";
}}

require_once $isc.'/sys/inc/tfoot.php';
?>