<?php
define('NTLCMS', 1);
$module = 'cabinet';
include ('system/start.php');
include ('system/function.php');
include ('system/antidos.php');
$page_title = 'Кабинет - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('system/head.php');
?>
<script>
setInterval(function(){ 
$('#time').load('cabinet #time'); 
}, 1000); 
</script><?php 
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
echo '<div class="title"><b>'.razd.' Baши дaнныe </b></div>';
if ($_USER['balans'] >= $set['mincost']){
$pay = '<i class="fa fa-rub fa-fw"></i>';
}
$inputlog = DB :: run() -> querySingle("select count(`id`) from `auth` where `login` = ?", array($ulogin));
$mymail = DB :: run() -> querySingle("select count(`id`) from `message` where `komy` = ?", array($ulogin));
$mynotice = DB :: run() -> querySingle("select count(`id`) from `notice` where `to` = ?", array($ulogin));
$acttask = DB :: run() -> querySingle("select count(`id`) from `jobs` where `done` = '0' and `accept` = '1'"); 
$best_today_count = DB :: run() -> querySingle("select count(`id`) from `users` where `click_day` <> '' and `id` <> '0'");
echo '<div class="menu2">
<center><i class="fa  fa-bookmark-o fa-fw"></i> '.hello(TIME + ($_USER['times']) * 3600).', <b>'.$ulogin.'</b> <i class="fa  fa-bookmark-o fa-fw"></i></center>
<table border="0"><tr><td>';
if ($_USER['avatar'] == '0'){
echo '<figure class="imgteaser"><img src="'.URL.'/style/icons/noavatar.gif" alt="*" style=" width: 90px; height: 90px; border-radius: 3%;"></figure>';
} else {
echo '<figure class="imgteaser"><img src="'.URL.'/avatars/'.$ulogin.'.jpg" alt="*" style=" width: 90px; height: 90px; border-radius: 30%;"></figure>';
}
echo '</td><td>
&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa   fa-caret-right fa-fw"></i>  Баланс: '.money(round($_USER['balans'], 4)).' '.$pay.'<br/>
&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa   fa-caret-right fa-fw"></i> Банк кр.: <a href="'.URL.'/bank">'.coins(round($_USER['bank'], 2)).'</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa   fa-caret-right fa-fw"></i> Актив кр.: '.coins(round($_USER['credit'], 2)).'<br/>
&nbsp;&nbsp;&nbsp;&nbsp; <i class="fa fa-power-off fa-fw"></i> <a href="'.URL.'/exit"><span style="color:red"> Выход </span></a><br/>
</td></tr></table></div>';
$inpayment = DB :: run() -> querySingle("select count(`id`) from `inmoney`");
$outpayment = DB :: run() -> querySingle("select count(`id`) from `payment` where `status` = ?", array('moder'));
$sitemod = DB :: run() -> querySingle("select count(`id`) from `sites` where `status` = ?", array(2));
$modspam = DB :: run() -> querySingle("select count(`id`) from `spam` where `status` = ?", array(1));
if ($_USER['admin'] == '1'){
echo '<div class="title"><b>'.razd.' Уведомления</b></div>';
echo'<div class="uved"><table style="width:100%" cellspacing="0" cellpadding="15"><tbody><tr>';
if ($inpayment > 0) echo '<td style="vertical-align:top;width:10%;"><center><a href="'.URL.'/_deposit" title="Просят ввод средств">Ввод <b>'.money($inpayment).'</b></a></center></td>';
if ($outpayment > 0) echo '<td style="vertical-align:top;width:10%;"><center><a href="'.URL.'/_withdrawal" title="Просят вывод средств" > <span style="color:red">Вывод</span> <b>'.money($outpayment).'</b></a></center></td>';
if ($sitemod > 0) echo '<td style="vertical-align:top;width:10%;"><center><a href="'.URL.'/_modsites" title="Модерация сайтов" > <span style="color:red">Модерация сайтов</span> <b>'.$sitemod.'</b></a></center></td>';
if ($modspam > 0) echo '<td style="vertical-align:top;width:10%;"><center><a href="'.URL.'/modmailing" title="Модерация рассылок" > <span style="color:red">Модерация рассылок</span> <b>'.$modspam.'</b></a> </center></td>';
echo'</tr></tbody></table></div>';	
}
if ($_USER['admin'] == '1'){   
echo '<div class="menu"><i class="fa  fa-cogs fa-fw"></i> <a href="'.URL.'/_control">Админ-Панель</a> <span class="count">'.($set['close'] == '1' ? 'Клуб закрыт!' : 'Клуб открыт!').'</span></div>';		
}
if ($_USER['admin'] == '2'){   
echo '<div class="title"><b>'.razd.' Уведомления</b></div>';
echo '<div class="menu"><i class="fa  fa-cogs fa-fw"></i> <a href="'.URL.'/mpanel">Модер-Панель</a> <span class="count">'.($set['close'] == '1' ? 'Клуб закрыт!' : 'Клуб открыт!').'</span></div>';		
}
$mysites = DB :: run() -> querySingle("select count(`id`) from `sites` where `login` = ?", array($ulogin));
if ($_USER['admin'] == '2'){
echo'<div class="uved"><table style="width:100%" cellspacing="0" cellpadding="0"><tbody><tr>';
if ($sitemod > 0) echo '<td style="vertical-align:top;width:10%;"><center><a href="'.URL.'/_mmodsites" title="Модерация сайтов" > Модерация сайтов <b>'.$sitemod.'</b></a></center></td>';
echo'</tr></tbody></table></div>';	
}
$news_count = NEWS();
echo '<div class="title"><b>'.razd.' Новости</b></div>';
echo '<div class="menu"><i class="fa fa-feed fa-fw"></i> <a href="'.URL.'/feed">Новости клуба</a> <span class="count">'.($news_count > 0 ? $news_count : 'Нет новостей').'</span></div>';
if ($_USER['news'] != '1'){
$sql = DB :: run() -> query("select * from `news` where `view` = ? order by `id` desc limit 1", array(1));
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<div class="menu"><i class="fa fa-file-text-o fa-fw"></i> <b>'.$row -> name.'</b> ['.date('d.m.Y', $row -> date).']<br/>';
echo '- '.outtext($row -> text, 1, 1, 1).'<br/>';
$comm = DB :: run() -> querySingle("select count(`id`) from `comment` where `pid` = ?", array($row -> id));
echo '- <a href="'.URL.'/feed_comment'.((int) $row -> id).'">Комментарии</a> ['.$comm.'] ';
echo '</div>';
} 
}
echo '<div class="title"><b>'.razd.' Общение</b></div>';
echo '<div class="menu"><i class="fa fa-comments-o fa-fw"></i> <a href="'.URL.'/chats">Беседка</a> <span style="color:red"><sup>'.CHATS().'</sup></span><span style="color:blue"><sup> ( '.CHAT_ONLINE().' чел. ) </sup></span><span class="count">'.money($set['paychat']).'</span></div>';
echo '<div class="menu"><i class="fa fa-bullhorn fa-fw"></i> <a href="'.URL.'/responses">Ваши отзывы</a> <span style="color:green"><sup> '.REVIEWS().'</sup></span><span class="count">'.money($set['payrev']).'</span></div>';
echo '<div class="title"><b>'.razd.' Операции с кредитами</b></div>';
echo '<div class="menu"><i class="fa fa-chain fa-fw"></i> <a href="'.URL.'/site_list">Просмотр ссылок</a> <span class="count">'.COUNTLINK().'</span></div>';
echo '<div class="menu"><i class="fa fa-gg fa-fw"></i> <a href="'.URL.'/site"> Ваши площадки</a> <span class="count">'.$mysites.'/'.($set['maxsite']).'</span></div>';
echo '<div class="menu"><i class="fa fa-envelope-open-o fa-fw"></i> <a href="'.URL.'/mailing">Рассылка писем</a> <span class="count">'.money(ints($set['costspam'])).' '.$pay.'</span></div>';
echo '<div class="menu"><i class="fa fa-shopping-basket fa-fw"></i> <a href="'.URL.'/exchanges">Биржа кредитов</a> <span class="count">'.EXCHANGES().'</span></div>';
echo '<div class="menu"><i class="fa fa-futbol-o fa-fw"></i> 
 <a href="'.URL.'/games">Развлечения</a> <span class="count">1</span></div> ';
echo '<div class="menu"><i class="fa fa-users fa-fw" aria-hidden="true"></i> <a href="'.URL.'/task">Задания</a> <span class="count">'.$acttask.'</span></div>';
$acttask = DB :: run() -> querySingle("select count(`id`) from `jobs` where `done` = '0' and `accept` = '1'");
echo '<div class="title"><b><i class="fa fa-angle-double-right fa-fw"></i> Кликун дня</b></div><div class="menu"><i class="fa fa-line-chart fa-fw"></i> <a href="/dayrate">Лучшие сегодня</a> <span class="count">'.$best_today_count.'</span></div>';
include 'linkrek.php';
echo '<div class="title"><b>'.razd.' Дополнительно</b></div>';
echo '<div class="menu"><i class="fa fa-question-circle fa-fw"></i> <a href="'.URL.'/help">Информация</a> <span class="count">4</span></div>';
echo '<div class="menu"><i class="fa fa-bar-chart-o fa-fw"></i> <a href="'.URL.'/stat">Статистика клуба</a> <span class="count">2</span></div>';
include ('system/foot.php');
?>