<?
require_once('classes/body.class.php');
require_once('classes/db.class.php');
require_once('classes/system.class.php');
$title= new Body;
$title->SetTitle(homeurl.' - Сообщество мастеров!');
$title->SetDescription(homeurl.' | Форум Wap мастеров, программистов, дизайнеров, кодеров и администраторов');
$title->SetKeywords('CMS, системы управления, '.homeurl.', модули, wap, wap cms, вап движок, мобильный двиг, cms для сайта, шаблоны CMS');
$title->GetHeader();
$AlexCount = DB :: $dbs -> queryFetch ("SELECT * FROM `counts` WHERE `id` = '1' LIMIT 1");
echo'<div class="row">
                    <div class="col-sm-6">
                        <div class="tile">
                            <div class="t-header th-alt bg-bluegray">';
$news = DB :: $dbs -> queryFetch ("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
echo'<div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/news"style="text-decoration:none; color:white;">  '. text ($news['name']).'</a>  ('.$AlexCount['news_comm'].')</div>                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_news">' . ($b['view_news']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_news'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_news`='" . ($b['view_news'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_news']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$sql = DB::$dbs->query("SELECT * FROM news ORDER BY time DESC LIMIT 1");
while($a = $sql->fetch()) {
echo'<a href="/news/comm.html?id='.$a['id'].'" class="list-group-item media"><div class="media-body"><div class="list-group-item-heading"> '.text($a['txt']).'</div></div></a>';        
                            }
                        echo'</div></div>';}
                      echo'</div>
                        <div class="tile">
                            <div class="t-header th-alt bg-teal">
                                <div class="th-title"><i class="zmdi zmdi-comments"></i><a href="/forum" style="text-decoration:none; color:white;">  Наш форум</a> ( ' .$AlexCount['forum_topic']. ' <b style="COLOR:green"> +' .$AlexCount['forum_topic_new']. '</b> / ' .$AlexCount['forum_mess'].' <b style="COLOR:red">+' .$AlexCount['forum_mess_new']. ' </b>)</div>
                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_forum">' . ($b['view_forum']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_forum'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_forum`='" . ($b['view_forum'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}

                                    echo'</ul></div></div>';
if ($b['view_forum']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$req = DB::$dbs->query("SELECT * FROM forum_topic ORDER BY last DESC LIMIT 5");
if ($req -> rowCount() == 0) {
err('Тем еще нет!');
} else {
while($row = $req->fetch()) {
$last_mess = DB::$dbs->queryFetch("SELECT * FROM forum_mess WHERE tid = ? ORDER BY time DESC LIMIT 1", [$row['id']]);
$mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM forum_mess WHERE tid = ?", [$row['id']]);
if ($mess > 10) {
$pg = ceil($mess / 10);
$st = '?page='.$pg;
} else {
$st = '';
}
echo '<a href="/forum/thema'.$row['id'].$st.'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="'.(user_inf($row['user_id'], 'ava') != NULL ? user_inf($row['user_id'], 'ava') : '/assets/img/4.jpg').'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$row['name'].'</div><small class="list-group-item-text">('.vr($last_mess['time']).')</small></div></a>';
}
}
echo'</div></div>';}
echo'</div>';
echo'<div class="tile bg-cyan"><div class="t-header th-alt bg-bluegray"><div class="th-title"><i class="zmdi zmdi-download"></i><a href="/downs"style="text-decoration:none; color:white;">   Загруз-центр </a>(' .$AlexCount['downs']. '/<b style="COLOR:red">' .$AlexCount['downs_new']. '</b>)</div><div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_down">' . ($b['view_down']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_down'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_down`='" . ($b['view_down'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_down']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$list_file = DB::$dbs->query("SELECT id,name,info,size,time FROM downs WHERE rid != ? ORDER BY id DESC LIMIT 4", [6]);
while($list = $list_file -> fetch()) {
$sqlScreen = DB::$dbs->queryFetch("SELECT * FROM `down_screen` WHERE `fid` = ? ORDER BY `id` DESC LIMIT 1",[$list['id']]);
$mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM down_komm WHERE file = ?", [$list['id']]);
echo'<a href="/downs/file.html?id='.$list['id'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/'.$sqlScreen['file'].'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$list['name'].' ('.get_size($list['size']).')</div><small class="list-group-item-text">('.vr($list['time']).')</small></div></a>';
}            
echo'</div></div>';}
echo'</div>';
echo'<div class="tile bg-cyan"><div class="t-header th-alt bg-black-trp"><div class="th-title"><i class="zmdi zmdi-crop"></i><a href="/codes"style="text-decoration:none; color:white;"> Полезные коды </a>(' .$AlexCount['codes_code']. '/<b style="COLOR:red">' .$AlexCount['codes_code_new']. '</b>)</div><div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_codes">' . ($b['view_codes']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_codes'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_codes`='" . ($b['view_codes'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_codes']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$list_code = DB::$dbs->query("SELECT * FROM `codes_code` WHERE `check` = ? ORDER BY RAND() DESC LIMIT 3", [1]);
while($list = $list_code -> fetch()) {
$mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM codes_comm WHERE cid = ?", [$list['id']]);
echo'<a href="/codes/code.php?id='.$list['id'].'" class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="'.(user_inf($list['user_id'], 'ava') != NULL ? user_inf($list['user_id'], 'ava') : '/assets/img/4.jpg').'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$list['name'].'</div><small class="list-group-item-text">('.vr($list['time']).')</small></div></a>';
                            }
                        echo'</div></div>';}echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-swap-alt"></i><a href="/votes"style="text-decoration:none; color:white;"> Случайный отзыв</a> (' . DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `otzyvy`") . ')</div>         
                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_votes">' . ($b['view_otz']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_votes'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_otz`='" . ($b['view_otz'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_otz']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM otzyvy WHERE activ = ?", [1]);
if ($look == 0) {
err('Отзывов нет! Будь первым :)');
}
$sql = DB::$dbs->query("SELECT * FROM otzyvy WHERE activ = ? ORDER BY RAND() DESC LIMIT 1",[1]);
while($a = $sql->fetch()) {
echo'<a class="list-group-item media" href="/users/'.$a['user_id'].'"><div class="pull-left"><img class="img-circle pull-left" src="/'.(user_inf($a['user_id'], 'ava') != NULL ? user_inf($a['user_id'], 'ava') : 'assets/img/4.jpg').'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.user_inf($a['user_id'], 'name').'  '.user_inf($a['user_id'], 'family').'</div><small class="list-group-item-text"> '.($a['type'] == 1 ? '<font color="green">'.text($a['text']).'</font>':'<font color="red">'.text($a['text']).'</font>').'</small></div></a>';
}

                                    echo'</div></div>';}echo'</div>';
$AlexCount = DB :: $dbs -> queryFetch ("SELECT * FROM `counts` WHERE `id` = '1' LIMIT 1");

                        echo'<!-- Меню сайта -->
                        <div class="tile">
                            <div class="calendar-widget"></div>
                        </div>
                    </div>
                    
                    <div class="col-sm-6">
                               <div class="tile">
                            <div class="t-header th-alt bg-blue">
                                <div class="th-title"><i class="zmdi zmdi-trending-up zmdi-hc-fw"></i> Статистика сайта</div>
                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_stat">' . ($b['view_stat']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_stat'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_stat`='" . ($b['view_stat'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
                                  
$ft = DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `forum_topic`");
$fm = DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `forum_mess`");
$fff = $ft + $fm;
                          if ($b['view_stat']==0) { 
echo'<div class="tile-body"><div class="bg-blue count-box"><div class="row">
<a href="/news"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `news`") . '</h3><small>Новости</small></div></div></a>
<a href="/allnews"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `gazeta_article`") . '</h3><small>Газета</small></div></div></a>
<a href="/forum"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . $fff . '</h3><small>Форум</small></div></div></a>
<a href="/downs"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `downs` WHERE `mod` = ?",[0]) . '</h3><small>Загрузки</small></div></div></a>';

$gf = DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `album_foto`");
$gall = $gf;

$sp = DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `support`");
$sm = DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `support_mess`");
$sup = $sp + $sm;

echo'<a href="/codes"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `codes_code`") . '</h3><small>Коды</small></div></div></a>
<a href="/market"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `magazin_file`") . '</h3><small>Магазин</small></div></div></a>
<a href="/gallery"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . $gall . '</h3><small>Галерея</small></div></div></a>
<a href="/lenta"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">'. DB::$dbs -> querySingle("SELECT COUNT(id) FROM `lenta`") . '</h3><small>События</small></div></div></a>
<a href="/garants"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">'.DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `garant`").'</h3><small>Гаранты</small></div></div></a>
<a href="/votes"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6"><div class="cb-item"><h3 style="text-decoration:none; color:white;">' . DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `otzyvy`") . '</h3><small>Отзывы</small></div></div></a>
<a href="/support/"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6 hidden-xs"><div class="cb-item"><h3 style="text-decoration:none; color:white;">'.$sup.'</h3><small>Тикеты</small></div></div></a>
<a href="/peoples"style="text-decoration:none; color:white;"><div class="col-sm-3 col-xs-6 hidden-xs"><div class="cb-item"><h3 style="text-decoration:none; color:white;">'.DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `blogger`").'</h3><small>Мастера</small></div></div></a>';
                                   echo' </div>';}echo'</div>                               
                        
                        <!-- Лента событий -->
                        <div class="tile">
                            <div class="t-header th-alt bg-bluegray">
                                <div class="th-title"><i class="zmdi zmdi-layers"></i><a href="/lenta"style="text-decoration:none; color:white;"> Лента событий</a> ('. DB::$dbs -> querySingle("SELECT COUNT(id) FROM `lenta`").(empty($new_lenta) ? NULL : '/<b style="COLOR:red">'.$new_lenta.'</b>').')</div>
                                
                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_lenta">' . ($b['view_lenta']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_lenta'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_lenta`='" . ($b['view_lenta'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_lenta']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';

$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM lenta");
if ($look == 0) {err('Лента событий пуст!');}
$sql = DB::$dbs->query("SELECT * FROM lenta ORDER BY time DESC LIMIT 5");
while($a = $sql->fetch()) {
echo'<div class="list-group-item media"><div class="pull-left"><img class="img-circle pull-left" src="/assets/img/4.jpg" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">Система оповещений</div><small class="list-group-item-text"> '.text($a['text']).'</small><small class="list-group-item-text">'.vr($a['time']).'</small></div></div>';
}
echo'</div></div>';}echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi zmdi-view-list"></i><a href="/allnews" style="text-decoration:none; color:white;">  Свежие новости</a> (' . DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `gazeta_article`") . ' <b style="COLOR:green"> +' . DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `gazeta_article` WHERE `time`>'" . (time () - 86400) . "'") . '</b>)</div>
                                <div class="actions dropdown">
                                    <a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>       
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_gazeta">' . ($b['view_gazet']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_gazeta'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_gazet`='" . ($b['view_gazet'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul>
                                </div>
                            </div>';
if ($b['view_gazet']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$sql = DB::$dbs->query("SELECT * FROM gazeta_article ORDER BY RAND() DESC LIMIT 3");
while($a = $sql->fetch()) {
echo'<a class="list-group-item media" href="/allnews/news.html?id='.$a['id'].'""><div class="pull-left"><img class="img-circle pull-left" src="/'.(user_inf($a['user_id'], 'ava') != NULL ? user_inf($a['user_id'], 'ava') : 'assets/img/4.jpg').'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$a['name'].'</div><small class="list-group-item-text">('.vr($a['time']).')</small></div></a>';
}
echo'</div></div>';}echo'</div>';
echo'<div class="tile"><div class="t-header th-alt bg-bluegray"><div class="th-title"><i class="zmdi zmdi-shopping-cart"></i><a href="/market" style="text-decoration:none; color:white;">  Маркет</a> (' .$AlexCount['magazin_file']. '/' .$AlexCount['magazin_file_new']. ')</div>
<div class="actions dropdown"><a href="" data-toggle="dropdown"><i class="zmdi zmdi-more"></i></a>       
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href=javascript:document.location.reload()>Обновить</a></li>';
                  if ($b == true) {    echo'<li><a href="?view_shop">' . ($b['view_shop']==1?'Развернуть':'Свернуть').'</a></li>'; 
if (isset ($_GET['view_shop'])) { 
DB :: $dbs -> query ("UPDATE `blogger` SET `view_shop`='" . ($b['view_shop'] == 1 ? 0 : 1) . "' WHERE (`id`='" . $b['id'] . "')"); 
header ('location: ?'); 
}
}
                            echo'</ul></div></div>';
if ($b['view_shop']==0) { 
echo'<div class="t-body"><div class="list-group lg-alt">';
$sql = DB :: $dbs -> query ("SELECT * FROM `magazin_file` ORDER BY RAND() DESC LIMIT 3");
if ($sql -> rowCount() >0) {
while($a = $sql-> fetch ()) {
$screen = DB::$dbs->queryFetch("SELECT * FROM `magazin_screen` WHERE `file` = ? ORDER BY `id` DESC LIMIT 1",[$a['id']]);
$mess = DB::$dbs->querySingle("SELECT COUNT(id) FROM magazin_komm WHERE file = ?", [$a['id']]);
$path = $_SERVER['DOCUMENT_ROOT'].'/files/mag_file/'.$a['file'];
$ext = strtolower(strrchr($path, '.'));
echo'<a class="list-group-item media" href="/market/file/'.$a['id'].'""><div class="pull-left"><img class="img-circle pull-left" src="/files/mag_screen/'.$screen['screen'].'" alt="" width="40" height="40"></div><div class="media-body"><div class="list-group-item-heading">'.$a['name'].'  ('.$ext.' | '.get_size(filesize($path)).')</div><small class="list-group-item-text">('.vr($a['time']).')</small></div></a>';
}
}else {
echo '<div class="alert alert-danger">Товаров пока нет..</div>';
}
echo'</div></div>';}echo'</div>';

$title->GetMenu();
$title->GetFooter();
?>