<?php

include './core.php';

if( !isset( $user ) || !$user->can_access( 'status' ) ) {
		
	
} else {
	if(isset($_REQUEST['order'])) {
		switch($_REQUEST['order']) {
			
		}
	} else {
		$order = 'name_spieler';
	}
		
	for($i=0;$i<=2;$i++) {
		list( $aktualisierung[$i] ) = $MySQL->query_first( "SELECT changed FROM server.serverstatus WHERE statusvariable = 1 AND server = $i ORDER BY changed DESC LIMIT 0,1");
		$spieler[$i] = $MySQL->fetch_complete( sprintf( "SELECT charid, charname, charsonline.accountid, accounts.name as accountname, x, y, z, charsonline.map, name_spieler, name_intern FROM (server.charsonline LEFT JOIN server.regionen ON charsonline.region_id = regionen.id) LEFT JOIN server.accounts ON charsonline.accountid = accounts.accountid WHERE server = $i ORDER BY %s, charname", $order));
		//$anzahl[$i] = count($players[$i]);
		$rufe[$i] = $MySQL->fetch_complete("SELECT callid, charid_accusator, charid, call_time, call_type, status, responsible, message, comment, map, x, y, z, visible FROM server.calls");
	}
	$Smarty->assign('aktualisierung', $aktualisierung);
	$Smarty->assign('spieler', $spieler);
	//$Smarty->assign('anzahl', $anzahl);
	
	$page['content'] = $Smarty->fetch( 'status.tpl' );
}

$Smarty->assign( 'page', $page );
$Smarty->display( 'main.tpl' );

?>