<?php
$title = 'Добро пожаловать';
include_once 'sys/db.php';
include_once 'sys/fnc.php';
include_once H.'sys/head.php';

$user_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$guest_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest`"),0);
$blog_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_article`"),0);
$user_on = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `time_last` > ". (time()-600) .""), 0);

echo $div->div_razd.'Последние статьи</div>'; 
$subsection = mysql_query("SELECT `id`,`time`,`name`,`text`,`id_dir` FROM `blog_article` ORDER BY `id` DESC LIMIT 3");
while ($blog = mysql_fetch_object($subsection)) {
$text = mb_substr($blog->text, 0, 140, 'utf-8');
$f_name = mysql_fetch_object(mysql_query("SELECT `id_dir` FROM `blog_article` WHERE `id_dir` = '$blog->id_dir' LIMIT 1"));
$dir_name = mysql_fetch_object(mysql_query("SELECT `name` FROM `blog_category` WHERE `id` = '$f_name->id_dir' LIMIT 1"));
echo '<div class="menu"><a href="'.$HOME.'/blog'. $blog->id .'">'. output($blog->name).'</a><br> '. output($text) .'
<br />Раздел: <a href="'.$HOME.'/pages/blog/?dir='.$blog->id_dir.'">'.$dir_name->name.'</a></div>';
}
// Вывод ссылки управление
echo $div->div_razd.' Меню</div>'; 
echo $div->div_menu.'<i class="fa fa-comment fa-fw"></i><a href="pages/guest/">Гостевая книга</a> <span class="count">'.$guest_count.'</span></div>'; 
echo $div->div_menu.'<i class="fa fa-book fa-fw"></i><a href="pages/blog/">Все блоги</a> <span class="count">'.$blog_count.'</span></div>'; 
echo $div->div_menu.'<i class="fa fa-group fa-fw"></i><a href="pages/user/">Пользователи</a> <span class="count">'.$user_count.'</span> / <span style="color: #DD0000">On '. $user_on .'</span></div>'; 

include_once H.'sys/foot.php';
?>