<?php include('inc/header.php'); ?>
<?php echo $lang['gm_titel']; ?>
<div class="container">
<form method="get" style="float: left;">
	Character Name:
	<input type="text" name="char" style="width: 150px;" />
    <input type="submit" value="Search" /><tr>
	<table border="0">
<?php
	echo '<tr><td><input type="radio" name="myRadio" value="all" checked></td><td>'.$lang['gm_cmd_all'].'</td></tr>
		<tr><td><input type="radio" name="myRadio" value="system"></td><td>'.$lang['gm_cmd_system'].'</td>
		<td><input type="radio" name="myRadio" value="out"></td><td>'.$lang['gm_cmd_out'].'</td>
		<td><input type="radio" name="myRadio" value="ci"></td><td>'.$lang['gm_cmd_item'].'</td></tr>
		<tr><td><input type="radio" name="myRadio" value="teleport"></td><td>'.$lang['gm_cmd_teleport'].'</td>
		<td><input type="radio" name="myRadio" value="summon"></td><td>'.$lang['gm_cmd_summon'].'</td>
		<td><input type="radio" name="myRadio" value="chat"></td><td>'.$lang['gm_cmd_chat'].'</td></tr>';
?>
	</table>
</form>
<br style="clear: both;" /><br />
<?php
	if( isset($_GET['char']) ){
		if( !empty($_GET['char']) ){
			echo '<h2>Logs - '.$_GET['char'].'</h2>';
			$m_idPlayer = mssql_escape_string(GetCharacterID($_GET['char']));
			odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['log'] . ']');
			if(isset($_GET['myRadio']) && $_GET['myRadio'] == 'all'){
				$select = odbc_exec($odbc_connect, 'SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=\''.$m_idPlayer.'\' ORDER BY SEQ DESC');
			}else{
				if(isset($_GET['myRadio']) && $_GET['myRadio'] == 'system'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/system %' or [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/sys %' ORDER BY SEQ DESC");
				}elseif(isset($_GET['myRadio']) && $_GET['myRadio'] == 'out'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/out%' ORDER BY SEQ DESC");
				}elseif(isset($_GET['myRadio']) && $_GET['myRadio'] == 'ci'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/createitem %' or [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/ci %' ORDER BY SEQ DESC");
				}elseif(isset($_GET['myRadio']) && $_GET['myRadio'] == 'teleport'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/teleport %' or [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/te %' ORDER BY SEQ DESC");
				}elseif(isset($_GET['myRadio']) && $_GET['myRadio'] == 'summon'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/summon %' or [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/su %' ORDER BY SEQ DESC");
				}elseif(isset($_GET['myRadio']) && $_GET['myRadio'] == 'chat'){
					$select = odbc_exec($odbc_connect, "SELECT TOP 100 * FROM [LOG_GAMEMASTER_TBL] WHERE [m_idPlayer]=".$m_idPlayer." AND [m_szWords] LIKE '/say %' ORDER BY SEQ DESC");
				}
			}
			echo '<table id="table">
				<tr>
					<td id="key" style="width:125px;">'.$lang['gm_date'].'</td>
					<td id="key" style="width:75px;">'.$lang['gm_seq'].'</td>
					<td id="key">'.$lang['gm_command'].'</td>
				</tr>';
			while($result = odbc_fetch_array($select)) {
				$content = $result['m_szWords'];
				//if(strlen($content) > 200)
				//	$content = substr($content, 0, 200).'...';
				echo '<td id="value">'.date('Y/m/d H:i', strtotime($result['s_date'])).'</td>
					<td id="value">'.$result['SEQ'].'</td>
					<td id="value">'.$content.'</td>
				</tr>';
			}
			echo '</table><br/>';
		}else{
			echo '<div class="fail">'.$lang['gm_enter_character'].'</div>';
		}
	}
?>
</div>
<?php include('inc/footer.php'); ?>