<?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>
<head>
<title>'.$PRETITLE.' '.$ph[0]['pname'].' - '.$lang_titlelast2note.'</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/inner.css">
<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/footer.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"><img src="' . $ROOT . 'game-images/ranks/header/rank_' . $ph[0]['prank'] . '.png" alt="" />'.$ph[0]['pname'].'<span class=zvanie>'.$lang_titlelast2note.'</span></h1>

	<div id="page-3">

		<ul id="navitems">
			<li>|<a href="'.$ROOT.'">'.$lang_main.'</a>|</li>
            <li><a href="'.$ROOT.'?go=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.'?go=monitor">'.$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 width=120><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastdate.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th width=200><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_lastduration.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_lastScore.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Team.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Commander.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Kills.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Deaths.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
				<th><a href="#" class="sortheader" onclick="ts_resortTable(this);return false;">'.$lang_Army.'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a></th>
			</tr>
	<tr>';

		for ($i=0; $i<=count($ph)-2; $i++){
//$lastrounds[$i]['name'] = preg_replace("/>/","&gt;",$lastrounds[$i]['name']);
//$lastrounds[$i]['name'] = preg_replace("/</","&lt;",$lastrounds[$i]['name']);
if ($ph[$i]['tickets1'] > $ph[$i]['tickets2']) {$ph[$i]['tickets1'] = "<b>".$ph[$i]['tickets1']."</b>";}
if ($ph[$i]['tickets2'] > $ph[$i]['tickets1']) {$ph[$i]['tickets2'] = "<b>".$ph[$i]['tickets2']."</b>";}
    $ph[$i]['sum']  = $ph[$i]['pids1'] + $ph[$i]['pids2'];
    $ph[$i]['sum_end']  = $ph[$i]['pids1_end'] + $ph[$i]['pids2_end'];
    $ph[$i]['mapsize'] = "32";
    if ($ph[$i]['sum'] < 17 ) {$ph[$i]['mapsize'] = "16";}
    if ($ph[$i]['sum'] > 38 ) {$ph[$i]['mapsize'] = "64";}
    if ($ph[$i]['team1'] > 12) {$ph[$i]['team1'] = 404;}
    if ($ph[$i]['team2'] > 12) {$ph[$i]['team2'] = 404;}
    $ph[$i]['name'] = $ph[$i]['mapname'];
	$ph[$i]['name'] = str_replace("_", " ", $ph[$i]['name']);
	$ph[$i]['name'] = preg_replace("/v(\d) (\d+)/i", "", $ph[$i]['name']);
	$ph[$i]['name'] = preg_replace("/(\d) (\d+)/i", "", $ph[$i]['name']);
	$ph[$i]['name'] = trim ($ph[$i]['name']);
	$ph[$i]['name'] = ucwords(strtolower($ph[$i]['name']));
    if ($ph[$i]['gameport'] == '16567'){$sservername = "<font color=#83FF61>Public</font>";} else {$sservername = "<font color=#FF5757>Private</font>";}
    //$rc = $ph[$i]['timestamp'] + 60;
    //$rn = $ph[$i]['timestamp'] + $ph[$i]['time'] + 60;
	$template .= '
		<td><a href="?rid='.$ph[$i]['id'].'">'.date("Y-m-d H:i",$ph[$i]['timestamp']).'</a></td>
		<td><div class="award-inline2" onMouseOver="show_mine(this);" onMouseOut="hide_mine(this);"><a href="?rid='.$ph[$i]['id'].'">'.$ph[$i]['name'].'</a> ('.$ph[$i]['sum'].'/'.$ph[$i]['mapsize'].')<div class="award-pop2 dir-left"><IMG SRC="maps/'.$ph[$i]['name'].'.jpg" width=260 height=200 border=0 alt="'.$ph[$i]['name'].' '.$ph[$i]['mapsize'].'"></div></div></td>
		<td>'.$sservername.'</td>
		<td>'.intToTime($ph[$i]['phtime']).'</td>
		<td>'.$ph[$i]['phscore'].'</td>
		<td>'.$ph[$i]['phteamscore'].'</td>
		<td>'.$ph[$i]['phcmdscore'].'</td>
		<td>'.$ph[$i]['phkills'].'</td>
		<td>'.$ph[$i]['phdeaths'].'</td>
		<td><img src="'.$ROOT.'game-images/armies/'.$ph[$i]['pharmy'].'.png" style="border: 0pt none ;"></td>
	</td></tr>';
		}
	$template .= '
			    </tbody></table>
	<!-- END OF RESULT TABLE -->';

$template .= '

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

<div id="footer"><!-- footer -->
<div class="footer_mod">
    <div class="footer_mod_left"><!-- Language -->
        <form method="post" id="content">
            '.$lang_select.'
            <select name="lang">
            <option value="ru">Russian</option>
            <option value="en">English</option>
            <option value="jp">Japanese</option>
            </select>
            <input type="submit" value="'.$lang_selectsave.'" />
        </form>
    </div><!-- / Language -->
    <div class="footer_mod_right">
    <a href="#top">'.$UpPage.'</a><br/>
    <!--&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<br/>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp-->
    </div>
    <div class="footer_mod_center">'.$lang_footerLASTUPDATE.'. '.$lang_footerNEXTUPDATE.'.<br>
	'.$lang_footerPROCESSED.'.<br><br/>
    '.$lang_copyrightProject.'<br/>
    <!-- Уважайте мою работу - не трогайте нижнюю строчку... (^ω^)/ -->
    '.$lang_copyrightBF2REW.'<br/>
    '.$lang_copyrightShark.'<br/></div>
</div>
</div><!-- footer -->
    
</div>';
$template .= '</body></html>';
?>
