<?php
echo '<div class="widget-right">';
echo '	<div class="widget-title flex-c-c">';
echo '		<h2>TOP <span class="widget-title-small">SERVERS</span></h2>';
echo '	</div>';
echo '	<div class="widget-content">';
echo '		<div class="server">';
echo '			<div class="flex-c-c">';
echo '				<span class="server-name">' . config('server_name') . '</span>';

if (number_format($srvInfo[3]) == 0) {
	echo '				<div class="img-online" style="background-image: url(' . __PATH_TEMPLATE_IMG__ . '/offline.png); "></div>';
} else {
	echo '				<div class="img-online" style="background-image: url(' . __PATH_TEMPLATE_IMG__ . '/online.png); "></div>';
}
echo '			</div>';
echo '			<div class="progress-bar">';
echo '				<span style="width: ' . ($srvInfo[3] * 100) / $templateMaxOnline . '%;"></span>';
echo '			</div>';
echo '			<div class="status">' . lang('sidebar_srvinfo_txt_5') . ' ' . number_format($srvInfo[3]) . '</div>';
echo '		</div>';
echo '	</div>';
echo '</div>';
// Top Resets
$resetRankingData = LoadCacheData('rankings_resets.cache');
$charactersCountry = loadCache('character_country.cache');
$topResetLimit = 5;
if (is_array($resetRankingData)) {
	$topReset = array_slice($resetRankingData, 0, $topResetLimit + 1);
	echo '<div class="widget-right">';
	echo '<div class="widget-title flex-c-c">';
	echo '<h2 widget-title-small>' . lang('rankings_txt_2') . '</h2>';
	echo '</div>';
	echo '<div class="widget-content-content">';
	echo '	<ul class="top-block">';
	echo '		<li class="top-title">';
	echo '			<span class="top-number">#</span> <span class="top-flag"></span> 
					<span class="top-name">Name</span> 
					<span class="top-lvl">LvL</span> 
					<span class="top-Res">Res</span>';
	echo '		</li>';
	foreach ($topReset as $key => $row) {
		if ($key == 0) continue;
		echo '		<li class="top-list">';
		echo '			<span class="top-number">' . $key . '.</span> 
				<span class="top-flag"><img src="' . getCountryFlag($charactersCountry[$row[0]]) . '" alt=""></span> 
				<span class="top-name"><a href="" title="nickname">' . playerProfile($row[0]) . '</a></span> 
				<span class="top-lvl">' . number_format($row[3]) . '</span> 
				<span class="top-Res">' . number_format($row[2]) . '</span>';

		echo '		</li>';
	}

	echo '	</ul>';
	echo '	<div class="flex-c-c">';
	echo '		<a href="' . __BASE_URL__ . 'rankings" class="button-small flex-c-c">all players</a>';
	echo '	</div>';
	echo '</div>';
	echo '</div>';
}

// Top Guilds
$GuildRankingData = LoadCacheData('rankings_guilds.cache');
$topGuildLimit = 5;
if (is_array($GuildRankingData)) {
	$topGuild = array_slice($GuildRankingData, 0, $topGuildLimit + 1);
	echo '<div class="widget-right">';
	echo '    <div class="widget-title flex-c-c">';
	echo '        <h2>' . lang('rankings_txt_4') . '</h2>';
	echo '    </div>';
	echo '    <div class="widget-content-content">';
	echo '        <ul class="top-block guild">';
	echo '            <li class="top-title">';
	echo '                <span class="top-number">#</span>';
	echo '                <span class="top-name">Name</span>';
	echo '                <span class="score">Score</span>';
	echo '            </li>';
	foreach ($topGuild as $key => $row) {
		if ($key == 0) continue;
		echo '<li class="top-list">';
		echo '<span class="top-number">' . $key . '' . returnGuildLogo($row[3], 20) . '</span>';
		echo '<span class="top-name"><a href="" title="nickname">' . guildProfile($row[0]) . '</a></span>';
		echo '<span class="score">' . number_format($row[2]) . '</span>';
		echo '</li>';
	}
	echo '        </ul>';
	echo '    </div>';
	echo '</div>';
}
