<?php
//-----Создаем титл страницы-----//
$title = 'LigaWM.Ru Клуб IT-Разработчиков!';
//-----Подключаем функции-----//
require_once ('system/function.php');
//-----Выводим Логотип------//
echo '<div class="logo"><img src="/images/logo.png" alt="Логотип" title="Логотип" /></div>';
//-----Подключаем вверх-----//
require_once ('system/header.php');
//-----Выводим новости-----//

$count_news = mysql_result(mysql_query('select count(`id`) from `news`'),0);
if($user['news']!=$count_news)
{
echo '<div class="menu">
<a href="'.$HOME.'/news/">Новости</a> ('.$count_news.')<br /></div><div class="news">';
$sql = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
while($sql1 = mysql_fetch_assoc($sql))
{
echo ''.smile(bb($sql1['text'])).'<br />
Автор: '.nick($sql1['avtor']).'<br />
<a href="/news/comment'.$sql1['id'].'">Комментарии:</a> ('.mysql_result(mysql_query('select count(`id`) from `news_com` where `news` = "'.$sql1['id'].'"'),0).')';
if($user['id']) {
echo '<br /><a href="?news='.$sql1['id'].'">Скрыть новость</a>';}
if(isset($_GET['news']))
{
$news= trim(intval($_GET['news']));
 mysql_query("UPDATE `users` SET `news` = '".$news."' WHERE `id` = '".$user['id']."'");
header('Location: '.$HOME.'');
}
}
}else{
echo '<div class="menu">
<a href="'.$HOME.'/news/">Новости</a> ('.$count_news.')</div>';}
echo '</div></div>';
//-----Выводим форум-----//
$t_f = mysql_result(mysql_query('select count(`id`) from `forum_tema`'),0);
echo '<div class="menu"><a href="'.$HOME.'/forum/"> Форум</a> ('.$t_f.' / '.mysql_result(mysql_query('select count(`id`) from `forum_post`'),0).')(<font color="red"><b>+3'.mysql_result(mysql_query('select count(`id`) from `forum_tema` where `time` > "'.(time()-((60*60)*24)).'"'),0).'</b></font> / <font color="green"><b>+58'.mysql_result(mysql_query('select count(`id`) from `forum_post` where `time` > "'.(time()-((60*60)*24)).'"'),0).'</b></font>)</div>';
//последние темы форума
require_once ('system/new_tem.php');


//выводим файлы 
echo '<div class="title">';
echo '<a href="'.$HOME.'/down/"> Загрузки ('.mysql_result(mysql_query("SELECT COUNT(id) FROM `load_file`"),0).' <span style="color: #61b565"><b>+ '.mysql_result(mysql_query('select count(`id`) FROM `load_file` WHERE `time` > "'.(time()-((60*60)*24)).'"'),0).' </b></span></a>)';
  echo '</div>';

$file = mysql_result(mysql_query('select count(`id`) from `load_file`'),0); 
 if($file >= 1)
{
$file_t = mysql_query("SELECT * FROM `load_file` ORDER BY `time` DESC LIMIT 3");
 while($load = mysql_fetch_assoc($file_t))
{
echo '<div class="menudiv">';
echo '<a class="k_menu" href="'.$HOME.'/down/file'.$load['id'].'"><img src="'.$HOME.'/images/load/'.$load['format'].'.png" alt="*" /> '.$load['name'].' </a>';
echo '</div>';
}
}
else{
echo '<div class="podmenu"><center><b>Нет файлов</b></center></div>';
} 


echo '<a href="/m"><div class="menu"><font color="white"> Магазин ('.mysql_result(mysql_query('select count(`id`) from `m_tovar`'),0).')</font></div></a>';
$magaz = mysql_query('select * from `m_tovar` order by `time` desc limit 3');
while($a = mysql_fetch_array($magaz)){
$text = ''.$a['opis'].'';
$array = explode(" ", $text);
$text_num = array_slice($array, 0, 20);
$text_v = implode(" ", $text_num);
if(count($array) < 5){$text_v .= '...';}
echo'<div class="podmenu"><a href="/m/tovar'.$a['id'].'"> '.$a['name'].'</a><small> (<font color="green"><b>'.$a['rub'].'р.</b></font>)</small><hr/>Описание: '.$text_v.'<br/><br/></div>';

}

echo'<a href="/polz_kod/"><div class="menu"> Полезные коды ('.$pdo->query("SELECT COUNT(id) FROM `polz_stat`")->fetchColumn().')</div></a>';

$sql = $pdo->query("SELECT *
FROM `polz_stat` ORDER BY `id` DESC LIMIT
3");
while($a = $sql->fetch()){
echo'<div class="menudiv"><a href="/polz_kod/kod'.$a['id'].'" class="k_menu"><img src="'.$HOME.'/images/spiscod.png" alt="*" title="Коды" /> '.$a['name'].'</a></div>';}



//-----Выводим меню сайта-----//
echo '<div class="menu">Меню сайта:</div>';

echo '<div class="menudiv"><a href="'.$HOME.'/guest" class="k_menu"><img src="/images/chat.png" alt="Гостевая" title="Гостевая" /> Гостевая ('.mysql_result(mysql_query("SELECT COUNT(id) FROM `guest`"),0).')</div></a>
<div class="menudiv"><a href="'.$HOME.'/user.php" class="k_menu"><img src="/images/user.png" alt="Пользователи" title="Пользователи" /> Пользователи ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"),0).')</a></div>';
//-----Подключаем низ-----//
require_once ('system/footer.php');
?>

