<?php
	@ob_start();
	include 'include/functions/header.php'; 
?>
<!DOCTYPE html>
<html lang="<?php print $language_code; ?>">
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title><?php print $site_title.' - '.$title; if($offline) print ' - '.$lang['server-offline']; ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		
		<link rel="stylesheet" type="text/css" href="<?php print $site_url; ?>css/style.min.css">
		<link rel="stylesheet" type="text/css" href="<?php print $site_url; ?>css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="<?php print $site_url; ?>css/bootstrap-table.css">
		
		<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&amp;display=swap" rel="stylesheet">
		<link href="<?php print $site_url; ?>css/font-awesome.min.css" rel="stylesheet" type="text/css">
		
		<link rel="shortcut icon" href="<?php print $site_url; ?>images/favicon.ico">
	
		<script src="https://www.google.com/recaptcha/api.js" async defer></script>
	</head>
	<body>
		<?php
			if($item_shop!="")
				$shop_url = $item_shop;
			else if(is_dir('shop')) 
				$shop_url = $site_url.'shop'; 
			else $shop_url = ''; 
		?>
		<header class="pixarts-header">
			<a href="<?php print $site_url; ?>" class="fake-logo"></a>
			<a href="<?php print $site_url; ?>" class="fake-pixarts"></a>
			
			<div class="pixarts-container">
				<div class="pixarts-nav">
					<ul class="l-menu">
						<li class="active"><a href="<?php print $site_url; ?>news"><?php print $lang['news']; ?></a></li>
						<?php if(!$database->is_loggedin()) { ?>
						<li><a href="<?php print $site_url; ?>users/register"><?php print $lang['register']; ?></a></li>
						<?php } else { ?>
						<li><a href="<?php print $site_url; ?>user/administration"><?php print $lang['account-data']; ?></a></li>
						<?php } ?>
						<li><a href="<?php print $site_url; ?>download"><?php print $lang['download']; ?></a></li>
					</ul>
					<ul class="r-menu">
						<li><a href="<?php print $site_url; ?>ranking/players"><?php print $lang['ranking']; ?></a></li>
						<li><a href="<?php print $shop_url; ?>" target="_blank">Shop</a></li>
						<li><a href="<?php print $social_links['discord']; ?>" target="_blank">Discord</a></li>
					</ul>
				</div>
			</div>
			
			
		
					
				<div class="flags-container m-5 p-2 text-center d-flex align-items-center">
				<ul class="list-inline p-0 m-0">
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=de"><img src="../img/theme/img/flags/de.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=en"><img src="../img/theme/img/flags/en.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=es"><img src="../img/theme/img/flags/es.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=fr"><img src="../img/theme/img/flags/fr.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=hu"><img src="../img/theme/img/flags/hu.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=it"><img src="../img/theme/img/flags/it.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=pl"><img src="../img/theme/img/flags/pl.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=pt"><img src="../img/theme/img/flags/pt.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=ro"><img src="../img/theme/img/flags/ro.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=tr"><img src="../img/theme/img/flags/tr.png" alt="" width="50"></a></li>
					<li class="list-inline-item flags"><a href="<?php print $site_url; ?>?lang=cz"><img src="../img/theme/img/flags/cz.png" alt="" width="50"></a></li>
				</ul>
			</div>			

		</header>
		
		
		
		<section class="pixarts-body">
			<div class="pixarts-container main">
				<div class="left-col">
					<div class="box-sm-v1">
						<div class="heading animv2">
							<h2><?php print $lang['user-panel']; ?></h2>
							<?php if(!$database->is_loggedin()) { ?>
							<div>
								<span></span>
								<a class="p-w-l" href="<?php print $site_url; ?>users/register" style="color:#0d6efd"><?php print $lang['register']; ?></a>
							</div>
							<?php } ?>
						</div>
						<div class="inner login-box">
							<?php if($offline || !$database->is_loggedin()) { ?>
							<form action="<?php print $site_url; ?>users/login" method="POST">
								<label class="username">
								<input type="text" name="username" pattern=".{5,64}" maxlength="64" placeholder="<?php print $lang['user-name']; ?>" autocomplete="off" <?php if($offline) print 'disabled'; else print 'required'; ?>>
								</label>
								<label class="password">
								<input type="password" name="password" pattern=".{5,16}" maxlength="16" placeholder="<?php print $lang['password']; ?>" <?php if($offline) print 'disabled'; else print 'required'; ?>>
								</label>
								<label class="checkbox">
									<div class="g-recaptcha" data-theme="light" data-sitekey="<?php print $site_key; ?>" style="border: solid 1px #2f2725;transform: scale(0.76);-webkit-transform: scale(0.86);transform-origin: 0 0;-webkit-transform-origin: 0 0;margin: 10px 0px -18px 0px;border-radius: 4px;"></div>
								</label>
								<td><button type="submit"><b><?php print $lang['login']; ?></b></button></td>
							</form>
							<div class="login-add">
								<div class="lane">
									<a href="<?php print $site_url; ?>users/lost" class="c-golden"><?php print $lang['forget-password']; ?></a>
								</div>
								<div class="lane">
									<span>No account yet? <a href="<?php print $site_url; ?>users/register" class="c-white">Create an account!</a></span>
								</div>
							</div>
							<?php } else { ?>
							<ul class="ranking">
								<?php if($web_admin) { ?>
								<li class="user-menu"><a href="<?php print $site_url; ?>admin"><?php print $lang['administration']; ?><?php if($web_admin>=9 && checkUpdate(officialVersion())) print ' <span class="tag tag-info tag-pill float-xs-right">'.$lang['update-available'].'</span>'; ?></a></li>
								<?php 
									if($web_admin>=$jsondataPrivileges['donate']) {
										$count_donations = count(get_donations());
										if($count_donations)
										{
								?>	
								<li class="user-menu"><a href="<?php print $site_url; ?>admin/donatelist"><?php print $lang['donatelist']; ?> <span class="tag tag-info tag-pill float-xs-right"><?php print $count_donations.' '.$lang['new-donations']; ?> </span></a></li>
								<?php
										}
									}
								}
								?>
								<li class="user-menu"><a href="<?php print $site_url; ?>user/administration"><?php print $lang['account-data']; ?></a></li>
								<li class="user-menu"><a href="<?php print $site_url; ?>user/characters"><?php print $lang['chars-list']; ?></a></li>
								<li class="user-menu"><a href="<?php print $site_url; ?>user/redeem"><?php print $lang['redeem-codes']; ?></a></li>
								<?php if($jsondataFunctions['active-referrals']) { ?>
								<li class="user-menu"><a href="<?php print $site_url; ?>user/referrals"><?php print $lang['referrals']; ?></a></li>
								<?php } if($item_shop!="") { ?>
								<li class="user-menu"><a target='_blank' href="<?php print $item_shop; ?>"><?php print $lang['item-shop']; ?></a></li>
								<?php }
									$vote4coins = file_get_contents('include/db/vote4coins.json');
									$vote4coins = json_decode($vote4coins, true);
									
									if(count($vote4coins))
										print '<li class="user-menu"><a href="'.$site_url.'user/vote4coins">Vote4Coins</a></li>';
									
									$donate = file_get_contents('include/db/donate.json');
									$donate = json_decode($donate, true);
									
									if(count($donate))
										print '<li class="user-menu"><a href="'.$site_url.'user/donate">'.$lang['donate'].'</a></li>';
								?>
								<li class="user-menu"><a class="logout" href="<?php print $site_url; ?>users/logout"><?php print $lang['logout']; ?></a></li>
							</ul>
							<?php } ?>
						</div>
					</div>
					<div class="box-sm-v1">
						<div class="heading animv1">
							<h2><?php print $lang['ranking'].' - '.$lang['players']; ?></h2>
							<div>
								<a class="p-w-l">Top 10</a>
							</div>
						</div>
						<div class="inner rank">
							<div class="pix-tab p-thead">
								<div class="order">#</div>
								<div class="username"><?php print $lang['name']; ?></div>
								<div class="kingdom"><?php print $lang['empire']; ?></div>
								<div class="level">Lv.</div>
							</div>
							<div class="pix-tab p-tbody">
								 <?php
                        if(!$offline) {
                        $top = array();
                        $top = top10players();
                        $i=1;
                        foreach($top as $player)
                        {
                            $empire=get_player_empire($player['account_id']); 
							
                    ?>
								<a class="lane">
																		<div class="order"><?php if($i==1) print '<img src="../img/theme/1.png" style="margin-left:-15px;">'; else if($i==2) print '<img src="../img/theme/2.png" style="margin-left:-15px;">'; else if($i==3) print '<img src="../img/theme/3.png" style="margin-left:-15px;">'; ?><?php if ($i >=4 ) print $i; ?></div>
									<div class="username"><?php print $player['name']; ?></div>
									<div class="kingdom <?php print emire_color($empire); ?>"><?php print emire_name($empire); ?></div>
									<div class="level">Lvl.<?php print $player['level']; ?></div>
								</a>
								 <?php $i++;}
                        }
                    ?>
							</div>
						</div>
						
					</div>
				</div>
				<div class="center-col">
					<?php if($page=='news' || $page=='') { ?>
					<div class="banner-main">
						<div class="slider" id="main-slider"><!-- outermost container element -->
	<div class="slider-wrapper"><!-- innermost wrapper element -->
		<img src="../img/theme/slider/banner-center-main-placeholder.png" alt="First" class="slide" /><!-- slides -->
		<img src="../img/theme/slider/banner-center-main-placeholder2.png" alt="Second" class="slide" />
		<img src="../img/theme/slider/banner-center-main-placeholder3.png" alt="Third" class="slide" />
	</div>
</div>	
					</div>
					<?php } ?>
					<div class="newsfeed">
						<?php include 'pages/'.$page.'.php'; ?>
					</div>
				</div>
				<div class="right-col">
					<div class="box-sm-v1">
						<div class="heading animv2">
							<h2>SERVER STATISTICS</h2>
							<div>
								<span></span>
								<a class="p-w-l"><?php print $site_title.''; if($offline) print ' - '.$lang['server-offline']; ?></a>
							</div>
						</div>
						<?php if(!$offline) { ?>
					<div class="inner stats-box">
					
					
							<?php include 'include/sidebar/statistics.php'; ?>
							
							
						</div>
						<?php } ?>
					</div>
					<div class="box-sm-v1">
						<div class="heading animv1">
							<h2><?php print $lang['ranking'].' - '.$lang['guilds']; ?></h2>
							<div>
								<a class="p-w-l">Top 10</a>
							</div>
						</div>
						<div class="inner rank">
							<div class="pix-tab p-thead">
								<div class="order">#</div>
								<div class="username"><?php print $lang['name']; ?></div>
								<div class="kingdom"><?php print $lang['empire']; ?></div>
								<div class="level"><?php print $lang['points']; ?></div>
							</div>
							<div class="pix-tab p-tbody">
								<?php
							if(!$offline) {
								$top = array();
								$top = top10guilds();
								
								$i=1;
								
								foreach($top as $guild)
								{
							?>
								<a class="lane">
									<div class="order"><?php if($i==1) print '<img src="../img/theme/1.png" style="margin-left:-15px;">'; else if($i==2) print '<img src="../img/theme/2.png" style="margin-left:-15px;">'; else if($i==3) print '<img src="../img/theme/3.png" style="margin-left:-15px;">'; ?><?php if ($i >=4 ) print $i; ?></div>
									<div class="username"><?php print $guild['name']; ?></div>
									<div class="kingdom <?php print emire_color($empire); ?>"><?php print emire_name($empire); ?></div>
									<div class="level"><?php print $guild['ladder_point']; ?></div>
								</a>
								<?php $i++; }
									}
								?>
							</div>
						</div>
						
					</div>
				</div>
			</div>
			<div class="pixarts-footer">
				<div class="pixarts-container">
					<div class="foot-foot">
						
						<div class="ownertag">
							<p> All rights reserved <b>&copy; <?php
										$copyright_year = date('Y');
										if($copyright_year > 2020)
											print '2020 - '.$copyright_year;
										else print $copyright_year;
								?></b> <a href="<?php print $site_url; ?>"><?php print $site_title; ?></a>. Powered by <a href="https://kabynode.ro/">KabyNode</a>.</p>
						</div>
						<div class="author">
							<span>Design &amp; implementation</span>
							<div class="tiptip">Game development studio</div>
							<a href="https://pixarts.net/"><img src="<?php print $site_url; ?>img/theme/pixarts-logo.png" alt="ValCode.Dev - Game Development"></a>
						</div>
					</div>
				</div>
			</div>
		</section>
		<script type="text/javascript" src="<?php print $site_url; ?>js/jquery-2.2.4.min.js"></script>
		<?php include 'include/functions/footer.php'; ?>
		<script src="<?php print $site_url; ?>js/tether.min.js"></script>
		<script src="<?php print $site_url; ?>js/bootstrap.min.js"></script>
		<script>
			var site_url = "<?php print $site_url; ?>";
		</script>
		
		<script>
			(function() {
	
	function Slideshow( element ) {
		this.el = document.querySelector( element );
		this.init();
	}
	
	Slideshow.prototype = {
		init: function() {
			this.wrapper = this.el.querySelector( ".slider-wrapper" );
			this.slides = this.el.querySelectorAll( ".slide" );
			this.previous = this.el.querySelector( ".slider-previous" );
			this.next = this.el.querySelector( ".slider-next" );
			this.index = 0;
			this.total = this.slides.length;
			this.timer = null;
			
			this.action();
			this.stopStart();	
		},
		_slideTo: function( slide ) {
			var currentSlide = this.slides[slide];
			currentSlide.style.opacity = 1;
			
			for( var i = 0; i < this.slides.length; i++ ) {
				var slide = this.slides[i];
				if( slide !== currentSlide ) {
					slide.style.opacity = 0;
				}
			}
		},
		action: function() {
			var self = this;
			self.timer = setInterval(function() {
				self.index++;
				if( self.index == self.slides.length ) {
					self.index = 0;
				}
				self._slideTo( self.index );
				
			}, 7000);
		},
		stopStart: function() {
			var self = this;
			self.el.addEventListener( "mouseover", function() {
				clearInterval( self.timer );
				self.timer = null;
				
			}, false);
			self.el.addEventListener( "mouseout", function() {
				self.action();
				
			}, false);
		}
		
		
	};
	
	document.addEventListener( "DOMContentLoaded", function() {
		
		var slider = new Slideshow( "#main-slider" );
		
	});
	
	
})();

		</script>
		
		<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous" type="86b91906db19f0b25c5b4b68-text/javascript"></script>
		<script src="<?php print $site_url; ?>js/main.js" type="86b91906db19f0b25c5b4b68-text/javascript"></script>
		<script src="https://ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js" data-cf-settings="86b91906db19f0b25c5b4b68-|49" defer=""></script>
	</body>
</html>