<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Форум - Наблюдаемые темы');
$title->GetHeader();
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: Форум</div></div></div>';
echo'<div class="list-group-item media"><span class="label label-danger">Новые</span> <a href="newtheme.php">Темы</a> | <a href="newposts.php">Сообщения</a></br>';
if (isset($b)) {
echo'</br><span class="label label-danger">Мои</span> <a href="user_thems.php?id='.$b['id'].'">Темы</a> | <a href="user_posts.php?id='.$b['id'].'">Сообщения</a> | <a href="podpis.php">Наблюдаемые</a>';
}
echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/forum"style="text-decoration:none; color:white;"> Форум</a> :: Наблюдаемые темы</div></div></div>';
echo'<div class="t-body"><div class="list-group lg-alt">';
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM forum_podpis WHERE user_id = ?", [$b['id']]);
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM forum_podpis WHERE user_id = ? ORDER BY id DESC LIMIT $start,$num", [$b['id']]);
if ($sql -> rowCount() == 0) {
err('Тем ещё нет!');
} else {
while($a = $sql->fetch()) {
$tema = DB::$dbs->queryFetch("SELECT * FROM forum_topic WHERE id = ? LIMIT 1", [$a['tid']]);
$k_mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM forum_mess WHERE tid = ?", [$a['tid']]);
if ($k_mess > 10) {
$pg = ceil($k_mess / 10);
$st = ' <a href="/forum/thema'.$a['tid'].'?page='.$pg.'">>></a>';
} else {
$st = '';
}
echo '<a href="/forum/thema'.$a['tid'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/'.(user_inf($tema['user_id'], 'ava') != NULL ? user_inf($tema['user_id'], 'ava') : '/assets/img/4.jpg').'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$tema['name'].' ('.$k_mess.')</div><small class="list-group-item-text">('.vr($tema['time']).')</small></div></a>';
}
}
echo'</div></div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-format-list-bulleted"></i>  <a href="/rules"style="text-decoration:none; color:white;">Правила</a> | <a href="/bbcodes"style="text-decoration:none; color:white;"> Справка BBcode</a> | <a href="/smiles"style="text-decoration:none; color:white;">Все смайлы</a> | <a href="search"style="text-decoration:none; color:white;">Поиск</a></div></div></div>'; 
if ($k_page>1) {
str('?', $k_page, $page);
}
$title->GetMenu();
$title->GetFooter();
?>