<?php if (!defined('access')) {die("Die gesuchte Ressource wurde entfernt oder umbenannt, oder sie steht vorübergehend nicht zur Verfügung.");} ?>
<p class="page_title">Unsere Ranglisten und Statistiken</p>
<p>
	<label class="px170 nopad"><b><?php echo $_LANG['ranking_available_rankings'];?>:</b></label>	| <a href="index.php?site=ranking&amp;rnk=players"><?php echo $_LANG['ranking_player_siteTitle'];?></a> | <a href="index.php?site=ranking&amp;rnk=gws"><?php echo $_LANG['ranking_guildwar_siteTitle'];?></a> | <a href="index.php?site=ranking&amp;rnk=guilds"><?php echo $_LANG['ranking_guild_siteTitle'];?></a> | <a href="index.php?site=ranking&amp;rnk=vote"><?php echo $_LANG['ranking_votes_siteTitle'];?></a> |<br />
	<label class="px170 nopad"><b><?php echo $_LANG['ranking_available_statistics'];?></b></label> 	| <a href="index.php?site=ranking&amp;rnk=election"><?php echo $_LANG['ranking_last_lord_election'];?></a> | <a href="index.php?site=ranking&amp;rnk=usercnt"><?php echo $_LANG['ranking_playernumbers'];?></a> | <a href="index.php?site=ranking&amp;rnk=stats"><?php echo $_LANG['ranking_general_siteTitle'];?></a> |
	<br style="clear:both;"/>
</p>

<?php
if ($_GET['rnk'] == 'players') {
	function cutFileContentInParts($title, $arrayEntries, $top, $pfad) {
		global $_CONFIG, $_LANG;
		if($top > count($arrayEntries)) {
			$top = count($arrayEntries);
		}
		$rank = 1;
		
		echo '
<p>
	<label class="px170 nopad"><b>' . $_LANG['ranking_top_label'] . ':</b></label>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=10">Top 10</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=50">Top 50</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=100">Top 100</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=200">Top 200</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=300">Top 300</a>
	|
</p>
<h2 class="center padding">' . $title . '</h3>
<div class="table padding">
	<div class="thead">
		<div class="tr">
			<div class="p05 center">&nbsp;</div>
			<div class="p35">' . $_LANG['character'] . '</div>
			<div class="p15 center">' . $_LANG['level'] . '</div>
			<div class="p15 center">' . $_LANG['class'] . '</div>
			<div class="p15 center">' . $_LANG['playtime'] . '</div>
			<div class="p15 center">' . $_LANG['created_on'] . '</div>
		</div>
	</div>
	<div class="tbody">';
		for($i=0; $i < $top; $i++) {
			$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
			echo '
		<div class="tr">
			<div class="p05 center">' . rankIcon($rank) . '</div>
			<div class="p35">' . getUserOnlineState($mixedEntry[0]) . ' <b>' . utf8_encode($mixedEntry[1]) . '</b></div>
			<div class="p15 center">' . $mixedEntry[2]		. '</div>
			<div class="p15 center">' . getjob($mixedEntry[3]) . '</div>
			<div class="p15 center">' . sectohrs($mixedEntry[4]) . '</div>
			<div class="p15 center">'.substr($mixedEntry[5],8,2).'.'.substr($mixedEntry[5],5,2).'.'.substr($mixedEntry[5],0,4).'</div>
		</div>';
			$rank++;
		}
		echo '
	</div>
</div>
		';
	}
	
	cutFileContentInParts($_LANG['ranking_player_siteTitle'], cutTxtInParts('site_ranking_players'), numbersOnly($_GET['top']), $_GET['rnk']);
	getTxtModifiedDate($contentFile);
}
elseif ($_GET['rnk'] == 'gws') {
	function cutFileContentInParts($title, $arrayEntries, $top, $pfad) {
		global $_CONFIG, $_LANG;
		if($top > count($arrayEntries)) {
			$top = count($arrayEntries);
		}
		$rank = 1;
		
		echo '
<p>
	<label class="px170 nopad"><b>' . $_LANG['ranking_top_label'] . ':</b></label>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=10">Top 10</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=50">Top 50</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=100">Top 100</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=200">Top 200</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=300">Top 300</a>
	|
</p>
<h2 class="center padding">' . $title . '</h3>
<div class="table padding">
	<div class="thead">
		<div class="tr">
			<div class="p05">&nbsp;</div>
			<div class="p25">' . $_LANG['character'] . '</div>
			<div class="p25">' . $_LANG['guild'] . '</div>
			<div class="p15 center">' . $_LANG['points'] . '</div>
			<div class="p15 center">' . $_LANG['participations'] . '</div>
			<div class="p15 center">' . $_LANG['points'] . ' / ' . $_LANG['gw_short'] . '</div>
		</div>
	</div>
	<div class="tbody">';
		for($i=0; $i < $top; $i++) {
			$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
			echo '
		<div class="tr">
			<div class="p05 center">' . rankIcon($rank) . '</div>
			<div class="p25">' . getUserOnlineState($mixedEntry[1]) . ' <b>' . utf8_encode($mixedEntry[0]) . '</b></div>
			<div class="p25">' . utf8_encode($mixedEntry[3]) . '&nbsp;</div>
			<div class="p15 center">' . $mixedEntry[2] . '</div>
			<div class="p15 center">' . $mixedEntry[4] . '</div>
			<div class="p15 center">' . $mixedEntry[5] . '</div>
		</div>';
			$rank++;
		}
		echo '
	</div>
</div>
		';
	}
	
	cutFileContentInParts($_LANG['ranking_guildwar_siteTitle'], cutTxtInParts('site_ranking_gws'), numbersOnly($_GET['top']), $_GET['rnk']);
	getTxtModifiedDate($contentFile);
}
elseif ($_GET['rnk'] == 'guilds') {
	function cutFileContentInParts($title, $arrayEntries, $top, $pfad) {
		global $_CONFIG, $_LANG;
		
		$rank = 1;
		if($top > count($arrayEntries)) {$top = count($arrayEntries);}
		if(empty($top)) {$top = 30;}
		
		echo '
<p>
	<label class="px170 nopad"><b>' . $_LANG['ranking_top_label'] . ':</b></label>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=10">Top 10</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=50">Top 50</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=100">Top 100</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=200">Top 200</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=300">Top 300</a>
	|
</p>
<h2 class="center padding">' . $title . '</h3>
<div class="table padding">
	<div class="thead">
		<div class="tr">
			<div class="p05">&nbsp;</div>
			<div class="p20">' . $_LANG['guild'] . '</div>
			<div class="p10 center">' . $_LANG['wins'] . '</div>
			<div class="p10 center">' . $_LANG['points'] . '</div>
			<div class="p20 center">' . $_LANG['leader'] . '</div>
			<div class="p10 center">' . $_LANG['level'] . '</div>
			<div class="p10 center">' . $_LANG['member'] . '</div>
			<div class="p15 center">' . $_LANG['created_on'] . '</div>
		</div>
	</div>
	<div class="tbody">';
		for($i=0; $i < $top; $i++) {
			$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
			echo '
		<div class="tr">
			<div class="p05 center">' . rankIcon($rank) . '</div>
			<div class="p20">&nbsp;' . utf8_encode($mixedEntry[0]) . '</div>
			<div class="p10 center">' . $mixedEntry[2] . '</div>
			<div class="p10 center">' . $mixedEntry[3] . '</div>
			<div class="p20 center">' . utf8_encode($mixedEntry[4]) . '</div>
			<div class="p10 center">' . $mixedEntry[1] . '</div>
			<div class="p10 center">' . $mixedEntry[5] . '</div>
			<div class="p15 center">' . date($_CONFIG['web_date_format']['date'], strtotime($mixedEntry[6])) . '</div>
		</div>';
			$rank++;
		}
		echo '
	</div>
</div>
		';
	}
	
	cutFileContentInParts($_LANG['ranking_guild_siteTitle'], cutTxtInParts('site_ranking_guilds'), numbersOnly($_GET['top']), $_GET['rnk']);
	getTxtModifiedDate($contentFile);
}
elseif ($_GET['rnk'] == 'vote') {
	function cutFileContentInParts($title, $arrayEntries, $top, $pfad) {
		global $_CONFIG,$_LANG;
		if($top > count($arrayEntries)) {
			$top = count($arrayEntries);
		}
		$rank = 1;
		
		echo '
<p>
	<label class="px170 nopad"><b>' . $_LANG['ranking_top_label'] . ':</b></label>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=10">Top 10</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=50">Top 50</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=100">Top 100</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=200">Top 200</a>
	| <a href="index.php?site=ranking&amp;rnk='.$pfad.'&amp;top=300">Top 300</a>
	|
</p>
<h2 class="center padding">' . $title . '</h3>
<div class="table padding">
	<div class="thead">
		<div class="tr">
			<div class="p05">&nbsp;</div>
			<div class="p35">' . $_LANG['player'] . '</div>
			<div class="p15 center">' . $_LANG['ranking_votes_month'] . '</div>
			<div class="p15 center">' . $_LANG['ranking_votes_summed'] . '</div>
			<div class="p30 center">' . $_LANG['ranking_votes_last_vote'] . '</div>
		</div>
	</div>
	<div class="tbody">';
		for($i=0; $i < $top; $i++) {
			$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
			echo '
		<div class="tr">
			<div class="p05 center">' . rankIcon($rank) . '</div>
			<div class="p35"><b>&nbsp;'. utf8_encode($mixedEntry[0]) . '</b></div>
			<div class="p15 center">' . $mixedEntry[1] . '</div>
			<div class="p15 center">' . $mixedEntry[3] . '</div>
			<div class="p30 center">' . $mixedEntry[2] . ' Uhr</div>
		</div>';
			$rank++;
		}
		echo '
	</div>
</div>
		';
	}
	
	cutFileContentInParts($_LANG['ranking_votes_siteTitle'], cutTxtInParts('site_ranking_vote'), numbersOnly($_GET['top']), $_GET['rnk']);
	getTxtModifiedDate($contentFile);
}
elseif ($_GET['rnk'] == 'usercnt') {

	$pfad = 'index.php?site=ranking&rnk=usercnt';
	$contentFile = 'site_ranking_usercnt';
	$strFilePath = 'includes/' . $_CONFIG['website_cronjob_folder'] . '/' . $contentFile . '.' . $_CONFIG['website_cronjob_filetype'];
	$inputArrayEntries = explode("\r\n", fread(fopen($strFilePath, 'r'), filesize($strFilePath)));
	
	function cutFileContentInParts($arrayEntries) {
		global $_CONFIG;
		$counter = 1;
		
	echo '
<div class="loadingImage">
	<img src="../includes/charts/ranking_usercount.php?someDays" alt="Userzahlen der letzten vier Tage" title="Userzahlen der letzten vier Tage" id="vier" class="pChartPicture"/>
</div>
<br />
<hr />';
		
		rsort($arrayEntries, SORT_NUMERIC);
		foreach($arrayEntries as $strEntries) {
			if($counter == 8) {$counter = 1;}
			$cutDate = explode("-", $strEntries);
			echo '
<div class="loadingImage">
	<a class="pChart" href="../includes/charts/ranking_usercount.php?date=' . $cutDate[0]  . '" alt="Userzahlen vom ' . date($_CONFIG['web_date_format']['date'], $cutDate[0]) . '"/>Userzahlen vom ' . date($_CONFIG['web_date_format']['date'], $cutDate[0]) . '</a>
</div>';
			$counter++;
		}
	}
	
	cutFileContentInParts($inputArrayEntries, $pfad);
	getTxtModifiedDate($contentFile);
}
elseif ($_GET['rnk'] == 'stats') {
	echo '<h2 class="center padding">' . $_LANG['ranking_general_siteTitle'] .  '</h3>';

	function cutFileContentInParts($title, $arrayEntries) {
		global $_CONFIG, $_LANG;
		
		echo '
<div style="float:left;" class="p50 padding">';
		if($title == $_LANG['characters']) {
			for($i=0; $i < count($arrayEntries); $i++) {
				if($i/5 == round($i/5,0) AND $i > 0) {echo '<br class="clear"/>';}
				$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
				echo '<p>';
				if($i/5 != round($i/5)) {
					echo '<span class="px140">- ';
				}
				else {
					echo '<span class="px140 bold">';
				}
				echo getjob($mixedEntry[0]) . 's:</span>' . $mixedEntry[1] . '</p>';
			}
		}
		if($title == $_LANG['general_information']) {
			$asdf = cutTxtInParts('include_boxes_online');
			echo '
				<div>
					<p><span class="px140">' . $_LANG['accounts'] . ':</span>' . $arrayEntries[0] . '</p>
					<p><span class="px140">' . $_LANG['characters'] . ':</span>' . $arrayEntries[1] . '</p>
					<p><span class="px140">' . $_LANG['guilds'] . ':</span>' . $arrayEntries[2] . '</p>
				</div>
				<div class="padding">
					<br />';
			foreach($_CONFIG['allg_svr_channel_ports'] as $id => $port) {echo '
					<p><span class="px140">Channel #0'.$id.':</span>' . checkServerState($port) . ', ' . $asdf[$id]. ' ' . $_LANG['users'] . '</p>';
			}
			echo '
				</div>
				<div class="padding">
					<p><span class="px140">' . $_LANG['staff_members'] . ':</span>' . $arrayEntries[3] . '</p>
				</div>
				<div class="padding">
					<p><span class="px140">' . $_LANG['lord'] . ':</span>&nbsp;' . $arrayEntries[4] . '</p>
					<p><span class="px140">' . $_LANG['guild'] . ':</span>&nbsp;' . $arrayEntries[5] . '</p>
					<p><span class="px140">' . $_LANG['mvp'] . ':</span>&nbsp;' . $arrayEntries[6] . '</p>
				</div>';
		}
		echo '
</div>';
	}
	
	cutFileContentInParts($_LANG['characters'], cutTxtInParts('site_ranking_stats_classes'));
	cutFileContentInParts($_LANG['general_information'], cutTxtInParts('site_ranking_stats_globals'));
	echo '<div class="clear"></div>';
}
elseif ($_GET['rnk'] == 'election') {
	function cutFileContentInParts($title, $arrayEntries) {
		global $_CONFIG, $_LANG;
		$rank = 1;
		
		if($title == $_LANG['ranking_last_lord_election']) {
			echo '
<div class="table padding">
	<div class="thead">
		<div class="tr">
			<div class="p05">&nbsp;</div>
			<div class="p45">'  . $_LANG['player'] . '</div>
			<div class="p25 center">'  . $_LANG['ranking_voices'] . '</div>
			<div class="p25 center">'  . $_LANG['ranking_relative_voices'] . '</div>
		</div>
	</div>
	<div class="tbody">';
			for($i=0; $i < count($arrayEntries); $i++) {
				$mixedEntry = explode($_CONFIG['website_cronjob_spacer'], $arrayEntries[$i]);
				echo '
		<div class="tr">
			<div class="p05 center">' . rankIcon($rank) . '</div>
			<div class="p45"><b>'. $mixedEntry[0] . '</b></div>
			<div class="p25 center">' . $mixedEntry[1] . '</div>
			<div class="p25 center">' . $mixedEntry[2] . ' %</div>
		</div>';
				$rank++;
			}
			echo '
	</div>
</div>
		';
		}
		else {
			echo '
<h2 class="center padding">' . $title . '</h3>
<div>
	Hierbei handelt es sich um die Ergebnisse der ' . $arrayEntries[0] . '. Lordwahlen vom ' . date($_CONFIG['web_date_format']['date'], $arrayEntries[1]) . '.
	Insgesamt haben sich ' . $arrayEntries[3] . ' Spieler an der Wahl beteiligt, das ist eine am Serverpeak gemessene Wahlbeteiligung von ' . $arrayEntries[4] . '%.
	Die nächste Lordwahl findet dann ab dem ' . date($_CONFIG['web_date_format']['date'], $arrayEntries[2]) . ' statt.
</div>
';
		}
	}
	
	cutFileContentInParts($_LANG['details'], cutTxtInParts('site_ranking_election_detail'));
	cutFileContentInParts($_LANG['ranking_last_lord_election'], cutTxtInParts('site_ranking_election_voting'));
	getTxtModifiedDate('site_ranking_election_voting');
}
