<?php
/**
 * WebEngine CMS
 * https://webenginecms.org/
 * 
 * @version 1.2.0
 * @author Lautaro Angelico <http://lautaroangelico.com/>
 * @copyright (c) 2013-2019 Lautaro Angelico, All Rights Reserved
 * 
 * Licensed under the MIT license
 * http://opensource.org/licenses/MIT
 */

# Login block
if(!isLoggedIn()) {
	echo '<div class="panel-user-cp">';
		echo '<div class="panel-title-cp">';
			echo ''.lang('module_titles_txt_2',true).'';
		echo '</div>';
		echo '<div class="panel-body">';
			echo '<form action="'.__BASE_URL__.'login" method="post">';
				echo '<div class="form-group-cp">';
					echo '<input type="text" class="form-control" id="loginBox1" name="webengineLogin_user" placeholder="User name" required>';
				echo '</div>';
				echo '<div class="form-group">';
					echo '<input type="password" class="form-control" id="loginBox2" name="webengineLogin_pwd" placeholder="Password" required>';
				echo '</div>';
				echo '<p class="flex-c-c">';
				echo '<button type="submit" name="webengineLogin_submit" value="submit" class="button-login ">'.lang('login_txt_3',true).'</button>';
				echo '</p>';
				echo'<p class="lost flex-c-c"><a style="color:#fff;" href="/home/forgotpassword">Quên Mật Khẩu</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a style="color:#fff;" href="/home/register">Đăng Ký</a></p>';
			echo '</form>';
		echo '</div>';
	echo '</div>';
}

# Usercp block
if(isLoggedIn()) {
	echo '<div class="panel-user-cp">';
	echo '<div class="panel-title-cp">';
		echo ''.lang('usercp_menu_title',true).'';
	echo '</div>';
		echo '<div class="user-cp-menu">';
				templateBuildUsercp();
		echo '</div>';
		echo'<p class="flex-c-c"><a href="'.__BASE_URL__.'logout" class="btn btn-primary" style="margin:15px 0;">logout</a></p>';
	echo '</div>';
	}

# Server info block
$srvInfoCache = LoadCacheData('server_info.cache');
if(is_array($srvInfoCache)) {
	$srvInfo = explode("|", $srvInfoCache[1][0]);
	
	echo '<div class="widget">';
		echo '<div class="widget-heading">';
			echo '<span class="widget-icon-left"></span>'.lang('sidebar_srvinfo_txt_1',true).'<span class="widget-icon-right"></span>';
		echo '</div>';
		echo '<div class="panel-body">';
			echo '<table class="widget-table">';
				
				/*echo '<tr><td style="color: #ffb400;">Version:</td><td>S12EP1</td></tr>';
				echo '<tr><td style="color: #ffb400;">Experience:</td><td>10x</td></tr>';
				echo '<tr><td style="color: #ffb400;">Drop:</td><td>20%</td></tr>';*/
				
				echo '<tr><td style="color: #ffb400;" >'.lang('sidebar_srvinfo_txt_2',true).' :</td><td style="font-weight:bold;">'.number_format($srvInfo[0]).'</td></tr>';
				echo '<tr><td style="color: #ffb400;">'.lang('sidebar_srvinfo_txt_3',true).' :</td><td style="font-weight:bold;">'.number_format($srvInfo[1]).'</td></tr>';
				echo '<tr><td style="color: #ffb400;">'.lang('sidebar_srvinfo_txt_4',true).' :</td><td style="font-weight:bold;">'.number_format($srvInfo[2]).'</td></tr>';
				echo '<tr><td style="color: #ffb400;">'.lang('sidebar_srvinfo_txt_5',true).' :</td><td style="color:#00aa00;font-weight:bold;">'.number_format($srvInfo[3]).'</td></tr>';
			echo '</table>';
		echo '</div>';
	echo '</div>';
}
# Top Level
$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">';
		echo '<div class="widget-heading">';
			echo '<span class="widget-icon-left"></span>'.lang('rankings_txt_1',true).'<span class="widget-icon-right"></span>';
        echo '</div>';
        echo '<div class="panel-body">';
            echo '<table class="widget-table table-condensed">';
                echo '<tr>';
					echo '<th style="color: #ffedc8;">#</th>';
					echo '<th style="color: #ffedc8;"></th>';
					echo '<th style="color: #ffedc8;"></th>';
                    echo '<th style="color: #ffedc8;">Player</th>';
                    echo '<th class="text-center" style="color: #ffedc8;">Level</th>';
                echo '</tr>';
				foreach($topReset as $key => $row) {
					if($key == 0) continue;
					echo '<tr>';
						echo '<td>'.$key.'.</td>';
						echo '<td><img src="'.getPlayerClassAvatar($row[1], false).'" width="20px" height="auto"/></td>';
                        echo '<td><img src="'.getCountryFlag($charactersCountry[$row[0]]).'" style="margin:0px 15px;"/></td>';
                        echo '<td>'.playerProfile($row[0]).'</td>';
                        echo '<td class="text-center">'.number_format($row[2]).'<sup style="color:red;">'.number_format($row[3]).'</sub></td>';
                    echo '</tr>';
                }
            echo '</table>';
        echo '</div>';
    echo '</div>';
}
# Top Level
/*$GuildRankingData = LoadCacheData('rankings_guilds.cache');
$topGuildLimit = 5;
if(is_array($GuildRankingData)) {
$topGuild = array_slice($GuildRankingData, 0, $topGuildLimit+1);
    echo '<div class="widget">';
		echo '<div class="widget-heading">';
			echo '<span class="widget-icon-left"></span>'.lang('rankings_txt_4',true).'<span class="widget-icon-right"></span>';
        echo '</div>';
        echo '<div class="panel-body">';
            echo '<table class="widget-table table-condensed">';
                echo '<tr>';
					echo '<th style="color: #ffedc8;">#</th>';
					echo '<th style="color: #ffedc8;">Mark</th>';
                    echo '<th style="color: #ffedc8;">Guild</th>';
                    echo '<th class="text-center" style="color: #ffedc8;">Score</th>';
                echo '</tr>';
				foreach($topGuild as $key => $row) {
					if($key == 0) continue;
					echo '<tr>';
						echo '<td>'.$key.'.</td>';
                        echo '<td>'.returnGuildLogo($row [3], 20).'</td>';
                        echo '<td>'.guildProfile($row[0]).'</td>';
                        echo '<td class="text-center">'.number_format($row[2]).'</sub></td>';
                    echo '</tr>';
                }
            echo '</table>';
        echo '</div>';
    echo '</div>';
}
#Castle Siegue
templateDisplayCSBanner();
# Shop Item
echo' <article class="mainShopWrap">';
	echo' <div class="scrollbtn">';
		echo' <button type="button" class="prev" onclick="bestitem.prev();"><span></span></button>';
		echo' <button type="button" class="next" onclick="bestitem.next();"><span></span></button>';
	echo' </div>';
	echo' <ul class="shopListConts" id="ShopItemList">';
		echo' <li class="item_content">';
			echo' <ul>';
				echo' <li class="icon"><span class="pngHot"></span></li>';
				echo' <li class="img"><img src="'.__PATH_TEMPLATE_IMG__.'shop/02.gif" alt=""></li>';
				echo' <li class="title">88,000 Goblin Point</li>';
				echo' <li class="wcoin">8000 Wcoin</li>';
				echo' <li class="shopBtn"><div class="alignCenterBtn"><a href="" class="btnStyle01" rel="">Comprar WC</a></div></li>';
			echo' </ul>';
		echo' </li>';
		echo' <li class="item_content">';
			echo' <ul>';
				echo' <li class="icon"><span class="pngNew"></span></li>';
				echo' <li class="img"><img src="'.__PATH_TEMPLATE_IMG__.'shop/01.gif" alt=""></li>';
				echo' <li class="title">[Master]BOOSTER Box 1</li>';
				echo' <li class="wcoin">800 Wcoin</li>';
				echo' <li class="shopBtn"><div class="alignCenterBtn"><a href="#" class="btnStyle01" rel="">Comprar WC</a></div></li>';
            echo' </ul>';
		echo' </li>';
		echo' <li class="item_content">';
			echo' <ul>';
				echo' <li class="icon"><span class="pngHot"></span></li>';
				echo' <li class="img"><img src="'.__PATH_TEMPLATE_IMG__.'shop/01.gif" alt=""></li>';
				echo' <li class="title">[Normal]BOOSTER Box 1</li>';
				echo' <li class="wcoin">800 Wcoin</li>';
				echo' <li class="shopBtn"><div class="alignCenterBtn"><a href="" class="btnStyle01" rel="">Comprar WC</a></div></li>';
			echo' </ul>';
		echo' </li>';
	echo' </ul>';
echo' </article>'; 
# Banners
echo '<div class="sideBannerCase">';
	echo'<ul class="rightbnr">';
		echo '<li>';
			echo '<a href="#" rel=""><img src="'.__PATH_TEMPLATE_IMG__.'banners/01.jpg" alt=""></a>';
		echo '</li>';
		echo '<li>';
			echo '<a href="#" rel=""><img src="'.__PATH_TEMPLATE_IMG__.'banners/02.jpg" alt=""></a>';
		echo '</li>';
		echo '<li>';
			echo '<a href="#" rel=""><img src="'.__PATH_TEMPLATE_IMG__.'banners/03.jpg" alt=""></a>';
		echo '</li>';
		echo '<li>';
			echo '<a href="#" rel=""><img src="'.__PATH_TEMPLATE_IMG__.'banners/04.jpg" alt=""></a>';
		echo '</li>';
		echo '<li>';
			echo '<a href="#" rel=""><img src="'.__PATH_TEMPLATE_IMG__.'banners/05.jpg" alt=""></a>';  
		echo '</li>'; 
	echo '</ul>';
echo '</div>'; */
# Fanpage
echo '<div class="panel-user-cp">';
	echo '<div class="panel-title-cp">';
		echo 'Facebook Fans';
	echo '</div>';
	$facebookPage = 'Awesome-MuOnline-959772257432600';
     echo '<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fhoiquanmu9x%2F&tabs=timeline&width=300&height=458&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" width="300" height="458" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>';
		echo '<ul class="mainSnsWrap">';
        echo '<li><a href="https://www.facebook.com/profile.php?id=100090443333922" target="_blank"><img src="'.__PATH_TEMPLATE_IMG__.'icon_main_sns_facebook.gif" alt="facebook"></a></li>';
        echo '<li><a href="#" target="_blank"><img src="'.__PATH_TEMPLATE_IMG__.'icon_main_sns_twitter.gif" alt="tweeter"></a></li>';
        echo '<li><a href="#" target="_blank"><img src="'.__PATH_TEMPLATE_IMG__.'icon_main_sns_youtube.gif" alt="youtube"></a></li>';
   	echo '</ul>';
echo '</div>';
