<?php
/*
	print "<?php\n";
	
	print '$loadavg = file("/proc/loadavg");';
	print '$loadavg = explode(" ",$loadavg[0]);';
	print '$loadavg = $loadavg[0];';
	print 'if ($loadavg>4) {echo "Sorry! Server load critical.";exit();}';
	
	print "?>\n";
*/
	
	print "<html>\n";
	include 'header.php';
	print "<body>\n";
		print "<center>\n";
		print "<table cellspacing='0' cellpadding='0' width='800' border='0'>\n";
				print "<tr><td>&nbsp;</td></tr>";				
				print "<tr>\n";					
					print "<td  width='300' align='center'><h2>#" . $XMLTEAM[$j]['team_data']['number'] . " - " . $XMLTEAM[$j]['team_data']['name'] . "</h2></td>\n";						
				print "</tr>\n";
				print "<tr>\n";
					print "<td class='standing_big_black'><a href='index.html'>Live standings</a></td>\n";
				print "</tr>\n";
		print "</table>\n";
		
		print "<hr class='standings_hr'>\n";
		
		print "<table cellspacing='2' cellpadding='2' border='1'>\n";
				print "<tr><td>Record</td><td>Lap</td><td>Laptime</td><td>Driver</td><td>Timestamp</td><td>Time since last log</td><td width=20>&nbsp;</td>
				<td>Record</td><td>Lap</td><td>Laptime</td><td>Driver</td><td>Timestamp</td><td>Time since last log</td></tr>";
				print "<tr><td valign='top'>\n";
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print $i . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print $XMLTEAM[$j]['raw_laps'][$i]['lap'] . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print normalTime($XMLTEAM[$j]['raw_laps'][$i]['laptime']) . "<br/>";
					
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print $XMLTEAM[$j]['raw_laps'][$i]['driverUserName'] . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print normalTime(($XMLTEAM[$j]['raw_laps'][$i]['logged'] - $XMLRACE['race_start'])*1000, false) . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
				{
					if (($i-1) > -1)
						print normalTime(($XMLTEAM[$j]['raw_laps'][$i]['logged'] - $XMLTEAM[$j]['raw_laps'][$i-1]['logged'])*1000, false) . "<br/>";
					else
						print "<br/>";
				}
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['raw_laps']); $i++)
					print "&nbsp;<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
					print $i . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
					print $XMLTEAM[$j]['filter_laps'][$i]['lap'] . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
					print normalTime($XMLTEAM[$j]['filter_laps'][$i]['laptime']) . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
					print $XMLTEAM[$j]['filter_laps'][$i]['driverUserName'] . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
					print normalTime(($XMLTEAM[$j]['filter_laps'][$i]['logged'] - $XMLRACE['race_start'])*1000, false) . "<br/>";
					
				print "</td><td valign='top'>";
					
				for ($i=0; $i < count ($XMLTEAM[$j]['filter_laps']); $i++)
				{
					if (($i-1) > -1)
						print normalTime(($XMLTEAM[$j]['filter_laps'][$i]['logged'] - $XMLTEAM[$j]['filter_laps'][$i-1]['logged'])*1000, false) . "<br/>";
					else
						print "<br/>";
				}
					
				print "</td></tr></table>";
					
			print "</center>\n";
		print "</body>\n";
	print "</html>\n";
?>