<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
	<title><?PHP echo $title; ?></title>
	
    <link rel="stylesheet" href="<?PHP echo $layout_name; ?>/_css/default.css" type="text/css" />
    <link rel="stylesheet" href="<?PHP echo $layout_name; ?>/_css/basic.css" type="text/css" />
	
	<meta name='keywords' content='tibia, 8.54, 8.6, gesior acc, modern acc, tfs, theforgottenserver, ots, open tibia server'>
	<meta name='description' content='The best Open Tibia Server what you see. Create account to day!'>
	
	<link rel="icon" href="<?PHP echo $layout_name; ?>/images/server.ico" type="image/x-icon">
	
	<meta name='author' content='Squidy & Bufo' />
	
    <?php echo $layout_header; ?>
	
	<script type=\"text/javascript\"><!--
	function show_hide(flip)
	{
		var tmp = document.getElementById(flip);
		if(tmp)
			tmp.style.display = tmp.style.display == 'none' ? '' : 'none';
	}
	--></script>
</head>
<!--//Queries//-->
<?PHP
	$lua = parse_ini_file($config['site']['server_path'].'/config.lua');
	$ip = explode("*", $lua['ip']);
	$port = explode("*", $lua['loginPort']);
	$motd = explode("*", $lua['motd']);
	$accounts = $SQL->query('SELECT COUNT(*) FROM `accounts` WHERE `id`>0;')->fetch();
	$players = $SQL->query('SELECT COUNT(*) FROM `players` WHERE `id`>0;')->fetch();
	$query = $SQL->query('SELECT `players`.`name`,`players`.`id`,`players`.`level`, `players`.`experience`, `server_motd`.`id`, `server_motd`.`text` FROM `players`,`server_motd` WHERE `players`.`group_id` < '.$config['site']['players_group_id_block'].' AND `players`.`name` != "Account Manager" ORDER BY `players`.`level` DESC, `players`.`experience` DESC, `server_motd`.`id` DESC LIMIT 1;')->fetch();
	$query2 = $SQL->query('SELECT `id`, `name` FROM `players` ORDER BY `id` DESC LIMIT 1;')->fetch();
	$banned = $SQL->query('SELECT COUNT(*) FROM `bans` WHERE `id`>0;')->fetch();
	$guilds = $SQL->query('SELECT COUNT(*) FROM `guilds` WHERE `id`>0;')->fetch();
?>
<!--//END Queries//-->
<body>
	<div id="top_bar">
		<?PHP
		if($config['status']['serverStatus_online'] == 1){
			echo '<div id="online"></div>';
		}else{
			echo '<div id="offline"></div>';}
		?>
	</div>
		<div id="logo-box"></div>
	<div id="bottom_bar">
		<div id="title">
			<?php echo $topic ?>
		</div>
	</div>
	
	<div id="page">
		<div id="cnt-box">
			<div id="cnt-container">
				<div id="cnt-left">
					<div id="bg_menu">
						<div id="menu">
							<div id="menu-top">&raquo; News &laquo;</div>
								<ul>
									<li><a href="?subtopic=latestnews">Latest News</a></li>
									<li class="last"><a href="?subtopic=archive">Archive</a></li>
								</ul>
							<div id="menu-top">&raquo; Account &laquo;</div>
								<ul>
									<?PHP
									if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
										echo '<li><a href="?subtopic=adminpanel">Admin Panel</a></li>';
									if($logged)
									{
										echo '<li><a href="?subtopic=accountmanagement">My Account</a></li>
										<li><a href="?subtopic=accountmanagement&action=logout">Logout</a></li>';
									}
									else
									{
										echo '<li><a href="?subtopic=accountmanagement">Login</a></li>';
									}
									?>
									<li><a href="?subtopic=createaccount">Create Account</b></a></li>
									<li><a href="?subtopic=lostaccount">Lost Account</a></li>
									<li class="last"><a href="?subtopic=tibiarules">Server Rules</a></li>
								</ul>
								
							<div id="menu-top">&raquo; Community &laquo;</div>
								<ul>
									<li><a href="?subtopic=characters">Search Player</a></li>
									<li><a href="?subtopic=guilds">Guilds</a></li>
									<li><a href="?subtopic=highscores">Highscores</a></li>
									<li><a href="?subtopic=killstatistics">Last Deaths</a></li>
									<li><a href="?subtopic=houses">Houses</a></li>
									<?PHP if(!empty($config['site']['forum_link'])) echo '<li><a href="'.$config['site']['forum_link'].'">Forum</a></li>'; ?>
									<li class="last"><a href="?subtopic=team">Game Masters</a></li>
								</ul>
								
							<div id="menu-top">&raquo; Library &laquo;</div>
								<ul>
									<li><a href="?subtopic=creatures">Monsters</a></li>
									<li><a href="?subtopic=spells">Spells</a></li>
									<li><a href="?subtopic=whoisonline">Who is online?</a></li>
									<?PHP if($config['site']['serverinfo_page'] == 1) echo '<li><a href="?subtopic=serverinfo">Server Info</a></li>'; ?>
									<?PHP if($config['site']['download_page'] == 1) echo '<li><a href="?subtopic=downloads">Downloads</a></li>'; ?>
									<?PHP if($config['site']['gallery_page'] == 1) echo '<li class="last"><a href="?subtopic=gallery">Gallery</a></li>'; ?>
								</ul>
								
							<?PHP
							if($config['site']['shop_system'] == 1)
							{
								echo '<div id="menu-top">&raquo; Shop &laquo;</div>
								<ul>
									<li><a href="?subtopic=buypoints"><b><font size="1" color="red"><blink>Buy Premium Points</blink></font></b></a></li>
									<li class="last"><a href="?subtopic=shopsystem">Shop Offer</a></li>';
									if($logged)
									echo '<li class="last"><a href="?subtopic=shopsystem&action=show_history">Shop History</a></li>';
								echo '</ul>';
							}
							?>
						</div>
					</div>
					<div id="menu-bottom">&nbsp;</div>
				</div>
				
				<div id="content-cnt" style="margin-bottom: 8px;">
					<div id="content-bg">
						<div id="status_box">
							<center>
								<table width="90%" align="center">
									<tr>
										<td><br/></td>
									</tr>
									
									<tr align="center">
										<td><span class="white"><a href="?subtopic=buypoints"><img src="<?PHP echo $layout_name; ?>/_img/content/donate.png"/></a></span></td>
										<td><span class="white"><a href="?subtopic=downloads"><img src="<?PHP echo $layout_name; ?>/_img/content/download.png"/></a></span></td>
									</tr>
									
									<tr align="center">
										<td>
											<span class="white">IP: </span><i><? echo $lua['ip'];?></i><br/>
											<span class="white">PORT: </span><i><? echo $lua['loginPort'];?></i><br/>
											<span class="white">TIBIA: </span><i>8.6</i>
										</td>
										<td>
											<span class="white">Players Online: </span><a href="?subtopic=whoisonline"><i><? echo $config['status']['serverStatus_players']; ?></i></a><br/>
											<span class="white">Server UpTime: </span><i><? echo $config['status']['serverStatus_uptime']; ?></i><br/>
											<span class="white">Monsters: </span><i><? echo $config['status']['serverStatus_monsters']; ?></i><br/>
										</td>
									</tr>
								</table>
								
								<br/>
								<span class="white">MOTD: </span><? echo $lua['motd'];?>
							</center>
							
						<div style="padding-top: 50px;"></div>
							<center>
								<table width="90%" align="center">
									<tr align="center">
										<td><b>Last joined us: </b><a href="?subtopic=characters&name=<? echo urlencode($query2['name']); ?>"><? echo $query2['name']; ?></a></td>
										<td> | </td>
										<td><b>Guilds in database: </b><? echo $guilds[0]?></td>
										<td> | </td>
										<td><b>Created Players: </b><? echo $players[0];?></td>
									</tr>
									
									<tr align="center">
										<td><b>Best Player: </b><a href="index.php?subtopic=characters&name=<? echo urlencode($query['name'])?>"><? echo $query['name'] ?></a> (<? echo urlencode($query['level'])?>)</td>
										<td> | </td>
										<td><b>Banned accounts: </b><? echo $banned[0] ?></td>
										<td> | </td>
										<td><b>Created Accounts: </b><? echo $accounts[0];?></td>
									</tr>
								</table>
							</center>
						</div>
						
							<br/>
							<div id="content-text">
								<?PHP echo $main_content; ?>
							</div>
					</div>
					<div id="fotter">
						Copyrights&nbsp;&copy;&nbsp;<script type="text/javascript">document.write((new Date).getFullYear());</script>&nbsp;&laquo; <?PHP echo $config['server']['serverName']; ?>&nbsp;&raquo; All Rights Reserved.
					</div>
				</div>
				
				<div id="cnt-left">
					<div id="bg_menu2">
						<div id="menu2">
							<div id="menu-top2">&raquo; Account &laquo;</div>
								<form method="post" action="?subtopic=accountmanagement">										
									<table width="176" border="0" align="center" cellpadding="0" cellspacing="0">
										<tr><td colspan="2"><input type="password" class="acc" name="account_login" SIZE="20" maxlength="20" ></td></tr>
										<tr><td colspan="2"><input type="password" class="pass" name="password_login" size="20" maxlength="29" ></td></tr>
										<tr>												
											<td>
												<input type="submit" name="Submit2" class="login" value="&nbsp;"/>
											</td>
											<td>
													<a href="?subtopic=createaccount"><b><font color="#4adbff">REGISTER</font></b></a><br/>
													<a href="?subtopic=lostaccount"><small><font color="#4adbff">Lost Account?</font></small></a>
											</td>
										</tr>
									</table>
								</form>
								
							<div id="menu-top2">&raquo; Top players &laquo;</div>
								<ul>
									<?php 
										$limitt = 5; 
										$zap = $SQL->query('SELECT `name`, `level` FROM `players` WHERE `group_id` < '.$config['site']['players_group_id_block'].' AND `name` != "Account Manager" ORDER BY `level` DESC, `experience` DESC LIMIT 5;'); 
										$number_of_rows = 0; 
										foreach($zap as $wynik) 
										{ 
										 $number_of_rows++; 
										 echo '<li><a href="index.php?subtopic=characters&name='.urlencode($wynik['name']).'" ><font color="green">'.$number_of_rows.'.</font> '.$wynik['name'].' <br/><small><font color="white">Level: ('.$wynik['level'].')</font></small><br/></a></li>'; 
										} 
									?>
								</ul>
								
							<div id="menu-top2">&raquo; Top guilds &laquo;</div>
								<ul>
									<?
										foreach($SQL->query('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`,
											`g`.`logo_gfx_name` AS `logo`, COUNT(`g`.`name`) as `frags`
										FROM `killers` k
											LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
											LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id`
											LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id`
											LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id`
										WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1
											GROUP BY `name`
											ORDER BY `frags` DESC, `name` ASC
											LIMIT 0, 5;') as $guild)
										echo '<li><a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '">' . $guild['name'] . '&nbsp;&nbsp;&nbsp;(' . $guild['frags'] . ' kills)</a></li>';
									?>
								</ul>
						</div>
					</div>
					<div id="menu-bottom2">&nbsp;</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>