<?php
	$break = explode('/', $_SERVER["SCRIPT_NAME"]);
	if($break[count($break) - 1] != "index.php") { header("Location: ../index.php"); exit(); } 
?>
			<div class="componentheading">Universe Query Admin</div>
<?php
	if(isset($_SESSION['errormsg']))
	{
?>
			<div class="module_menu">
				<div>
					<div>
						<div>
							<h3>Notification</h3>
								<b><?php echo $_SESSION['errormsg']; ?></b>
						</div>
					</div>
				</div>
			</div>
<?php
		unset($_SESSION['errormsg']);
	}

	if(!LOG_PLAYER_DATA)
	{
?>
			<div class="module_menu">
				<div>
					<div>
						<div>
							<h3>Player Data Logging is Disabled</h3>
							The universe administrator has disabled the <i><b>LOG_PLAYER_DATA</b></i> option.<br>
							This might mean that your queries will yeild no results.
						</div>
					</div>
				</div>
			</div>
<?php
	}
?>
			<div class="module_menu">
				<div>
					<div>
						<div>
							<h3>Query Access Logs</h3>
		  <h1>Search for Player Access Data</h1><hr><br>
		  <form name="adminQueryForm" id="adminQueryForm" action="process.php" method="POST">
		  Search By: <select name="searchby" id="searchby" onchange="if(document.forms['adminQueryForm'].searchby.value == 'browse') document.forms['adminQueryForm'].query.value='Browse All';if(document.forms['adminQueryForm'].searchby.value == 'browse') document.forms['adminQueryForm'].submit();">
<option value="client_id"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "client_id") echo " selected"; ?>>Nexgen Client ID</option>
<option value="playername"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "playername") echo " selected"; ?>>Player Name</option>
<option value="player_ip"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "player_ip") echo " selected"; ?>>Player IP</option>
<option value="hostname"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "hostname") echo " selected"; ?>>Player Hostname</option>
<option value="server_name"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "server_name") echo " selected"; ?>>Server Name</option>
<option value="browse"<?php if(isset($_SESSION['adminQueryField']) && $_SESSION['adminQueryField'] == "browse") echo " selected"; ?>>Browse All</option>
</select><br><br>
		  Search For: <input type="text" name="query" id="query" size="50" value="<?php if(isset($_SESSION['adminQuery'])) echo $_SESSION['adminQuery']; ?>"><br><br>
		  Search Scope: <select name="wide" id="wide">
<option value="false"<?php if(!isset($_SESSION['adminQueryWide'])) echo " selected"; ?>>Exact Matches</option>
<option value="true"<?php if(isset($_SESSION['adminQueryWide'])) echo " selected"; ?>>Partial Matches</option>
</select><br>
		  <input type="submit" value="Search">
		  <input type="hidden" name="pageno" id="pageno" value="0">
		  <input type="hidden" name="adminquerysubmit" value="1"><br>
<?php
	if(isset($_SESSION['adminQuery']))
	{
		$database->printAdminQuery($_SESSION['pageno'],$_SESSION['adminQueryField'],$_SESSION['adminQueryWide'],mysql_real_escape_string($_SESSION['adminQuery']));
		unset($_SESSION['adminQueryField']);
		unset($_SESSION['adminQueryWide']);
		unset($_SESSION['adminQuery']);
		unset($_SESSION['pageno']);
	}
?>
		</form>
						</div>
					</div>
				</div>
			</div>
<?php if(isset($_SESSION['adminActions'])) { echo "<script type='text/javascript'>window.onload = function (){location.replace('index.php?p=queryadmin#content');}</script>"; } ?>
		<a name="content"></a>
			<div class="module_menu">
				<div>
					<div>
						<div>
							<h3>Query Administrative Action Logs</h3>
		  <h1>Search for Player Moderation Data</h1><hr><br>
		  <form name="adminActionsForm" id="adminActionsForm" action="process.php" method="POST">
		  Search By: <select name="searchby" id="searchby" onchange="if(document.forms['adminActionsForm'].searchby.value == 'browse') document.forms['adminActionsForm'].query.value='Browse All';if(document.forms['adminActionsForm'].searchby.value == 'browse') document.forms['adminActionsForm'].submit();if(document.forms['adminActionsForm'].searchby.value == 'browse_muted') document.forms['adminActionsForm'].query.value='Browse Muted';if(document.forms['adminActionsForm'].searchby.value == 'browse_muted') document.forms['adminActionsForm'].submit();if(document.forms['adminActionsForm'].searchby.value == 'browse_renamed') document.forms['adminActionsForm'].query.value='Browse Renamed';if(document.forms['adminActionsForm'].searchby.value == 'browse_renamed') document.forms['adminActionsForm'].submit();if(document.forms['adminActionsForm'].searchby.value == 'browse_kicked') document.forms['adminActionsForm'].query.value='Browse Kicked';if(document.forms['adminActionsForm'].searchby.value == 'browse_kicked') document.forms['adminActionsForm'].submit();if(document.forms['adminActionsForm'].searchby.value == 'browse_banned') document.forms['adminActionsForm'].query.value='Browse Banned';if(document.forms['adminActionsForm'].searchby.value == 'browse_banned') document.forms['adminActionsForm'].submit();">
<option value="performer_client_id"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "performer_client_id") echo " selected"; ?>>Performer Nexgen Client ID</option>
<option value="performer_playername"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "performer_playername") echo " selected"; ?>>Performer Name</option>
<option value="performer_player_ip"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "performer_player_ip") echo " selected"; ?>>Performer IP</option>
<option value="performer_hostname"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "performer_hostname") echo " selected"; ?>>Performer Hostname</option>
<option value="receiver_client_id"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "receiver_client_id") echo " selected"; ?>>Receiver Nexgen Client ID</option>
<option value="receiver_playername"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "receiver_playername") echo " selected"; ?>>Receiver Name</option>
<option value="receiver_player_ip"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "receiver_player_ip") echo " selected"; ?>>Receiver IP</option>
<option value="receiver_hostname"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "receiver_hostname") echo " selected"; ?>>Receiver Hostname</option>
<option value="server_name"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "server_name") echo " selected"; ?>>Server Name</option>
<option value="browse_muted"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "browse_muted") echo " selected"; ?>>Browse Muted</option>
<option value="browse_renamed"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "browse_renamed") echo " selected"; ?>>Browse Renamed</option>
<option value="browse_kicked"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "browse_kicked") echo " selected"; ?>>Browse Kicked</option>
<option value="browse_banned"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "browse_banned") echo " selected"; ?>>Browse Banned</option>
<option value="browse"<?php if(isset($_SESSION['adminActionsField']) && $_SESSION['adminActionsField'] == "browse") echo " selected"; ?>>Browse All</option>
</select><br><br>
		  Search For: <input type="text" name="query" id="query" size="50" value="<?php if(isset($_SESSION['adminActions'])) echo $_SESSION['adminActions']; ?>"><br><br>
		  Search Scope: <select name="wide" id="wide">
<option value="false"<?php if(!isset($_SESSION['adminActionsWide'])) echo " selected"; ?>>Exact Matches</option>
<option value="true"<?php if(isset($_SESSION['adminActionsWide'])) echo " selected"; ?>>Partial Matches</option>
</select><br>
		  <input type="submit" value="Search">
		  <input type="hidden" name="pageno" id="pageno" value="0">
		  <input type="hidden" name="adminactionssubmit" value="1"><br>
<?php
	if(isset($_SESSION['adminActions']))
	{
		$database->printActionsQuery($_SESSION['pageno'],$_SESSION['adminActionsField'],$_SESSION['adminActionsWide'],mysql_real_escape_string($_SESSION['adminActions']));
		unset($_SESSION['adminActionsField']);
		unset($_SESSION['adminActionsWide']);
		unset($_SESSION['adminActions']);
		unset($_SESSION['pageno']);
	}
?>
		</form>
						</div>
					</div>
				</div>
			</div>