query("
		SELECT
			code,
			name
		FROM
			hlstats_Games
		WHERE
			hidden='0'
		ORDER BY
			realgame, name ASC
	");
	
	$num_games = $db->num_rows($resultGames);
	$redirect_to_game = 0;  
	
	if ($num_games == 1 || $game = valid_request($_GET['game'], 0)) {
		$redirect_to_game++;
		if ($num_games == 1) {
			list($game) = $db->fetch_row($resultGames);
		}
		
		include(PAGE_PATH . '/game.php');
	} else {
		unset($_SESSION['game']);
		
		pageHeader(array('Contents'), array('Contents' => ''));
		include(PAGE_PATH . '/voicecomm_serverlist.php');
		printSectionTitle('Games');
	?>
		
		
			
			
				
					| Game | Players | Top Player | Top Clan | 
				
fetch_row($resultGames))
		{
			$nonhiddengamestring .= "'$gamedata[0]',";
			$result = $db->query("
				SELECT
					playerId,
					lastName,
					activity
				FROM
					hlstats_Players
				WHERE
					game='$gamedata[0]'
					AND hideranking=0
				ORDER BY
					".$g_options['rankingtype']." DESC,
					(kills/IF(deaths=0,1,deaths)) DESC
				LIMIT 1
			");
		
			if ($db->num_rows($result) == 1)
			{
				$topplayer = $db->fetch_row($result);
			}
			else
			{
				$topplayer = false;
			}
					
			$result = $db->query("
				SELECT
					hlstats_Clans.clanId,
					hlstats_Clans.name,
					AVG(hlstats_Players.skill) AS skill,
					AVG(hlstats_Players.kills) AS kills,
					COUNT(hlstats_Players.playerId) AS numplayers
				FROM
					hlstats_Clans
				LEFT JOIN
					hlstats_Players
				ON
					hlstats_Players.clan = hlstats_Clans.clanId
				WHERE
					hlstats_Clans.game='$gamedata[0]'
					AND hlstats_Clans.hidden = 0
					AND hlstats_Players.hideranking=0
				GROUP BY
					hlstats_Clans.clanId
				HAVING
					".$g_options['rankingtype']." IS NOT NULL
					AND numplayers >= 3
				ORDER BY
					".$g_options['rankingtype']." DESC
				LIMIT 1
			");
			if ($db->num_rows($result) == 1)
			{
				$topclan = $db->fetch_row($result);
			}
			else
			{
				$topclan = false;
			}
			$result= $db->query("
				SELECT
					SUM(act_players) AS `act_players`,                                
					SUM(max_players) AS `max_players`
				FROM
					hlstats_Servers
				WHERE
					hlstats_Servers.game='$gamedata[0]'
			");
							
			$numplayers = $db->fetch_array($result);
			if ($numplayers['act_players'] == 0 and $numplayers['max_players'] == 0)
				$numplayers = false;
			else
				$player_string = $numplayers['act_players'].'/'.$numplayers['max_players'];
?>				
				
					|  |  | '.htmlspecialchars($topplayer[1], ENT_COMPAT).'';
			}
			else
			{
				echo '-';
			}
					?> | '.htmlspecialchars($topclan[1], ENT_COMPAT).'';
			}
			else
			{
				echo '-';
			}
					?> | 
	
				
		
		 
		
		
query("SELECT COUNT(playerId) FROM hlstats_Players WHERE game IN $nonhiddengamestring");
		list($num_players) = $db->fetch_row($result);
		$num_players = number_format($num_players);
		$result = $db->query("SELECT COUNT(clanId) FROM hlstats_Clans WHERE game IN $nonhiddengamestring");
		list($num_clans) = $db->fetch_row($result);
		$num_clans = number_format($num_clans);
		$result = $db->query("SELECT COUNT(serverId) FROM hlstats_Servers WHERE game IN $nonhiddengamestring");
		list($num_servers) = $db->fetch_row($result);
		$num_servers = number_format($num_servers);
		
		$result = $db->query("SELECT SUM(kills) FROM hlstats_Servers WHERE game IN $nonhiddengamestring");
		list($num_kills) = $db->fetch_row($result);
		$num_kills = number_format($num_kills);
		$result = $db->query("
			SELECT 
				eventTime
			FROM
				hlstats_Events_Frags
			ORDER BY
				id DESC
			LIMIT 1
		");
		list($lastevent) = $db->fetch_row($result);
?>
		
		
			
				- $num_players players and $num_clans clans "
						. "ranked in $num_games games on $num_servers"
						. " servers with $num_kills kills."; ?>Last Kill  " . date('g:i:s A, D. M. d, Y', strtotime($lastevent)) . "";
		}
?>
- All statistics are generated in real-time. Event history data expires after  days.