<?php
include_once '../settings.php';
$crapVarr = 'F@#&$^*FG^&F^#$&#&D$%%#$D%&$^%#&';
include_once "./../_init.php";
if(isset($_GET["token"]))$__TOKEN = $_GET["token"];
if ( $__TOKEN == 'ILoveAthensFiestaReallyBad' )
{
	echo '<h1>Top 50 guilds</h1>';
	$mssql_link = @mssql_connect("CYBER951-PC\SQLEXPRESS", "sa", "Test12345");
	if ( !$mssql_link )
	{
		showMessage( 'info,huhu');
	}
	else
	{
		$selectGuilds = mssql_query( "SELECT TOP 50 sName, nWarWinCount, nWarLoseCount FROM w00_character..tGuild" );
		$i = 1;
		echo "<table width=\"100%\">\n";
		echo '<tr>';
					echo '<td><font color=\"bluee\">#</td>';
					echo '<td><font color=\"bluee\">Name</td>';
					echo '<td><font color=\"bluee\">Gewonnen</td>';
					echo '<td><font color=\"bluee\">Verloren</td>';
					echo '<td><font color=\"bluee\">Durchschnitt</td>';
				echo '</tr>';
		while ( $guild = mssql_fetch_array( $selectGuilds ) )
		{
			$guild["sName"] = str_replace("ä", "&auml;", str_replace("Ä", "&Auml;", str_replace("ö", "&ouml;", str_replace("Ö", "&Ouml;", str_replace("ü", "&uuml;", str_replace("Ü", "&Uuml;", str_replace("ß", "&szlig;", $guild["sName"])))))));
			if($guild['nWarWinCount'] > 0)$average = round($guild['nWarWinCount'] / ($guild['nWarWinCount'] + $guild['nWarLoseCount']), 3)*100;
			else $average = 0;
			echo '<tr><td width="20px">'.$i.'</td><td>'.$guild['sName'].'</td><td>'.$guild['nWarWinCount'].'</td><td>'.$guild['nWarLoseCount'].'</td><td>'. $average ."%</td></tr>\n";
			$i++;
		}
		echo '</table>';
	}
}
?>