<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut == true) {
//Выводим закладки
$diz -> head('Мои закладки');
require_once (ROOT.'/new_mail.php');
$count = $db -> dbcount('count(`id`)','nuts',"`user` = '".$ya['id']."' and `where`='forum'");
$diz -> title("<a href='./'>Форум</a>/<b>Мои закладки</b> ($count)");
if ($count > 0) {
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$nuts = $db -> query("SELECT * FROM `nuts` WHERE `user` = '".$ya['id']."' and `where`='forum' order by `time` DESC  LIMIT ".$start.",".$num);
while ($a = $nuts -> fetch_assoc()) {
$assoc = $db -> query("SELECT `id`,`name`,`user` FROM `forum_tems` WHERE `id` = '".$a['idwh']."'")-> fetch_assoc();
$col = $db -> dbcount('COUNT(`id`)','golos',"`where`='forum' and `id_w` = '".$assoc['id']."'");
if($col>0){$st=$diz -> img('golos.png');}else{$st=null;}
if($assoc['status']==0){$status =''.$diz -> img('r.png').' '.$st.'';}
if($assoc['var']==1){$sta =''.$diz -> img('zak.png').'';}
elseif($assoc['status']==1){$status=''.$sta.''.$diz -> img('close.png').''.$st.'';}

$usmax = $db -> dbcount('max(`id`)','forum_posts','`tema`='.$assoc['id'].'');
$max = $db -> query("SELECT * FROM `forum_posts` where `id`='$usmax'")-> fetch_assoc();
$usmin = $db -> dbcount('min(`id`)','forum_posts','`tema`='.$assoc['id'].'');
$min = $db -> query("SELECT * FROM `forum_posts` where `id`='$usmin'")-> fetch_assoc();
$user = $db -> query("SELECT * FROM `users` where `id`='".$max['user']."' ")-> fetch_assoc();
$autor = $db -> query("SELECT * FROM `users` where `id`='".$min['user']."' ")-> fetch_assoc();
$cid = $db -> dbcount('COUNT(`id`)','forum_posts'," `tema` = '".$assoc['id']."'");
$tot = intval(($cid - 1) / $num) + 1;
$msg .= '<div class="top">'.$status.' <a href="tema'.$assoc['id'].'">'.$assoc['name'].'</a>('.$cid.')
<a href="tema.php?id='.$assoc['id'].'&amp;page='.$tot.'">>></a></div>
<a href="../my/id'.$autor['id'].'">'.$autor['login'].'</a>/<a href="../my/id'.$user['id'].'">'.$user['login'].'</a>    ('.$func -> times(date('d m Y H:i:s',$max['time'])).')';
}
$act = 'my_nuts.php?';
$msg .= ''.$func -> pagenav($act,$page,$total).'';
} else {
$msg = '';
$msg.='<div class="fon">У вас пока нет закладок!</div>';
}
}else {header('location: ../aut.php');}
$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/index.php">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
?>