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

if(!defined('access') or !access) die();
include('inc/template.functions.php');

$disabledSidebar = array(
	'rankings',
);

$serverInfoCache = LoadCacheData('server_info.cache');
if(is_array($serverInfoCache)) {
	$srvInfo = explode("|", $serverInfoCache[1][0]);
}

$maxOnline = config('maximum_online', true);
$onlinePlayers = check_value($srvInfo[3]) ? $srvInfo[3] : 0;
$onlinePlayersPercent = check_value($maxOnline) ? $onlinePlayers*100/$maxOnline : 0;
?>
<html>
	<head>
	<meta charset="utf-8"/>
	<title>MU SeaSon 6</title>
	<meta name="generator" content="WebEngine <?php echo __WEBENGINE_VERSION__; ?>"/>
	<meta name="author" content="Lautaro Angelico"/>
	<meta name="description" content="<?php config('website_meta_description'); ?>"/>
	<meta name="keywords" content="<?php config('website_meta_keywords'); ?>"/>
	<meta property="og:type" content="website" />
	<meta property="og:title" content="<?php $handler->websiteTitle(); ?>" />
	<meta property="og:description" content="<?php config('website_meta_description'); ?>" />
	<meta property="og:image" content="<?php echo __PATH_IMG__; ?>webengine.jpg" />
	<meta property="og:url" content="<?php echo __BASE_URL__; ?>" />
	<meta property="og:site_name" content="<?php $handler->websiteTitle(); ?>" />
	<link rel="shortcut icon" href="<?php echo __PATH_TEMPLATE__; ?>favicon.ico"/>

	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>bootstrap.min.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>custom.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>font-awesome.min.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>style.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>swiper.min.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>bootstrap-select.min.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>flag-icon.min.css" rel="stylesheet" media="screen">		
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>jquery.growl.css" rel="stylesheet" media="screen">	
	
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>engine.css" rel="stylesheet" media="screen">	
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>profiles.css" rel="stylesheet" media="screen">
	<link href="<?php echo __PATH_TEMPLATE_CSS__; ?>castle-siege.css" rel="stylesheet" media="screen">
	
	<script src="<?php echo __PATH_TEMPLATE_JS__; ?>jquery-3.4.1.min.js"></script>
	<script>
		var baseUrl = '<?php echo __BASE_URL__; ?>';
	</script>			

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-178410892-1');
</script>

</head>
<body>
	<div class="smoke"></div>
	<div class="topPanel">
		<div class="topPanel-wrapper flex-s-c">
			<div class="btn2 buttonDrop" data-class="topMenu">
				<span></span>
				<span></span>
				<span></span>
			</div>
			
			<div class="topMenu">
					<?php templateBuildNavbar(); ?>
			</div>
			
			<?php if(isLoggedIn()) { ?>
			<a href="<?php echo __BASE_URL__; ?>usercp/myaccount" class="button"><?php echo lang('menu_txt_5'); ?></a>
			<a href="<?php echo __BASE_URL__; ?>logout" class="button"><?php echo lang('menu_txt_6'); ?></a>
			<?php } else { ?>
			<a href="#modal-login" class="button open_modal">Login</a>
			<?php } ?>
		</div>
	</div>
	
	<div class="wrapper_web">
    <header class="header_web">
			<!--serverBlock<a href="<?php echo __BASE_URL__; ?>" class="logo bright"><img src="<?php echo __PATH_TEMPLATE_IMG__; ?>logo16.png" alt="Logo"></a>-->

  
<div class="sparks sparks_1">
	<div class="spark_1"></div>
	<div class="spark_2"></div>
	<div class="spark_3"></div>
	<div class="spark_4 spark-big"></div>
	<div class="spark_5 spark-big"></div>
</div>
<div class="sparks sparks_2">
	<div class="spark_1"></div>
	<div class="spark_2"></div>
	<div class="spark_3"></div>
	<div class="spark_4 spark-big"></div>
	<div class="spark_5 spark-big"></div>
</div>
    
</header>
	<!-- .header-->	
	
		<div class="container_web">
		<aside class="left-sidebar">
	<a href="<?php echo __BASE_URL__; ?>downloads" class="download-button bright">
		<p>TẢI GAME</p>
		<span>Game PC</span>
	</a>
					<div class="serverBlock flex-c">
		<div>
			<div class="server-title">
				X500
			</div>
			<div class="server-progress">
				<span style="max-width: 100%;width: <?php echo number_format($onlinePlayers); ?>%;"></span>
			</div>
			<div class="server-online flex-s">
				Online: <span><?php echo number_format($onlinePlayers); ?></span>
			</div>
		</div>
	</div>
	<!--serverBlock-->
	
<div class="socBlock flex">
	<a href="<?php echo __BASE_URL__; ?>" class="flex-c">
		<div class="icon">
			<img src="<?php echo __PATH_TEMPLATE_IMG__; ?>fb-icon.png" alt="facebook">
		</div>
		Facebook
	</a>
	<a href="<?php echo __BASE_URL__; ?>" class="flex-c">
		<div class="icon">
			<img src="<?php echo __PATH_TEMPLATE_IMG__; ?>yt-icon.png" alt="youtube">
		</div>
		Youtube
	</a>
</div>

<?php if(isLoggedIn()) { ?>
<div class="block">
		<div class="blockTitle">
			<p>User Control Panel</p>
		</div>
	<br>
<?php			
	echo '<div class="panel panel-sidebar-usercp panel-usercp">';

		echo '<div class="panel-body">';
				templateBuildUsercp();
				echo '<br>';
			echo '<a class="button" href="'.__BASE_URL__.'logout">Logout</a>';
		echo '</div>';
	echo '</div>';
?>

</div>
<?php } ?>	
	
	
<div class="block">
	<div class="blockTitle">
		<p>Top Players</p> <span>Top anh hùng!</span>
	</div>
	<div id="topPlayersGroup">
	

<?php


// Top Level Players
$levelRankingData = LoadCacheData('rankings_gr.cache');
$charactersCountry = loadCache('character_country.cache');
$topLevelLimit = 15;
if(is_array($levelRankingData)) {
    $Character = new Character();
    $topLevel = array_slice($levelRankingData, 0, $topLevelLimit+1);
    echo '<div class="panel-sidebar-ranking">';
	
        echo '<div class="panel-body-ranking">';
            echo '<table class="table table-condensed">';
                echo '<tr>';
				    echo '<th>#</th>';
					echo '<th>Pais</th>';
                    echo '<th>Raza</th>';
                    echo '<th>Player</th>';
                    echo '<th class="text-center">G. Resets</th>';
                echo '</tr>';
                foreach($topLevel as $key => $row) {
                    if($key == 0) continue;
                    $characterIMG = $Character->GenerateCharacterClassAvatar($row[3],false,false);
                    echo '<tr>';
					    echo '<td>'. $key . '</td>';
						echo '<td><img src="'. getCountryFlag($charactersCountry[$row[0]]) .'" width="20px" height="auto"  /></td>';
                        echo '<td><img src="'.$characterIMG.'" width="20px" height="auto" class="rounded_corners_image" /></td>';
                        echo '<td>'.$row[0].'</td>';
                        echo '<td class="text-center">'.$row[1].'</td>';
                    echo '</tr>';
                }
            echo '</table>';
        echo '</div>';
    echo '</div>';
}


?>
	</div>
</div>
<!-- widget -->
   
<!-- Messenger Plugin chat Code -->
    <div id="fb-root"></div>

    <!-- Your Plugin chat code -->
    <div id="fb-customer-chat" class="fb-customerchat">
    </div>

    <script>
      var chatbox = document.getElementById('fb-customer-chat');
      chatbox.setAttribute("page_id", "432023187316520");
      chatbox.setAttribute("attribution", "biz_inbox");
    </script>

    <!-- Your SDK code -->
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          xfbml            : true,
          version          : 'v14.0'
        });
      };

      (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = 'https://connect.facebook.net/vi_VN/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>


<!-- widget -->

</aside>
<!-- left-sidebar -->


<main class="content">



<?php

	$handler->loadModule($_REQUEST['page'],$_REQUEST['subpage']);
	
?>

			
</main>
<aside class="right-sidebar">

	<div class="block">
	<div class="blockTitle">
		<p>Thông tin máy chủ</p> <span>Thống kê!</span>
	</div>
	<div id="topGuildsGroup">
	

<?php
// Server info block
if(is_array($srvInfo)) {
	echo '<div class="panel-sidebar-info">';
		echo '<div class="panel-body-info">';
			echo '<table class="table">';
				if(check_value(config('server_info_season', true))) echo '<tr><td>'.lang('sidebar_srvinfo_txt_6').'</td><td>'.config('server_info_season', true).'</td></tr>';
				if(check_value(config('server_info_exp', true))) echo '<tr><td>'.lang('sidebar_srvinfo_txt_7').'</td><td>'.config('server_info_exp', true).'</td></tr>';
				if(check_value(config('server_info_masterexp', true))) echo '<tr><td>'.lang('sidebar_srvinfo_txt_8').'</td><td>'.config('server_info_masterexp', true).'</td></tr>';
				if(check_value(config('server_info_drop', true))) echo '<tr><td>'.lang('sidebar_srvinfo_txt_9').'</td><td>'.config('server_info_drop', true).'</td></tr>';
				echo '<tr><td>'.lang('sidebar_srvinfo_txt_2').'</td><td style="font-weight:bold;">'.number_format($srvInfo[0]).'</td></tr>';
				echo '<tr><td>'.lang('sidebar_srvinfo_txt_3').'</td><td style="font-weight:bold;">'.number_format($srvInfo[1]).'</td></tr>';
				echo '<tr><td>'.lang('sidebar_srvinfo_txt_4').'</td><td style="font-weight:bold;">'.number_format($srvInfo[2]).'</td></tr>';
				if(check_value(config('maximum_online', true))) echo '<tr><td>'.lang('sidebar_srvinfo_txt_5').'</td><td style="color:#00aa00;font-weight:bold;">'.number_format($onlinePlayers).'</td></tr>';
			echo '</table>';
		echo '</div>';
	echo '</div>';
}
?>
</div>
</div>
<!-- widget -->

	<div class="block">
	<div class="blockTitle">
		<p>Castle Siegue</p> <span>Guild chiến thắng trong CTC!</span>
	</div>
	<div id="topGuildsGroup">
<?php
// Castle Siege Block
templateCastleSiegeWidget();
?>
</div>
</div>
<!-- widget -->


<div class="block">
	<div class="blockTitle">
		<p>Top Guilds</p> <span>The best guilds of server!</span>
	</div>
	<div id="topGuildsGroup">
<?php
// Top guilds
$GuildRankingData = LoadCacheData('rankings_guilds.cache');
$topGuildLimit = 10;
if(is_array($GuildRankingData)) {
$topGuild = array_slice($GuildRankingData, 0, $topGuildLimit+1);
    echo '<div class="panel-sidebar-ranking">';
	    echo'<div class="server-status-title2">';
    echo'</div>';
        echo '<div class="panel-body-ranking">';
            echo '<table class="table table-condensed">';
                echo '<tr>';
				    echo '<th>#</th>';
					echo '<th>Logo</th>';
                    echo '<th>Nombre</th>';
                    echo '<th>Score</th>';
                echo '</tr>';
                foreach($topGuild as $key => $row) {
                if($key == 0) continue;
                    //$characterIMG = $Character->GenerateCharacterClassAvatar($row[1],false,false);
                    echo '<tr>';
					    echo '<td>'. $key . '</td>';
						echo '<td>'.returnGuildLogo($row [3], 20).'</td>';
                        echo '<td>'.guildProfile($row[0]).'</td>';
                        echo '<td>'.number_format($row[2]).'</td>';
                    echo '</tr>';
                }
            echo '</table>';
        echo '</div>';
    echo '</div>';
}

?>	
 </div>  
</div>	

</aside>
<!-- right-sidebar -->	
</div>

<!-- .container-->
<footer class="footer">
	<div class="toTop"></div>
	<ul class="f-menu flex-c-c">
		<li><a href="<?php echo __BASE_URL__; ?>">Home</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>registration">Register</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>downloads">Download</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>rankings">Rankings</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>">Forum</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>support">Support</a></li>
		<li><a href="<?php echo __BASE_URL__; ?>about">About</a></li>
	</ul>
	<div class="f-logo flex-c-c">
		<a href=<?php echo __BASE_URL__; ?>"><img src="<?php echo __PATH_TEMPLATE_IMG__; ?>f-logo.png" alt=""></a>
	</div>
	<!--<div class="copy">
		Copyright 2021 &copy; AngelsMu.com
	</div>-->
</footer>
<!-- .footer -->
</div>
<!-- .wrapper -->
<div id="modal-login" class="modal_div"> 
	<div class="modal_close">
	</div>
	<!--modal_close-->
	<h1>Login</h1>
	<div class="modal-v">
		<form class="modalForm" id="login_form" method="post" action="<?php echo __BASE_URL__ . 'login'; ?>">
			<div class="formGroup">
				<span class="formGroup-name">Username</span>
				<input type="text" name="webengineLogin_user">
			</div>
			<div class="formGroup">
				<span class="formGroup-name">Password</span>
				<input type="password" name="webengineLogin_pwd">
			</div>
				<button name="webengineLogin_submit" type="submit" value="submit">LOGIN</button>
		</form>
	</div>
</div>
<div id="overlay2"></div>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>moment.min.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>moment.tz.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>paypal.js"></script>
<script>
	base_url = '<?php echo __BASE_URL__; ?>';
	template = 'king';
		server_events = {
    "Sheep Invasion": {
        "openText": true,
        "toOpen": 5,
        "days": 0,
        "times": [
            "00:00",
            "03:00",
            "06:00",
            "09:00",
            "12:00",
            "15:00",
            "18:00",
            "21:00"
        ]
    },
    "Kundun Invasion": {
        "openText": true,
        "toOpen": 5,
        "days": 0,
        "times": [
            "01:30",
            "04:30",
            "07:30",
            "10:30",
            "13:30",
            "16:30",
            "19:30",
            "22:30"
        ]
    },
    "Medusa invasion": {
        "openText": true,
        "toOpen": 5,
        "days": 0,
        "times": [
            "00:45",
            "12:45"
        ]
    },
    "Hellriser invasion": {
        "openText": true,
        "toOpen": 30,
        "days": [
            1,
            2
        ],
        "times": [
            "19:00"
        ]
    },
    "Ice Wind Walley": {
        "openText": true,
        "toOpen": 30,
        "days": [
            0
        ],
        "times": [
            "19:00"
        ]
    },
    "Castle Siege": {
        "openText": true,
        "toOpen": 30,
        "days": [
            6
        ],
        "times": [
            "19:00"
        ]
    }
}
		countdown = moment.tz('2021/02/19 17:00:00', 'YYYY-M-D H:m', 'Europe/Paris');
</script>

<script src="<?php echo __PATH_TEMPLATE_JS__; ?>jquery.countdown.min.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>swiper.min.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>bootstrap.min.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>bootstrap-select.min.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>jquery.growl.js"></script>
<script src="<?php echo __PATH_TEMPLATE_JS__; ?>custom.js"></script>


</body>

</html>