Location: PHPKode > scripts > ezStats for PlayStation Network > ezStats2_psn/index.php
<?php
	### Weiterleitung auf den Installer ###
	if (!file_exists('tmp/sql.php')) {
		header("Status: 301 Moved Permanently");
		header("Location:install/");
		exit; 
	}
	
	
	### Klassen laden ###
	if (true) {
		require 'tmp/sql.php';
		require 'classes/mysql.php';
		
		$sql = new MySQL(); if ($sql->debug) error_reporting (E_ALL|E_STRICT); else error_reporting (0);
		
		require 'plugins/phpQuery.php';
		require 'classes/settings.php';
		require 'classes/security.php';
		require 'classes/functions.php';
		require 'classes/template.php';
		require 'classes/player.php';
		require 'classes/stats.php';
		
		
		$func = new Functions();
		$secure = new Security();
		$settings = new Settings();
		$tpl = new Templates();
		$tpl->load_phrases("overview", true);
		$tpl->load_phrases("_psn_admin", true);
		$tpl->load_phrases("_psn_overview", true);
	}
	
	
	### Allgemeine Variablen setzen ###
	if (true) {
		$func->counter();                                             // Counter starten
		$preset = $func->load_settings("settings");                   // Settings laden
		$ov = $func->load_settings("overview");                       // Settings laden
		date_default_timezone_set($preset["timezone"]);               // Zeitzone setzen
		$lastupdate = date("d.m.Y - H:i", $preset["lastcheckall"]);   // Variable für das letzte Update aller Spieler
		$columns = $func->load_settings("overview");                  // Spalten die in der Übersicht angezeigt werden können/sollen
	}
	
	
	### Tabellenkopf ###
	if (true) {
		// Spalten, die anstatt eines Textes ein Icon als Bezeichnung haben
		$icons = Array(
			"totalGames" => 0,
			"platinum" => -20,
			"gold" => -40,
			"silver" => -60,
			"bronze" => -80,
			"total" => -100,
			"totalPerGame" => -220,
			"platPerGame" => -140,
			"goldPerGame" => -160,
			"silvPerGame" => -180,
			"bronPerGame" => -200,
			"percPlat" => -120,
		);
		
		
		$thead = phpQuery::newDocumentHTML("<thead><tr></tr></thead>");
		
		// Alle Spaltenheader erstellen, die im Leaderboard aktiviert wurden
		foreach ($columns as $name => $active) {
			if (array_key_exists($name, $icons)) {
				if ($active) pq('tr')->append('<th info="'.$tpl->phrase($name).'"><div class="ov_icons" style="background-position: 0 '.$icons[$name].'px"></div></th>');
			} else {
				if ($active) pq('tr')->append('<th>'.$tpl->phrase($name).'</th>');
			}
		}
		
		// Sortierung umdrehen, wenn Spalte 1 "Position" enthält
		$sortList = pq('th')->eq(0)->text() == $tpl->phrase('position') ? "[[0,0]]" : "[[0,1]]";
	}
	
	
	### Tabellenkörper ###
	if (true) {
		$tbody = phpQuery::newDocumentHTML("<tbody></tbody>");
		$summary = Array();
		$i = 0;
		
		// Die IDs aller Spieler abrufen, die eine Spielzeit > 0 haben, nicht die ID 1 haben, sortiert nach den Punkten
		$sql->query('
			SELECT id FROM '.$sql->prefix.'player 
			WHERE id != 0 AND jid != ""
			ORDER BY points DESC
		');
		
		// Alle Spieler durchlaufen und in als Zeile in die Tabelle speichern
		while ($row = $sql->fetchAssoc()) {
			$i++;
			$td = Array();
			$stats = new Stats($row['id']);
			
			
			if ($ov['position']) {      // Position im Leaderboard
				$result = $stats->format($i, Array('number', 0, '', 'position'));
				$td['position'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['position'])) $summary['position'] = Array();
				$summary['position'][] = '';
			}
			
			if ($ov['country']) {       // Country-Icon
				$result = $stats->get('player', 'country', Array('deficon', 'country'));
				$td['country'] = phpQuery::newDocumentHTML('<td class="tcenter" sort="'.$result['sort'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['country'])) $summary['country'] = Array();
				$summary['country'][] = NULL;
			}
			
			if ($ov['name']) {          // Spielername
				$name     = $stats->get('player', 'name');
				$nickname = $stats->get('player', 'nickname');
				$clantag  = $settings->get('clantag');
				
				if ($nickname) $name = $nickname;
				
				
				$path = ($preset['cms'] == "standalone") ? "" : $settings->get("path");
				$html = utf8_encode(htmlentities('
					<div style="background-image: url('.$stats->get('player', 'avatar').')">
						<span>
							<h1>'.$clantag.$name.'</h1>
							'.$stats->get('player', 'aboutme').'
						</span>
					</div>
				'));
				$td['name'] = phpQuery::newDocumentHTML('<td class="tleft" sort="'.$name.'" menu="'.$html.'"><a href="http://psnprofiles.com/'.$stats->get('player', 'name').'" target="_blank">'.$clantag.$name.'</a></td>');
				
				
				
				if (!isset($summary['name'])) $summary['name'] = Array();
				$summary['name'][] = NULL;
			}
			
			if ($ov['level']) {         // Level
				$result = $stats->get('player', 'level', Array('level'));
				$td['level'] = phpQuery::newDocumentHTML('<td class="tcenter" sort="'.$result['sort'].'" info="'.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['level'])) $summary['level'] = Array();
				$summary['level'][] = $result['raw'];
			}
			
			if ($ov['custom1']) {       // Custon-Wert 1
				$result = $stats->get('player', 'custom1');
				$td['custom1'] = phpQuery::newDocumentHTML('<td class="tleft" sort="'.$result.'">'.$result.'</td>');
				
				if (!isset($summary['custom1'])) $summary['custom1'] = Array();
				$summary['custom1'][] = NULL;
			}
			
			if ($ov['points']) {        // Gesamt-Punkte
				$result = $stats->get('player', 'points', Array('number', 0));
				$td['points'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('points').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['points'])) $summary['points'] = Array();
				$summary['points'][] = $result['raw'];
			}
			
			if ($ov['totalGames']) {    // Anzahl gespielter Spiele
				$result = $stats->get('player', 'totalGames', Array('number', 0));
				$td['totalGames'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('totalGames').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['totalGames'])) $summary['totalGames'] = Array();
				$summary['totalGames'][] = $result['raw'];
			}
			
			if ($ov['platinum']) {      // Platinum Trophys
				$result = $stats->get('player', 'platinum', Array('number', 0));
				$td['platinum'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('platinum').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['platinum'])) $summary['platinum'] = Array();
				$summary['platinum'][] = $result['raw'];
			}
			
			if ($ov['gold']) {          // Gold Trophys
				$result = $stats->get('player', 'gold', Array('number', 0));
				$td['gold'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('gold').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['gold'])) $summary['gold'] = Array();
				$summary['gold'][] = $result['raw'];
			}
			
			if ($ov['silver']) {        // Silver Trophys
				$result = $stats->get('player', 'silver', Array('number', 0));
				$td['silver'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('silver').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['silver'])) $summary['silver'] = Array();
				$summary['silver'][] = $result['raw'];
			}
			
			if ($ov['bronze']) {        // Bronze Trophys
				$result = $stats->get('player', 'bronze', Array('number', 0));
				$td['bronze'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('bronze').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['bronze'])) $summary['bronze'] = Array();
				$summary['bronze'][] = $result['raw'];
			}
			
			if ($ov['total']) {         // Alle Trophys
				$result = $stats->get('player', 'total', Array('number', 0));
				$td['total'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('total').': '.$result['format'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['total'])) $summary['total'] = Array();
				$summary['total'][] = $result['raw'];
			}
			
			if ($ov['totalPerGame']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'total', Array('ratio', $games, 1));
				$td['totalPerGame'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('totalPerGame').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['totalPerGame'])) $summary['totalPerGame'] = Array();
				$summary['totalPerGame'][] = $result['raw'];
			}
			
			if ($ov['platPerGame']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'platinum', Array('ratio', $games, 1));
				$td['platPerGame'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('platPerGame').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['platPerGame'])) $summary['platPerGame'] = Array();
				$summary['platPerGame'][] = $result['raw'];
			}
			
			if ($ov['goldPerGame']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'gold', Array('ratio', $games, 1));
				$td['goldPerGame'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('goldPerGame').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['goldPerGame'])) $summary['goldPerGame'] = Array();
				$summary['goldPerGame'][] = $result['raw'];
			}
			
			if ($ov['silvPerGame']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'silver', Array('ratio', $games, 1));
				$td['silvPerGame'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('silvPerGame').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['silvPerGame'])) $summary['silvPerGame'] = Array();
				$summary['silvPerGame'][] = $result['raw'];
			}
			
			if ($ov['bronPerGame']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'bronze', Array('ratio', $games, 1));
				$td['bronPerGame'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('bronPerGame').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['bronPerGame'])) $summary['bronPerGame'] = Array();
				$summary['bronPerGame'][] = $result['raw'];
			}
			
			if ($ov['percPlat']) {
				$games = $stats->get('player', 'totalGames');
				$result = $stats->get('player', 'platinum', Array('ratio', $games, 0, '%'));
				$td['percPlat'] = phpQuery::newDocumentHTML('<td sort="'.$result['sort'].'" info="'.$tpl->phrase('percPlat').': '.$result['tip'].'">'.$result['format'].'</td>');
				
				if (!isset($summary['percPlat'])) $summary['percPlat'] = Array();
				$summary['percPlat'][] = $result['raw'];
			}
			
			// Zellen der gewünschten Reihenfolge nach in eine Zeile speichern
			$tr = phpQuery::newDocumentHTML('<tr></tr>');
			foreach ($ov as $name => $show) {
				if ($show AND isset($td[$name])) pq('tr')->append($td[$name]);
			}
			
			// Zeile an den Tabellenkörper anhängen
			phpQuery::selectDocument($tbody);
			pq('tbody')->append($tr);
		}
	}
	
	
	### Tabellenfuss ###
	if (true) {
		$tfoot = phpQuery::newDocumentHTML('<tfoot></tfoot>');
		$methods = Array('ov_averages', 'ov_median', 'ov_summary');
		
		if ($sql->count()) {
			foreach ($methods as $method) {
				if ($settings->get($method)) {
					$td = Array();
					
					if ($ov['position']) {      // Position im Leaderboard
						$td['position'] = phpQuery::newDocumentHTML('<td></td>');
					}
					
					if ($ov['country']) {       // Country-Icon
						$td['country'] = phpQuery::newDocumentHTML('<td></td>');
					}
					
					if ($ov['name']) {          // Spielername
						$td['name'] = phpQuery::newDocumentHTML('<td>'.$tpl->phrase($method).': </td>');
					}
					
					if ($ov['custom1']) {       // Custon-Wert 1
						$td['custom1'] = phpQuery::newDocumentHTML('<td></td>');
					}
					
					if ($ov['level']) {         // Fortschritt
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['level']);
							$result = $stats->format($result, Array('number', 0));
							$td['level'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['level']);
							$result = $stats->format($result, Array('number', 0));
							$td['level'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['level'] = phpQuery::newDocumentHTML('<td></td>');
						}
						
						
						
					}
					
					if ($ov['points']) {        // Gesamt-Punkte
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['points']);
							$result = $stats->format($result, Array('number', 0));
							$td['points'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['points']);
							$result = $stats->format($result, Array('number', 0));
							$td['points'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['points']);
							$result = $stats->format($result, Array('number', 0, "k"));
							$td['points'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['totalGames']) {    // Anzahl gespielter Spiele
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['totalGames']);
							$result = $stats->format($result, Array('number', 0));
							$td['totalGames'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['totalGames']);
							$result = $stats->format($result, Array('number', 0));
							$td['totalGames'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['totalGames']);
							$result = $stats->format($result, Array('number', 0));
							$td['totalGames'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['platinum']) {      // Platinum Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['platinum']);
							$result = $stats->format($result, Array('number', 0));
							$td['platinum'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['platinum']);
							$result = $stats->format($result, Array('number', 0));
							$td['platinum'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['platinum']);
							$result = $stats->format($result, Array('number', 0));
							$td['platinum'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['gold']) {          // Gold Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['gold']);
							$result = $stats->format($result, Array('number', 0));
							$td['gold'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['gold']);
							$result = $stats->format($result, Array('number', 0));
							$td['gold'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['gold']);
							$result = $stats->format($result, Array('number', 0, "k"));
							$td['gold'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['silver']) {        // silver Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['silver']);
							$result = $stats->format($result, Array('number', 0));
							$td['silver'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['silver']);
							$result = $stats->format($result, Array('number', 0));
							$td['silver'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['silver']);
							$result = $stats->format($result, Array('number', 0, "k"));
							$td['silver'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['bronze']) {        // bronze Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['bronze']);
							$result = $stats->format($result, Array('number', 0));
							$td['bronze'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['bronze']);
							$result = $stats->format($result, Array('number', 0));
							$td['bronze'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['bronze']);
							$result = $stats->format($result, Array('number', 0, "k"));
							$td['bronze'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['total']) {        // total Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['total']);
							$result = $stats->format($result, Array('number', 0));
							$td['total'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['total']);
							$result = $stats->format($result, Array('number', 0));
							$td['total'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$result = array_sum($summary['total']);
							$result = $stats->format($result, Array('number', 0, "k"));
							$td['total'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
					}
					
					if ($ov['totalPerGame']) {        // totalPerGame Trophys
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['totalPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['totalPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['totalPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['totalPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['totalPerGame'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					if ($ov['platPerGame']) { 
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['platPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['platPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['platPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['platPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['platPerGame'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					if ($ov['goldPerGame']) { 
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['goldPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['goldPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['goldPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['goldPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['goldPerGame'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					if ($ov['silvPerGame']) { 
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['silvPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['silvPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['silvPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['silvPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['silvPerGame'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					if ($ov['bronPerGame']) { 
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['bronPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['bronPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['bronPerGame']);
							$result = $stats->format($result, Array('number', 1));
							$td['bronPerGame'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['bronPerGame'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					if ($ov['percPlat']) { 
						if ($method == 'ov_averages') {
							$result = $func->calculate_average($summary['percPlat']);
							$result = $stats->format($result, Array('number', 0, '%'));
							$td['percPlat'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_median') {
							$result = $func->calculate_median($summary['percPlat']);
							$result = $stats->format($result, Array('number', 0, '%'));
							$td['percPlat'] = phpQuery::newDocumentHTML('<td info="'.$tpl->phrase($method).': '.$result['format'].'">'.$result['format'].'</td>');
						}
						if ($method == 'ov_summary') {
							$td['percPlat'] = phpQuery::newDocumentHTML('<td></td>');
						}
					}
					
					
					// Zellen der gewünschten Reihenfolge nach in eine Zeile speichern
					$tr = phpQuery::newDocumentHTML('<tr></tr>');
					foreach ($ov as $name => $show) {
						if ($show AND isset($td[$name])) pq('tr')->append($td[$name]);
					}
					
					// Zeile an den Tabellenfuss anhängen
					phpQuery::selectDocument($tfoot);
					pq('tfoot')->append($tr);
				}
			}
		}
	}
	
	
	### Seite erzeugen und ausgeben ###
	if (true) {
		if ($preset['cms'] == "standalone") {
			eval ("\$html = \"".$tpl->template("standalone")."\";");  $html = phpQuery::newDocumentHTML($html);
		} else {
			eval ("\$html = \"".$tpl->template("plugin")."\";");
			$html = str_replace('#PATH#', $preset['path'], $html);
			$html = phpQuery::newDocumentHTML($html);
		}
		
		pq('#ezOverview')->append($thead);
		pq('#ezOverview')->append($tfoot);
		pq('#ezOverview')->append($tbody);
		
		
		// Postprocessing
		if (!$preset['ov_brand'])            pq('#ezBrand')->remove(); // Werbung entfernen
		if (!$preset['ov_infobox'])          pq('#ezAside')->remove(); // Infobox entfernen
		if ($preset['language'] == "hebrew") pq('#ezStats')->attr('dir', 'rtl'); // Schriftrichtung ändern bei RTL-Sprachen
		if ($preset['selfadd'] == "1")       pq("#ezStats")->prepend('<a href="'.$preset["path"].'admin/index.php?selfadd" class="selfadd">'.$tpl->phrase("selfadd").'</a>'); // Selfadd: Link einblenden, mit dem Spieler sich selbst adden können
		
		
		// Ausgabe
		header('Content-Type:text/html; charset=UTF-8');
		echo $html;
	}
?>
Return current item: ezStats for PlayStation Network