<?php include('inc/header.php'); ?>
<h1>Listen / Logs - Diverse Listen</h1>
<div class="container">
    <form method="get">
        <input type="submit" name="GetAuthAccChar" value="Rechteverteilung" />
        <input type="submit" name="GetPushedCharacter" value="Gepushte Charaktere" />
        <input type="submit" name="GetDeletedCharacter" value="Gelöschte Charaktere" />
        <input type="submit" name="GSRanking" value="Guildsiege" />
        <input type="submit" name="regist" value="Registrationen" />
        <input type="submit" name="logins" value="Websitelogins" />
        <input type="submit" name="LCSendLog" value="Spendenpunkte" />
    </form>
    <hr style="clear: both;"/>
<?php
	if(isset($_GET['GetPushedCharacter'])){
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
		$select = odbc_exec($odbc_connect, 'SELECT * FROM [CHARACTER_TBL] WHERE ([m_nStr]+[m_nSta]+[m_nDex]+[m_nInt]) >= '.$lang['db_push_limit'].' AND [isblock] = \'F\' ORDER BY [account] asc, [m_szName] ASC');
		if( odbc_num_rows($select) < 1 ){
			echo '<div class="fail">Es existieren keine Charaktere mit ungewöhnlichen Werten.</div>';
		}
		else {
			echo '
<p>
	Aufgelistet werden Charaktere, die nicht gelöscht sind. Ob der entsprechende Account, mit dem die Charaktere verbunden sind, gebannt ist, spielt keine Rolle.
</p>
<table cellspacing="0">
	<thead>
		<tr>
			<td>'.$lang['db_user'].'</td>
			<td>Account</td>
			<td>'.$lang['db_level'].'</td>
			<td>'.$lang['db_job'].'</td>
			<td>'.$lang['db_stat_str'].'</td>
			<td>'.$lang['db_stat_sta'].'</td>
			<td>'.$lang['db_stat_dex'].'</td>
			<td>'.$lang['db_stat_int'].'</td>
		</tr>
	</thead>
	<tbody>';
			while($result = odbc_fetch_array($select)){
				echo '
		<tr class="body">
			<td>'.$result['m_szName'].'</td>
			<td>'.$result['account'].'</td>
			<td>'.$result['m_nLevel'].'</td>
			<td>'.$job[$result['m_nJob']].'</td>
			<td>'.$result['m_nStr'].'</td>
			<td>'.$result['m_nSta'].'</td>
			<td>'.$result['m_nDex'].'</td>
			<td>'.$result['m_nInt'].'</td>
		</tr>';
			}
			echo '
	</tbody>
</table>';
		}
		echo '
	<br />
	<a href="list_database.php">'.$lang['panel_back'].'</a>';
	}
	elseif(isset($_GET['GetDeletedCharacter'])){
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
		$select = odbc_exec($odbc_connect, 'SELECT TOP 100 * FROM [CHARACTER_TBL] WHERE [isblock] !=\'F\' ORDER BY [m_szName] ASC');
		if( odbc_num_rows($select) == 0 ){
			echo '<div class="fail">'.$lang['db_no_del'].'</div>';
		}
		else {
			echo '
<table cellspacing="0">
	<thead>
		<tr>
			<td>'.$lang['db_user'].'</td>
			<td>'.$lang['db_level'].'</td>
			<td>'.$lang['db_job'].'</td>
			<td>'.$lang['db_stat_str'].'</td>
			<td>'.$lang['db_stat_sta'].'</td>
			<td>'.$lang['db_stat_dex'].'</td>
			<td>'.$lang['db_stat_int'].'</td>
		</tr>
	</thead>
	<tbody>';
			while($result = odbc_fetch_array($select)){
				echo '
		<tr>
			<td>'.$result['m_szName'].'</td>
			<td>'.$result['m_nLevel'].'</td>
			<td>'.$job[$result['m_nJob']].'</td>
			<td>'.$result['m_nStr'].'</td>
			<td>'.$result['m_nSta'].'</td>
			<td>'.$result['m_nDex'].'</td>
			<td>'.$result['m_nInt'].'</td>
		</tr>';
			}
			echo '
	</tbody>
</table>';
		}
		echo '
	<br />
	<a href="list_database.php">'.$lang['panel_back'].'</a>';
	}
	elseif(isset($_GET['GetAuthAccChar'])){
		if( isset($_GET['RemAccAuth']) && !empty($_GET['RemAccAuth']) ){
				odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['acc'] . ']');
				odbc_exec($odbc_connect, 'UPDATE [ACCOUNT_TBL_DETAIL] SET [m_chLoginAuthority] =\'F\' WHERE [account]=\''.mssql_escape_string($_GET['RemAccAuth']).'\'');
				echo '<div class="success">'.$lang['db_rem_acc_auth'].'</div>';
		}
		if( isset($_GET['RemCharAuth']) && !empty($_GET['RemCharAuth']) ){
				odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
				odbc_exec($odbc_connect, 'UPDATE [CHARACTER_TBL] SET [m_chAuthority] =\'F\' WHERE [m_szName]=\''.mssql_escape_string($_GET['RemCharAuth']).'\'');
				echo '<div class="success">'.$lang['db_rem_char_auth'].'</div>';
		}
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['acc'] . ']');
		$select = odbc_exec($odbc_connect, 'SELECT account,m_chLoginAuthority from [account_tbl_detail] where [m_chLoginAuthority] !=\'F\' order by [m_chLoginAuthority] desc');
		echo '<h2>Accounts mit Rechten</h2>';
		if( odbc_num_rows($select) == 0 ){
			echo '<p class="fail">'.$lang['db_no_acc_auth'].'</p>';
		}
		else{
			echo '
<table cellspacing="0">
	<thead>
		<tr>
			<td>Account ID</td>
			<td>Gruppe</td>
			<td></td>
		</tr>
	</thead>
	<tbody>';
			while($result = odbc_fetch_array($select)){
				echo '
		<tr>
			<td>'.$result['account'].'</td>
			<td>'.getAuth($result['m_chLoginAuthority']).'</td>
			<td><a href="list_database.php?GetAuthAccChar&RemAccAuth='.mssql_escape_string($result['account']).'">'.$lang['db_rem_auth'].'</a></td>
		</tr>';
			}
			echo '
	</tbody>
</table>';
		}
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
		$select = odbc_exec($odbc_connect, 'SELECT m_szname, account, m_chAuthority from [character_tbl] where [isblock] =\'F\' and [m_chAuthority] !=\'F\' order by [m_chAuthority] desc');
		echo '<h2>Charaktere mit Rechten</h2>';
		if( odbc_num_rows($select) == 0 ){
			echo '<p class="fail">'.$lang['db_no_vhar_auth'].'</p>';
		}else{
			echo '
<table cellspacing="0">
	<thead>
		<tr>
			<td>Charakter</td>
			<td>Account ID</td>
			<td>Gruppe</td>
			<td></td>
		</tr>
	</thead>
	<tbody>';
			while($result = odbc_fetch_array($select)){
				echo '
		<tr class="row">
			<td>'.$result['m_szname'].'</td>
			<td>'.$result['account'].'</td>
			<td>'.getAuth($result['m_chAuthority']).'</td>
			<td><a href="list_database.php?GetAuthAccChar&RemCharAuth='.mssql_escape_string($result['m_szname']).'">'.$lang['db_rem_auth'].'</a></td>
		</tr>';
			}
			echo '
	</tbody>
</table>';
		}
		echo '<br><a href="list_database.php">'.$lang['panel_back'].'</a>';
	}
	elseif( isset($_GET['TradeLogs']) ){
		if( isset($_GET['From']) || isset($_GET['ItemID']) || isset($_GET['To']) ){
			odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['log'] . ']');
			$check = false;
			// From
			if( isset($_GET['From']) && !empty($_GET['From']) && empty($_GET['ItemID']) && empty($_GET['To']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [m_szName] =\''.mssql_escape_string($_GET['From']).'\' Order by [s_date] desc');
				$check = true;
			// To
			}elseif( isset($_GET['To']) && !empty($_GET['To']) && empty($_GET['ItemID']) && empty($_GET['From']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [m_GetszName] =\''.mssql_escape_string($_GET['To']).'\' Order by [s_date] desc');
				$check = true;
			// Item ID
			}elseif( empty($_GET['To']) && isset($_GET['ItemID']) && !empty($_GET['ItemID']) && empty($_GET['From']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [Item_Name] =\''.mssql_escape_string($_GET['ItemID']).'\' Order by [s_date] desc');
				$check = true;
			// From + Item ID
			}elseif( isset($_GET['From']) && !empty($_GET['From']) && isset($_GET['ItemID']) && !empty($_GET['ItemID']) && empty($_GET['To']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [m_szName] =\''.mssql_escape_string($_GET['From']).'\' AND [Item_Name] =\''.mssql_escape_string($_GET['ItemID']).'\' order by [s_date] desc');
				$check = true;
			// To + Item ID
			}elseif( isset($_GET['To']) && !empty($_GET['To']) && isset($_GET['ItemID']) && !empty($_GET['ItemID']) && empty($_GET['From']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [m_GetszName] =\''.mssql_escape_string($_GET['To']).'\' AND [Item_Name] =\''.mssql_escape_string($_GET['ItemID']).'\' order by [s_date] desc');
				$check = true;
			// From + Item ID + To
			}elseif( isset($_GET['From']) && !empty($_GET['From']) && isset($_GET['ItemID']) && !empty($_GET['ItemID']) && isset($_GET['To']) && !empty($_GET['To']) ){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 200 * FROM [LOG_ITEM_TBL] WHERE [m_szName] =\''.mssql_escape_string($_GET['From']).'\' AND [Item_Name] =\''.mssql_escape_string($_GET['ItemID']).'\' AND [m_GetszName] =\''.mssql_escape_string($_GET['To']).'\' order by [s_date] desc');
				$check = true;
			}else{
				echo '<div class="fail">'.$lang['db_gm_log_fail'].'</div>';
			}
			if( $check ){
				echo '<table id="table" style="width: 60%;">
						<tr>
							<td id="key">'.$lang['db_trade_user_from'].'</td>
							<td id="key">'.$lang['db_trade_user_to'].'</td>
							<td id="key">'.$lang['db_trade_item_id'].'</td>
							<td id="key">'.$lang['db_trade_item_count'].'</td>
							<td id="key">'.$lang['db_trade_item_serial'].'</td>
							<td id="key">'.$lang['db_trade_date'].'</td>
						</tr>';
				while($result = odbc_fetch_array($select)){
					echo '<tr class="row">
							<td id="value">'.$result['m_szName'].'</td>
							<td id="value">'.$result['m_GetszName'].'</td>
							<td id="value">'.$result['Item_Name'].'</td>
							<td id="value">'.$result['Item_count'].'</td>
							<td id="value">'.$result['Item_UniqueNo'].'</td>
							<td id="value">'.date('Y/m/d H:i', strtotime($result['s_date'])).'</td>
						  </tr>';
				}
				echo '</table>';
			}
			echo '<br><a href="list_database.php?TradeLogs">'.$lang['panel_back'].'</a>';
		} else {
			echo '<form method="get"><table id="table">
					<tr>
						<td>Von User:</td><td><input type="text" name="From" /></td>
					</tr>
					<tr>
						<td>An User:</td><td><input type="text" name="To" /></td>
					</tr>
					<tr>
						<td>Item ID:</td><td><input type="text" name="ItemID" /></td>
					</tr>
					<tr>
						<td></td><td><input type="submit" name="TradeLogs" value="Trade Logs"></td>
					</tr>
				  </table></form>';
			echo '<br><a href="list_database.php">'.$lang['panel_back'].'</a>';
		}
	}
	elseif( isset($_GET['PrivateMessage']) ){
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['web'] . ']');
		
		if( isset($_GET['del']) && isset($_GET['id']) && !empty($_GET['id']) ){
			odbc_exec($odbc_connect, 'UPDATE [WEB_NICK_MESSAGE] SET [deleted] =\'1\' WHERE [id]=\''.mssql_escape_string($_GET['id']).'\'');
			echo '<div class="success">'.$lang['db_priv_del'].'</div>';
		}
		if( isset($_GET['id']) && !empty($_GET['id']) && !isset($_GET['del']) ){
			$message = odbc_fetch_array(odbc_exec($odbc_connect, 'SELECT * FROM [WEB_NICK_MESSAGE] WHERE [id]=\''.mssql_escape_string($_GET['id']).'\''));
			echo '<table id="table">
					<tr><td id="key">'.$lang['db_priv_titel'].':</td><td id="value">'.$message['titel'].'</td></tr>
					<tr><td id="key">'.$lang['db_priv_date'].':</td><td id="value">'.$message['datum'].'</td></tr>
					<tr><td id="key">'.$lang['db_priv_sender'].':</td><td id="value">'.$message['nick_from'].'</td></tr>
				  </table>
				  <br>
				  <b>Nachricht:</b><br>'.$message['nachricht'].'';
			echo '<br><br><a href="list_database.php?PrivateMessage">'.$lang['panel_back'].'</a>';
		}else{		
			$select = odbc_exec($odbc_connect, 'SELECT * FROM [WEB_NICK_MESSAGE] order by datum desc');
			$unread = odbc_exec($odbc_connect, 'SELECT * FROM [WEB_NICK_MESSAGE] WHERE [gelesen] =\'0\'');
			$deleted = odbc_exec($odbc_connect, 'SELECT * FROM [WEB_NICK_MESSAGE] WHERE [deleted] =\'1\'');
			echo '<table id="table">
					<tr><td id="key">'.$lang['db_priv_message'].':</td><td id="value">'.odbc_num_rows($select).'</td></tr>
					<tr><td id="key">'.$lang['db_priv_read'].':</td><td id="value">'.odbc_num_rows($unread).'</td></tr>
					<tr><td id="key">'.$lang['db_priv_msg_del'].':</td><td id="value">'.odbc_num_rows($deleted).'</td></tr>
				  </table>';
			echo '<hr>';
			echo '<table id="table" style="width: 100%;">
					<tr>
						<td id="key">'.$lang['db_priv_dfrom'].'</td>
						<td id="key">'.$lang['db_priv_dto'].'</td>
						<td id="key">'.$lang['db_priv_dtitel'].'</td>
						<td id="key">'.$lang['db_priv_dmsg'].'</td>
						<td id="key">'.$lang['db_priv_dread'].'</td>
						<td id="key">'.$lang['db_priv_ddel'].'</td>
						<td id="key">'.$lang['db_priv_ddate'].'</td>
						<td id="key"></td>
					</tr>';
			while( $result = odbc_fetch_array($select) ){
				$titel = preg_replace('(<.*/>)', '', $result['titel']);
				$message = preg_replace('(<.*/>)', '', $result['nachricht']);
				if(strlen($titel) > 10)
					$titel = substr($titel, 0, 10).'...';
				if(strlen($message) > 10)
					$message = substr($message, 0, 10).'...';
				echo '<tr class="row">
						<td id="value">'.$result['nick_from'].'</td>
						<td id="value">'.$result['nick_to'].'</td>
						<td id="value"><a href="list_database.php?PrivateMessage&id='.$result['id'].'">'.$titel.'</a></td>
						<td id="value">'.$message.'</td>
						<td id="value">'.ReturnMsg($result['gelesen']).'</td>
						<td id="value">'.ReturnMsg($result['deleted']).'</td>
						<td id="value">'.date('Y/m/d H:i', strtotime($result['datum'])).'</td>';
					if( $result['deleted'] == 0 )
						echo '<td id="value"><a href="list_database.php?PrivateMessage&del&id='.$result['id'].'"><img src="../img/delete.png"></a></td>';
					else
						echo '<td id="value"></td>';
					echo '</tr>';
			}
			echo '</table>';
			echo '<br><br><a href="list_database.php">'.$lang['panel_back'].'</a>';
		}
	}
	elseif(isset($_GET['regist'])) {
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['web'] . ']');
		if(!isset($_GET['page'])) {$_GET['page'] = 1;}
		$page = $_GET['page'];
		$perpage = 50;
		$select = odbc_exec($odbc_connect, 'SELECT * FROM [VALIDATE] WHERE type = 0 ORDER BY timestamp DESC');
		$resultset = array();
		$counter = 0;
		
		
		echo '
<h2>Durchsuche die Registrationen</h2>
<form method="post">
	<input type="text" name="inputField" placeholder="Account oder E-Mail"/>
	<input type="submit" name="searchForRegistrations" value="Suche starten" />
</form>
<br />';


		if(isset($_POST['searchForRegistrations']) AND !empty($_POST['inputField'])) {
			$strStringForSearching = mssql_escape_string($_POST['inputField']);
			$dbQuery = 'SELECT * FROM [VALIDATE] WHERE [account] LIKE \'%' . $strStringForSearching . '%\' OR [fieldAlfa] = \'' . $strStringForSearching . '\' ORDER BY [timestamp] DESC';
			$dbExecute = odbc_exec($odbc_connect, $dbQuery);
			if(odbc_num_rows($dbExecute) > 0) {
				echo '
<table cellspacing="0">
	<thead>
		<tr>
			<td>Account</td>
			<td>E-Mail</td>
			<td class="center"><img src="../images/date.png" /> Datum / Uhrzeit</td>
		</tr>
	</thead>
	<tbody>';
			while($dbOutput = odbc_fetch_array($dbExecute)) {
					echo '
		<tr>
			<td>'.$dbOutput['account'].'</td>
			<td>'.$dbOutput['fieldAlfa'].'</td>
			<td align="center">'.date('d.m.Y, H:i', $dbOutput['timestamp']).' Uhr</td>
		</tr>';
				}
				echo '
	</tbody>
</table>
<br />';
			}
			else {
				echo '<p class="fail">Kein Eintrag gefunden.</p>';
			}
		}

		while($row = odbc_fetch_array($select)) {$resultset[$counter++] = $row;}
		$all = odbc_exec($odbc_connect, 'SELECT COUNT([type]) as count FROM [VALIDATE] WHERE type = 0');
		$count = odbc_result($all, 'count');
		$countpages = $count / $perpage;
		echo '
<h2>Registrationen: Auf Validierung wartend</h2>
<table cellspacing="0">
	<thead>
		<tr>
			<td></td>
			<td>Account</td>
			<td>E-Mail</td>
			<td class="center"><img src="../images/date.png" /> Datum / Uhrzeit</td>
			<td colspan="2" class="center">Aktionen</td>
		</tr>
	</thead>
	<tbody>';
		for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
			if(isset($resultset[$i])) {			
				echo '
		<tr id="regid_'.$i.'">
			<td style="line-height:20px;">#'.$i.'</td>
			<td>'.$resultset[$i]['account'].'</td>
			<td>'.$resultset[$i]['fieldAlfa'].'</td>
			<td class="center">'.date('d.m.Y, H:i', $resultset[$i]['timestamp']).' Uhr</td>
			<td class="center"><a href="javascript:acceptValidation(\''.$i.'\',\''.$resultset[$i]['key'].'\');" title="Validieren" rel="tooltip"><img src="../images/add.png" alt="" /></a></td>
			<td class="center"><a href="javascript:denyValidation(\''.$i.'\',\''.$resultset[$i]['key'].'\');" title="Anfrage verwerfen" rel="tooltip"><img src="../images/delete.png" alt="" /></a></td>
		</tr>';
			}
		}
		echo '
	</tbody>
</table>';
		for($i=0; $i < $countpages; $i++) {
			$k = $i + 1;
			if(strlen($k) == 1) {$k = '0'.$k;} if($k == 51) {echo '<br /><br />';}
			if($page == $k) {echo '<p class="page">'.$k.'</p> ';} 
			else {echo '<p class="page"><a href="list_database.php?regist&page='.$k.'">'.$k.'</a></p>';}
		}
	}
	elseif(isset($_GET['logins'])){
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['web'] . ']');
		if(!isset($_GET['page'])) {$_GET['page'] = 1;}
		$page = $_GET['page'];
		$perpage = 20;
		$select = odbc_exec($odbc_connect, 'SELECT * FROM [LOG_LOGIN] ORDER BY [timestamp] DESC');
		$resultset = array();
		$counter = 0;
	
		echo '
<h2>Durchsuche die Websitelogins</h2>
<form method="post">
	<input type="text" name="inputField" placeholder="Account oder IP"/>
	<input type="submit" name="searchForWebsiteLogins" value="Suche starten" />
</form>
<br />';

		
		if(isset($_POST['searchForWebsiteLogins']) AND !empty($_POST['inputField'])) {
			$strStringForSearching = mssql_escape_string($_POST['inputField']);
			$dbQuery = 'SELECT * FROM [LOG_LOGIN] WHERE [account] LIKE \'%' . $strStringForSearching . '%\' OR [ip] = \'' . $strStringForSearching . '\' ORDER BY [timestamp] DESC';
			$dbExecute = odbc_exec($odbc_connect, $dbQuery);
			if(odbc_num_rows($dbExecute) > 0) {
				echo '
<table cellspacing="0">
	<thead>
		<tr>
			<td>Account</td>
			<td>IP / Host</td>
			<td>Browser</td>
			<td><img src="../images/date.png" /> Datum / Uhrzeit</td>
		</tr>
	</thead>
	<tbody>';
				while($dbOutput = odbc_fetch_array($dbExecute)) {
					echo '
		<tr class="body">
			<td>' . $dbOutput['account'] . '</td>
			<td style="overflow:hidden;">'.$dbOutput['ip'].'<br />'.$dbOutput['host'].'</td>
			<td style="overflow:hidden;">'.$dbOutput['browser'].'</td>
			<td>'.date('d.m.Y, H:i', $dbOutput['timestamp']).' Uhr</td>
		</tr>';
				}
				echo '
	</tbody>
</table>';
			}
			else {
				echo 'Kein Eintrag gefunden.';
			}
		}
	}
	elseif( isset($_GET['GSRanking']) ){
		if( isset($_GET['nID']) ){
			odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
			$select = odbc_exec($odbc_connect, 'SELECT a.PlayerID, a.Point, a.Reward, b.m_szGuild FROM [tblCombatJoinPlayer] a, [GUILD_TBL] b WHERE a.GuildID = b.m_idGuild and a.CombatID = \''.mssql_escape_string($_GET['nID']).'\'');
			echo '<table id="table" style="width: 50%;">
					<tr>
						<td id="key">'.$lang['db_gs_player'].'</td>
						<td id="key">'.$lang['db_gs_points'].'</td>
						<td id="key">'.$lang['db_gs_winner'].'</td>
						<td id="key">'.$lang['db_gs_guild'].'</td>
					</tr>';
			while( $result = odbc_fetch_array($select) ){
				echo '<tr class="row">
						<td id="value">'.GetCharacterName($result['PlayerID']).'</td>
						<td id="value">'.$result['Point'].'</td>
						<td id="value">'.$result['Reward'].'</td>
						<td id="value">'.$result['m_szGuild'].'</td>
					</tr>';
			}
			echo '</table>';
			echo '<br><br><a href="list_database.php?GSRanking">'.$lang['panel_back'].'</a>';
		}
		elseif(isset($_GET['DeleteLog'])){
			if( !$_CONFIG['admin_deleteGSLogs'] ){
				echo '
				<div class="fail">'.$lang['db_del_gs_log_forbidden'].'</div>
				<br><br><a href="list_database.php?GSRanking">'.$lang['panel_back'].'</a>';
			}
			else {
				ClearGuildSiegeLog();
				echo '<div class="success">'.$lang['db_del_gs_log_deleted'].'</div>';
			}
		}
		else {
			echo '<a href="list_database.php?GSRanking&DeleteLog"><input type="submit" name="DelLog" value="'.$lang['db_del_gs_log'].'" /></a><hr>';
	
			odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
			$select = odbc_exec($odbc_connect, 'SELECT a.CombatID, a.CombatFee, a.Point, a.StraightWin, b.m_szGuild, b.m_nLevel FROM [tblCombatJoinGuild] a, [GUILD_TBL] b WHERE a.GuildID = b.m_idGuild order by a.CombatID desc');
			echo '<table id="table" style="width: 50%;">
					<tr>
						<td id="key">'.$lang['db_gs_id'].'</td>
						<td id="key">'.$lang['db_gs_guild'].'</td>
						<td id="key">'.$lang['db_gs_level'].'</td>
						<td id="key">'.$lang['db_gs_winner'].'</td>
						<td id="key">'.$lang['db_gs_points'].'</td>
						<td id="key">'.$lang['db_gs_fee'].'</td>
					</tr>';
			while( $result = odbc_fetch_array($select) ){
				echo '<tr class="row">
						<td id="value"><a href="list_database.php?GSRanking&nID='.$result['CombatID'].'">'.$result['CombatID'].' - Info</a></td>
						<td id="value">'.$result['m_szGuild'].'</td>
						<td id="value">'.$result['m_nLevel'].'</td>
						<td id="value">'.$result['StraightWin'].'</td>
						<td id="value">'.$result['Point'].'</td>
						<td id="value">'.$result['CombatFee'].'</td>
					</tr>';
			}
			echo '</table>
			<br><br><a href="list_database.php">'.$lang['panel_back'].'</a>';
		}
	}
	else {
	
	odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
	$str = 'SELECT * FROM [CHARACTER_TBL] WHERE ';
	$male_chars = odbc_exec($odbc_connect, $str.'[m_dwSex] = 0');
	$female_chars = odbc_exec($odbc_connect, $str.'[m_dwSex] = 1'); 
	
	function retJob($job){
		global $odbc_connect;
		$jobs = odbc_exec($odbc_connect, 'SELECT * FROM [CHARACTER_TBL] WHERE [m_nJob] = \''.$job.'\'');
		return odbc_num_rows($jobs);
	}
	
	echo '<h2>'.$lang['stat_char'].'</h2>';
	echo '<table border="0">
			<tr><td>'.$lang['sex_male'].':</td><td>'.odbc_num_rows($male_chars).'</td></tr>
			<tr><td>'.$lang['sex_female'].':</td><td>'.odbc_num_rows($female_chars).'</td></tr>
		  </table>';
	echo '<h2>'.$lang['stat_job'].'</h2>';
	echo '<table border="0"><tr><td><b>'.$job[0].':</b></td><td>'.retJob(0).'</td></tr></table>';
	echo '<table border="0"><tr>';
	echo '<td><table border="0">
			<tr><td><b>'.$job[1].':</b></td><td>'.retJob(1).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].':</td><td style="font-size: 11px">'.retJob(6).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].' (M):</td><td style="font-size: 11px">'.retJob(16).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].' (H):</td><td style="font-size: 11px">'.retJob(24).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[32].' (L):</td><td style="font-size: 11px">'.retJob(32).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].':</td><td style="font-size: 11px">'.retJob(7).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].' (M):</td><td style="font-size: 11px">'.retJob(17).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].' (H):</td><td style="font-size: 11px">'.retJob(25).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[33].' (L):</td><td style="font-size: 11px">'.retJob(33).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[2].':</b></td><td>'.retJob(2).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].':</td><td style="font-size: 11px">'.retJob(8).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].' (M):</td><td style="font-size: 11px">'.retJob(18).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].' (H):</td><td style="font-size: 11px">'.retJob(26).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[34].' (L):</td><td style="font-size: 11px">'.retJob(34).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].':</td><td style="font-size: 11px">'.retJob(9).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].' (M):</td><td style="font-size: 11px">'.retJob(19).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].' (H):</td><td style="font-size: 11px">'.retJob(27).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[35].' (L):</td><td style="font-size: 11px">'.retJob(35).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[3].':</b></td><td>'.retJob(3).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].':</td><td style="font-size: 11px">'.retJob(10).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].' (M):</td><td style="font-size: 11px">'.retJob(20).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].' (H):</td><td style="font-size: 11px">'.retJob(28).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[36].' (L):</td><td style="font-size: 11px">'.retJob(36).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].':</td><td style="font-size: 11px">'.retJob(11).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].' (M):</td><td style="font-size: 11px">'.retJob(21).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].' (H):</td><td style="font-size: 11px">'.retJob(29).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[37].' (L):</td><td style="font-size: 11px">'.retJob(37).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[4].':</b></td><td>'.retJob(4).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].':</td><td style="font-size: 11px">'.retJob(12).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].' (M):</td><td style="font-size: 11px">'.retJob(22).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].' (H):</td><td style="font-size: 11px">'.retJob(30).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[38].' (L):</td><td style="font-size: 11px">'.retJob(38).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].':</td><td style="font-size: 11px">'.retJob(13).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].' (M):</td><td style="font-size: 11px">'.retJob(23).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].' (H):</td><td style="font-size: 11px">'.retJob(31).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[39].' (L):</td><td style="font-size: 11px">'.retJob(39).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</tr></table>
		<br />
		<h2>Referrerlinks: Auswertung</h2>
		<img src="../../includes/charts/referrer.php" alt="Referrerlinks: Auswertung"/>';
	}
?>
</div>
<?php include('inc/footer.php'); ?>