<?php
if($__TOKEN = "hardcodeshitbykernstudios"){
echo '<h2 class="bg-h2-1 bot">Login Log</h2>';
	if(isset($_SESSION['nEMID'])){
	$conn = sqlsrv_connect($__CONFIG['SQLHost'], array("Database"=>$__CONFIG['SQLDB'], "UID"=>$__CONFIG['SQLUID'], "PWD"=>$__CONFIG['SQLPWD']));
	if(!$conn){
					echo print_r(sqlsrv_errors(), true);
					exit();
				}
		$checkAccount = sqlsrv_query($conn, "SELECT nEMID, sUsername, sEmail, dDate, nAGPoints FROM tAccounts WHERE nEMID = ?;", array($_SESSION['nEMID']), array("Scrollable" => SQLSRV_CURSOR_KEYSET));
		$fetchAccount = sqlsrv_fetch_array($checkAccount);
		$checkCharacter = sqlsrv_query($conn, "SELECT nCharNo, sID, nLevel, nMoney FROM w00_Character..tCharacter WHERE nUserNo = ? AND bDeleted = 0;", array($_SESSION['nEMID']));
		
		If (!$fetchAccount['nEMID'] == $_SESSION['nEMID']){
			
			echo '<center>Game Account not activated!!!</center>';
			echo '<center>
			<form method="post">
			<input type="submit" name="submit" value="Activate Account" class="myButton">
			</form>
			</center>';
			if (isset($_POST['submit']))
			{
				$insert = sqlsrv_query($conn, "INSERT INTO tAccounts (nEMID, sUsername, sUserPass, sUserPassSalt, sEmail, sIP, nAuthID) VALUES (?, ?, ?, ?, ?, ?, ?);", array($_SESSION['nEMID'], $_SESSION['UserID'], 'CheckForum', 'Forum', 'CheckForum', getRemoteIP(), 1));
				showMessage('success', '<strong>Welcome</strong> to Noctis Gaming! Successfully activated.', 3, 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
				if(!$insert){
					echo ('Insert Error!!!');
				}
			}
			
		}elseif($fetchAccount['nEMID'] == $_SESSION['nEMID']){
		echo '<center>Account Information:<br><br><table width="400px;"><tr><th style="color: red;">Username:</th><th>'.$fetchAccount['sUsername'].'</th></tr>';
		echo '<tr><th style="color: red;">Email:</th><th>'.$fetchAccount['sEmail'].'</th></tr>';
		echo '<tr><th style="color: red;">SignUp Date:</th><th>'.date_format($fetchAccount['dDate'], 'Y-m-d H:i:s').'</th></tr>';
		echo '<tr><th style="color: red;">Points:</th><th>'.$fetchAccount['nAGPoints'].'</th></tr>';
		echo '<table width="400px;"><tr><th>Character Name</th><th>Level</th><th>Money</th><th>Class</th></tr>';
		while($fetchChar = sqlsrv_fetch_array($checkCharacter)){
			$checkClass = sqlsrv_query($conn, "SELECT nClass FROM w00_Character..tCharacterShape WHERE nCharNo = ?;", array($fetchChar['nCharNo']));
			$fetchClass = sqlsrv_fetch_array($checkClass);
			echo '<tr><th>'.$fetchChar['sID'].'</th><th>'.$fetchChar['nLevel'].'</th><th>'.$fetchChar['nMoney'].'</th><th>'.getClassToString($fetchClass['nClass']).'</th></tr>';
		}
		echo '</table>';
		echo '<br><hr><br>';
		}
	}
}
?>