<?php
define('NTLCMS', 1);
$module = 'banks';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница рейтинга по заработку - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
echo '<div class="title"><b>'.razd.' Рейтинг по заработку</b></div>';
$k_post = DB :: run() -> querySingle("select count(`id`) from `users` where `allprofit` <> '0'");
$k_page = k_page($k_post, $onpage); 
$page = page($k_page); 
$start = $onpage * $page - $onpage;
$sql = DB :: run() -> query("select (`login`), (`allprofit`) from `users` where `allprofit` <> '' and `id` <> '0' order by `allprofit` desc limit ".$start.", ".$onpage);
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Рейтинг по заработку пуст!</center></div>';
} else {
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
$usout = DB :: run() -> querySingle("select sum(`money`) from `payment` where `login` = ? and `status` = ?", array($row -> login, on));
echo '<div class="menu">'.ava($row -> login).' '.login($row -> login, 1).' <span class="count">'.money(round($row -> allprofit, 2)).'span></div>';
}
if ($k_page > 1) navigation(URL.'/rate_jmoney?', $k_page, $page);
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/rate">Рейтинги системы</a></div>';
include ('../system/foot.php');
?>