<?php
header('Content-type: text/html; charset=utf-8');
$template = '
<!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" class="inner"><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
<title>'.$PRETITLE.' - '.$lang_lastrounds.'</title>

<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">

<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/two-tiers.css">
<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/nt.css">
<link rel="stylesheet" type="text/css" media="print" href="'.$ROOT.'css/print.css">
<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/default.css">

<script type="text/javascript">/* no frames */ if(top.location != self.location) top.location.replace(self.location);</script>
<script type="text/javascript" src="'.$ROOT.'js/nt2.js"></script></head><body class="inner">

<div id="page-1">
	<div id="page-2">

	<h1 id="page-title">'.$lang_lastrounds.'</h1>

	<div id="page-3">

		<ul id="navitems">
			<li>|<a href="'.$ROOT.'">'.$lang_main.'</a>|</li>
            <li><a href="'.$ROOT.'/forum">'.$lang_forum.'</a>|</li>
            <li><a href="'.$ROOT.'?go=stats">'.$lang_top.'</a>|</li>
            <li><a href="'.$ROOT.'?go=currentranking">'.$lang_currentranking.'</a>|</li>
            <li><a href="'.$ROOT.'?go=lastrounds">'.$lang_lastrounds.'</a>|</li>
            <li><a href="'.$ROOT.'?go=banlist">'.$lang_banlist.'</a>|</li>
            <li><a href="'.$ROOT.'monitor.php">'.$lang_monetor.'</a>|</li>
			<li><a href="'.$ROOT.'?go=faq">'.$lang_faq.'</a>|</li>
            <li><a href="'.$ROOT.'?go=ubar">'.$lang_UBAR.'</a>|</li>
			<li><a href="http://wiki.bf2s.com/">'.$lang_Wiki.'</a>|</li>
		</ul>
		
		<form action="'.$ROOT.'?go=search" method="post" id="getstats">
			<label for="pid">'.$lang_search.':</label>
			<input type="text" name="searchvalue" id="pid" value="" />
			<input type="submit" class="btn" value="Go" />
		</form>

<br />';

	$template .= '
		<table width=99% id="lastrounds" class="stat sortable" border="0" cellpadding="0" cellspacing="0">
			<tbody><tr>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastdate.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Map.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastserv.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastPlayers.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastResult.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastduration.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
			</tr>
	<tr>';
		for ($i=0; $i<=count($lastrounds)-1; $i++){
//$lastrounds[$i]['name'] = preg_replace("/>/","&gt;",$lastrounds[$i]['name']);
//$lastrounds[$i]['name'] = preg_replace("/</","&lt;",$lastrounds[$i]['name']);
if ($lastrounds[$i]['tickets1'] > $lastrounds[$i]['tickets2']) {$lastrounds[$i]['tickets1'] = "<b>".$lastrounds[$i]['tickets1']."</b>";}
if ($lastrounds[$i]['tickets2'] > $lastrounds[$i]['tickets1']) {$lastrounds[$i]['tickets2'] = "<b>".$lastrounds[$i]['tickets2']."</b>";}
    $lastrounds[$i]['sum']  = $lastrounds[$i]['pids1'] + $lastrounds[$i]['pids2'];
    $lastrounds[$i]['sum_end']  = $lastrounds[$i]['pids1_end'] + $lastrounds[$i]['pids2_end'];
    $lastrounds[$i]['mapsize'] = "32";
    if ($lastrounds[$i]['sum'] < 17 ) {$lastrounds[$i]['mapsize'] = "16";}
    if ($lastrounds[$i]['sum'] > 38 ) {$lastrounds[$i]['mapsize'] = "64";}
    if ($lastrounds[$i]['team1'] > 12) {$lastrounds[$i]['team1'] = 404;}
    if ($lastrounds[$i]['team2'] > 12) {$lastrounds[$i]['team2'] = 404;}
    $lastrounds[$i]['mapname'] = $lastrounds[$i]['name'];
	$lastrounds[$i]['name'] = str_replace("_", " ", $lastrounds[$i]['name']);
	$lastrounds[$i]['name'] = preg_replace("/v(\d) (\d+)/i", "", $lastrounds[$i]['name']);
	$lastrounds[$i]['name'] = preg_replace("/(\d) (\d+)/i", "", $lastrounds[$i]['name']);
	$lastrounds[$i]['name'] = trim ($lastrounds[$i]['name']);
	$lastrounds[$i]['name'] = ucwords(strtolower($lastrounds[$i]['name']));
    if ($lastrounds[$i]['gameport'] == '16567'){$sservername = "<font color=#83FF61>Public</font>";} else {$sservername = "<font color=#FF5757>Private</font>";}
    //$rc = $lastrounds[$i]['timestamp'] + 60;
    //$rn = $lastrounds[$i]['timestamp'] + $lastrounds[$i]['time'] + 60;
	$template .= '
		<td><a href="?rid='.$lastrounds[$i]['rid'].'">'.date("Y-m-d H:i",$lastrounds[$i]['timestamp']).'</a></td>
		<td><div class="award-inline2" onMouseOver="show_mine(this);" onMouseOut="hide_mine(this);"><a href="?rid='.$lastrounds[$i]['rid'].'">'.$lastrounds[$i]['name'].'</a><div class="award-pop2 dir-left"><IMG SRC="maps/'.$lastrounds[$i]['name'].'.jpg" width=260 height=200 border=0 alt="'.$lastrounds[$i]['name'].' '.$lastrounds[$i]['mapsize'].'"></div></div></td>
		<td>'.$sservername.'</td>
		<td>'.$lastrounds[$i]['sum'].'/'.$lastrounds[$i]['mapsize'].'</td>
		<td><sup>'.$lastrounds[$i]['pids1'].'</sup><img src="'.$ROOT.'game-images/armies/'.$lastrounds[$i]['team1'].'.png" alt="Игроков: '.$lastrounds[$i]['pids1'].'" style="border: 0pt none ;"> '.$lastrounds[$i]['tickets1'].' : '.$lastrounds[$i]['tickets2'].' <img src="'.$ROOT.'game-images/armies/'.$lastrounds[$i]['team2'].'.png" alt="Игроков: '.$lastrounds[$i]['pids2'].'" style="border: 0pt none ;"><sup>'.$lastrounds[$i]['pids2'].'</sup></td>
		<td>'.intToTime($lastrounds[$i]['time']).'</td>
	</td></tr>';
		}
	$template .= '
			    </tbody></table>
	<!-- END OF RESULT TABLE -->';

$template .= '

	<!-- end content == footer below -->

	<hr class="clear">
    
    <div><!-- Language -->
        <form method="post" id="content">
            <select name="lang">
            <option value="ru">Russian</option>
            <option value="en">English</option>
            <option value="jp">Japanese</option>
            </select>
            <input type="submit" value="'.$lang_select.'" />
        </form>
    </div><!-- / Language -->
    
<div id="footer">'.$lang_footerLASTUPDATE.'. '.$lang_footerNEXTUPDATE.'.<br>
	'.$lang_footerPROCESSED.'.<br>
    '.$lang_copyrightProject.'<br/>
    <!-- Уважайте мою работу - не трогайте нижнюю строчку... (^ω^)/ -->
    '.$lang_copyrightBF2REW.'<br/>
    '.$lang_copyrightShark.'<br/></div>

</div>';
$template .= '</body></html>';
?>