<?php

include 'system/funcs.php';
require_once('system/sys.php');
H (' Мобильный форум решений и проблем');
// Новости
$c_n = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `news`");
if ($c_n !=0) {
        $news = DB :: $dbs -> queryFetch ("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
        
        // 
        echo '<div class="menu"><a href="/news" style="text-decoration:none; color:white;">Новости проекта (' . $c_n . ')</a></div>';
        
        // 
        echo '<div class="wape">';             
        
        
        
        if (mb_strlen ($news['text']) > 1500) {
                echo bb (mb_substr ($news['text'], 0, 150)) . '.. <a href="/news">Читать дальше..</a>';
        }
        else {
                echo bb ($news['text']);
        }
        
        echo '<br/>';
        
        
        echo '<span style="color: #6d6d6d;">Добавил: ' . uNick ($news['us']) . ' (' . datef ($news['t']) . ')</span><br/>';
        // display link from comments
        echo '<a href="/komm' . $news['id'] . '">Комментарии</a>: (' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `news_komm` WHERE (`id_news`='" . $news['id'] . "')") . ')';

        
        echo '</div>';
        
}



$date = date('d.m.');
$day = DB::$dbs->query
("SELECT id FROM us WHERE
birthday LIKE ? ORDER BY id DESC",array("%$date%"));
if ( $day->rowCount() == 0 ) {
             echo '<div class="list1">Сегодня именинников нет!</div>';
         }
if($day->rowCount()>0){
echo '<div class="list1">';
echo '<b><font color=#a6a122>Именинники сегодня:</b></font> ';
while($d = $day->fetch()){
echo '<a href="/us'.$d['id'].'">'.uNick($d['id']).'</a>, ';
}
echo '</div>';
} 




// Форум
echo '<div class="menu3"><a href="/forum.php" style="text-decoration:none; color:white;">Форум</a> (' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_t` " . (isset ($us) ? ($us['level']>0 ? '' : 'WHERE (`type`!=\'2\')') : 'WHERE (`type`!=\'2\')')) . '/' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` " . (isset ($us) ? ($us['level']>0 ? '' : 'WHERE (`del`=\'0\')' ) : 'WHERE (`del`=\'0\')')) . ') (<font color="green">+' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_t` WHERE `time`>'" . (time () - 86400) . "' " . (isset ($us) ? ($us['level']>0 ? 'AND (`type`!=\'2\')' : '') : 'AND (`type`!=\'2\')')) . '</font>/<font color="red">+' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE `time`>'" . (time () - 86400) . "' " . (isset ($us) ? ($us['level']>0 ? '' : 'AND (`del`=\'0\')') : 'AND (`del`=\'0\')')) . '</font>)</div>';
echo '<div class="ram">';

if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_t` " . (isset ($us) ? ($us['level']>0 ? '' : 'WHERE (`type`!=\'2\')') : 'WHERE (`type`!=\'2\')' )) != 0) {
        $query = DB :: $dbs -> query ("SELECT * FROM `forum_t` " . (isset ($us) ? ($us['level']>0 ? '' : 'WHERE (`type`!=\'2\')') : 'WHERE (`type`!=\'2\')' ) . " ORDER BY `time` DESC LIMIT 8");
        while ($t = $query -> fetch()) {
                
                // 
                $c_p = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`id_t`='" . $t['id'] . "') " . (isset ($us) ? ($us['level']>0 ? '' : 'AND (`del`=\'0\')') : 'AND (`del`=\'0\')'));
                
                echo '<div class="raz"><img src="/design/' . ($t['top']==1? 'prikrep' : ($t['type']==0 ? 'closed' : 'the')) . '.png" alt=""/> <a href="/forum/thema' . $t['id'] . '">' . $t['name'] . '</a><span class="c"> (' . $c_p.') <a href="/forum/thema' . $t['id'] . '/page' . ceil ( $c_p / 10 ) . '">>>
</a></span></div>';
        
        }

}
else {
        echo '<div class="list1">Тем пока нет..</div>';
}

echo '</div>';

// Загруз-центр
echo '</div>';
echo '<div class="menu2"><a href="/zc" style="color:white;">Загруз-центр</a> (' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`dop`='da')") . '/<font color="red">+' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`dop`='da') AND (`time`>'" . (time()-86400) . "')") . '</font>)</div>';
echo '<div class="ram">';
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`dop`='da')") != 0) {
$query = DB :: $dbs -> query ("SELECT * FROM `zc_f` WHERE (`dop`='da') ORDER BY `id` DESC LIMIT 6");

while ($f = $query -> fetch ()) {
echo '<div class="raz">' . fName ($f['id']) . ' (' . sizef ($f['size']) . ')</div>';
} 
}

 else {
        echo '<div class="list1">Файлов пока нет..</div>';
}
               
  
// 
        $g_n = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `code`");
        echo '<div class="menu3"><a href="/code.php" style="color:white;">Полезные коды</a> (' . $g_n . ')
</div>';
        if ($g_n != 0) {
                $query = DB :: $dbs -> query ("SELECT * FROM `code` ORDER BY `id` DESC LIMIT 5");
                while ($news = $query -> fetch ()) {
                        echo '<div class="raz"><img src=" http://profiwm.ru/styles/1/core/ups.png" alt=""/> <a href="code.php?act=source&id=' . $news['id'] . '&r=' . $news['id_r'] . '">' . $news['name'] . '</a></div>';
                }
        }
        else {
                echo '<div class="list1">Кодов нет..</div>';
        }
     

        // 
        $g_n = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `gazeta`");
        echo '<div class="menu2"><a href="/gazeta.php" style="color:white;">Газета</a> (' . $g_n . ')</div>';
        if ($g_n != 0) {
                $query = DB :: $dbs -> query ("SELECT * FROM `gazeta` ORDER BY `id` DESC LIMIT 5");
                while ($news = $query -> fetch ()) {
                        echo '<div class="raz"><img src="../styles/snowy/image/ind.png" alt="*">  <a href="/gazeta.php?mod=read&id=' . $news['id'] . '&r=' . $news['id_r'] . '">' . $news['name'] . '</a> </div>';
                }
        }
        else {
                echo '<div class="list1">Газета пуста..</div>';
        }
//
echo '<div class="menu3">Wap мастеру </div>';
echo '<div class="raz"><a href="/srv"> <img src="../styles/snowy/image/ind.png" alt="*"> Сервисы сайта<font color=#ff0000></font></a></div>';
echo '<div class="raz"><a href="/wminfo.php"> <img src="../styles/snowy/image/ind.png" alt="*">  WM Справочник</a></div>';
echo '<div class="raz"><a href="/php_lsn"> <img src="../styles/snowy/image/ind.png" alt="*">  Учебник PHP</a></div>';
echo '<div class="menu2">Меню сайта</div>';
echo '<div class="raz"><a href="mosh.php"><img src="../styles/snowy/image/ind.png" alt="*"> База мошенников </a></div>';
echo '<div class="raz"><a href="/masters.php"> <img src="../styles/snowy/image/ind.png" alt="*">  Пользователи (' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `us`") . ') </a></div>';
echo '<div class="raz"><a href="stat.php?mod=adm"><img src="../styles/snowy/image/ind.png" alt="*"> Администрация  </a></div>';
echo '<div class="raz"><a href="rulles.php"> <img src="../styles/snowy/image/ind.png" alt="*"> Правила сайта</a></div>';
echo '<div class="raz"><a href="vip.php"> <img src="../styles/snowy/image/ind.png" alt="*"> Пользователи <img src="/images/menu/vip.png" alt="*"> </a></div>';
if (isset ($us)) {
        
        // 
        if (isset ($_GET['exit'])) {
        
                setcookie ('pass', '', time () - 1, '/');
                setcookie ('id',   '', time () - 1, '/');
           
                header ('location:/');
                }
        

}


echo '</div>';

F (); 