<?php
include_once ('./core/base.php');
falseauth();

$header = 'Рейтинг';
include_once ('./core/head.php');

$_GET['place'] = fl($_GET['place']);
$_GET['type'] = fl($_GET['type']);

echo '<div class="b"><div class="title">Рейтинг</div>';

switch($_GET['action']){

default:

echo '<center><div class="btn_small_pressed">Игроки</div> <a class="btn_small" href="/rating/clans/">Кланы</a></center>';

echo '<div class="line"></div>';

if($_GET['type'] == '') $_GET['type'] = 'exp';

echo '<center>';
if($_GET['type'] == 'exp') echo '<div class="btn_small_pressed"><small>Опытные</small></div> ';
else echo '<a class="btn_small" href="/rating/"><small>Опытные</small></a> ';
if($_GET['type'] == 'killers') echo '<div class="btn_small_pressed"><small>Истребители</small></div> ';
else echo '<a class="btn_small" href="/rating/killers/"><small>Истребители</small></a> ';
if($_GET['type'] == 'boss_killers') echo '<div class="btn_small_pressed"><small>Убийцы боссов</small></div> ';
else echo '<a class="btn_small" href="/rating/boss_killers/"><small>Убийцы боссов</small></a> ';
if($_GET['type'] == 'duels') echo '<div class="btn_small_pressed"><small>Дуэлянты</small></div> ';
else echo '<a class="btn_small" href="/rating/duels"><small>Дуэлянты</small></a> ';
echo '</center><br/>';

if($_GET['type'] == 'exp'){

$count = $base -> query("SELECT * FROM `users`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `users` ORDER BY `level` DESC LIMIT $start,10");
if($count > 0){
	$i = 0 + ($page * 10 - 10);
	while($r_user = $sql -> fetch_assoc()){
		$r_user_avatar = '/images/skins/'.$r_user['skin'].'_big.png';
		$i ++;
		echo '<a class="btn" href="/user/'.$r_user['id'].'/">'.$i.'. <img src="'.$r_user_avatar.'" width="24px;"> '.nolinkname($r_user['id']).' <img src="/images/icons/exp.png"><b>'.n_f($r_user['exp']).'</b></a>';
	}
	if($count > '10'){
		echo str('?',$k_page,$page);
	}
}else{
	echo '<br/><center>В данном рейтинге ещё нет игроков.</center><br/>';
}

}elseif($_GET['type'] == 'killers'){

$count = $base -> query("SELECT * FROM `users`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `users` ORDER BY `kills` DESC LIMIT $start,10");
if($count > 0){
	$i = 0 + ($page * 10 - 10);
	while($r_user = $sql -> fetch_assoc()){
		$r_user_avatar = '/images/skins/'.$r_user['skin'].'_big.png';
		$i ++;
		echo '<a class="btn" href="/user/'.$r_user['id'].'/">'.$i.'. <img src="'.$r_user_avatar.'" width="24px;"> '.nolinkname($r_user['id']).' <img src="/images/icons/skull.png"><b>'.n_f($r_user['kills']).'</b></a>';
	}
	if($count > '10'){
		echo str('?',$k_page,$page);
	}
}else{
	echo '<br/><center>В данном рейтинге ещё нет игроков.</center><br/>';
}

}elseif($_GET['type'] == 'boss_killers'){

$count = $base -> query("SELECT * FROM `users`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `users` ORDER BY `boss_kills` DESC LIMIT $start,10");
if($count > 0){
	$i = 0 + ($page * 10 - 10);
	while($r_user = $sql -> fetch_assoc()){
		$r_user_avatar = '/images/skins/'.$r_user['skin'].'_big.png';
		$i ++;
		echo '<a class="btn" href="/user/'.$r_user['id'].'/">'.$i.'. <img src="'.$r_user_avatar.'" width="24px;"> '.nolinkname($r_user['id']).' <img src="/images/icons/skeleton.png"><b>'.n_f($r_user['boss_kills']).'</b></a>';
	}
	if($count > '10'){
		echo str('?',$k_page,$page);
	}
}else{
	echo '<br/><center>В данном рейтинге ещё нет игроков.</center><br/>';
}

}elseif($_GET['type'] == 'duels'){

$count = $base -> query("SELECT * FROM `users`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `users` ORDER BY `duel_wins` DESC LIMIT $start,10");
if($count > 0){
	$i = 0 + ($page * 10 - 10);
	while($r_user = $sql -> fetch_assoc()){
		$r_user_avatar = '/images/skins/'.$r_user['skin'].'_big.png';
		$i ++;
		echo '<a class="btn" href="/user/'.$r_user['id'].'/">'.$i.'. <img src="'.$r_user_avatar.'" width="24px;"> '.nolinkname($r_user['id']).' <img src="/images/icons/duel.png"><b>'.n_f($r_user['duel_wins']).'</b></a>';
	}
	if($count > '10'){
		echo str('?',$k_page,$page);
	}
}else{
	echo '<br/><center>В данном рейтинге ещё нет игроков.</center><br/>';
}

}

break;

case 'clans':

echo '<center><a class="btn_small" href="/rating/">Игроки</a> <div class="btn_small_pressed">Кланы</div></center>';

echo '<div class="line"></div>';

$count = $base -> query("SELECT * FROM `clans`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `clans` ORDER BY `exp` DESC LIMIT $start,10");
if($count > 0){
	$i = 0 + ($page * 10 - 10);
	while($r_clan = $sql -> fetch_assoc()){
		$i ++;
		echo '<a class="btn" href="/clan/info/'.$r_clan['id'].'/">'.$i.'. <img src="/images/emblems/'.$r_clan['emblem'].'.png" width="24px">'.$r_clan['name'].' <small><font color="#B1B1B1">'.$r_clan['level'].' ур.</font></small></b></a>';
	}
	if($count > '10'){
		echo str('?',$k_page,$page);
	}
}else{
	echo '<br/><center>В данном рейтинге ещё нет кланов.</center><br/>';
}

break;

}

echo '<br/><a class="btn" href="/"><img src="/images/icons/back.png"> Назад</a>';

echo '</div>';

include_once ('./core/foot.php');
?>