<html>
<head><title>Battlefield 2 Server Query PHP Class</title></head>
<body bgcolor="#F5F5F5" marginwidth="0" marginheight="0"><br/>
<?
foreach($status['results']['players'] as $number=>$player)
foreach($player as $field=>$value)
$sorted[$field][$number]=$value;
array_multisort($sorted['team'],SORT_ASC,SORT_NUMERIC,
$sorted['score'],SORT_DESC,SORT_NUMERIC,
$sorted['skill'],SORT_DESC,SORT_NUMERIC,
$sorted['deaths'],SORT_ASC,SORT_NUMERIC,
$sorted['player'],
$sorted['pid'],
$sorted['ping']);
$teams[1]=array('players'=>null,'score'=>null,'kills'=>null,'deaths'=>null,'ping'=>null);
$teams[2]=array('players'=>null,'score'=>null,'kills'=>null,'deaths'=>null,'ping'=>null);
foreach($status['results']['players'] as $value)
{ $teams[$value['team']]['players']++;
$teams[$value['team']]['score']+=$value['score'];
$teams[$value['team']]['kills']+=$value['skill'];
$teams[$value['team']]['deaths']+=$value['deaths'];
$teams[$value['team']]['ping']+=$value['ping'];
}
?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr bgcolor="#CCCCCC">
<td><? if (!isset($status['results']) OR empty($status['results'])) { ?>
<table cellpadding="3" cellspacing="1" border="0" height="100%" width="100%">
<tr bgcolor="#EEEEEE">
<td height="26" background="images/newback.gif"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Unable to connect to the Battlefield 2 server. Server could be down or changing the map...</b></font></td>
</tr>
</table><? } else { ?>
<table cellpadding="3" cellspacing="1" border="0" height="100%" width="100%">
<tr bgcolor="#EEEEEE">
<td height="26" colspan="2" background="images/newback.gif"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b><?=$status['results']['server']['hostname']?></b></font></td>
</tr>
<tr bgcolor="#EEEEEE">
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Variable</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Value</b></font></td>
</tr><? foreach ($status['results']['server'] as $key => $value) { ?>
<tr bgcolor="#FFFFFF">
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$key?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$value?></b></font></td>
</tr><? } ?>
</table>
</td>
</tr>
</table>
<br/>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr bgcolor="#CCCCCC">
<td>
<table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%">
<tr>
<td width="50%">
<table align="center" border="0" cellpadding="3" cellspacing="1" width="100%">
<tr bgcolor="#EEEEEE"><td colspan="2" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Team 1</b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Players</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[1]['players']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Score</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[1]['score']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Kills</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[1]['kills']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Deaths</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[1]['deaths']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Average Ping</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=ceil($teams[1]['ping']/$teams[1]['players'])?></b></font></td></tr>
</table>
</td>
<td width="50%">
<table align="center" border="0" cellpadding="3" cellspacing="1" width="100%">
<tr bgcolor="#EEEEEE"><td colspan="2" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Team 2</b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Players</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[2]['players']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Score</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[2]['score']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Kills</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[2]['kills']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Deaths</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$teams[2]['deaths']?></b></font></td></tr>
<tr><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>Average Ping</b></font></td><td bgcolor="#FFFFFF" height="26"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=ceil($teams[2]['ping']/$teams[2]['players'])?></b></font></td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr bgcolor="#CCCCCC">
<td>
<? if (isset($status['results']['players'])) { ?>
<table cellpadding="3" cellspacing="1" border="0" height="100%" width="100%">
<tr bgcolor="#EEEEEE">
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>#</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Player</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Score</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Kills</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Deaths</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Team</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>PID</b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #003366; text-decoration: none; font-weight: bold;"><b>Ping</b></font></td>
</tr><? for($i=0; $i<count($sorted['player']); $i++) { if (empty($sorted['ping'][$i])) { ?>
<tr bgcolor="#FFFFFF">
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$i+1?></b></font></td>
<td align="center" colspan="7"><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b>CONNECTING</b></font></td>
</tr><? } else { ?>
<tr bgcolor="#FFFFFF">
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=($i+1)?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['player'][$i]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['score'][$i]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['skill'][$i]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['deaths'][$i]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$status['results']['teams']['team_t'][($sorted['team'][$i]-1)]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['pid'][$i]?></b></font></td>
<td><font style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: #006699; text-decoration: none; font-weight: bold;"><b><?=$sorted['ping'][$i]?></b></font></td>
</tr><? }} ?>
</table><? }} ?>
</td>
</tr>
</table>
<br/>
</body>
</html>
|