<?php
	$break = explode('/', $_SERVER["SCRIPT_NAME"]);
	if($break[count($break) - 1] != "index.php") { exit(); }
	
	if(!isset($_GET['user']))
	{
		echo '<meta http-equiv="refresh" content="0;url=index.php?p=admin">';
		die();
	}
	
	$userinfo = $database->getUserInfoByID($_GET['user']);
	if($userinfo == NULL)
	{
		$userinfo['username'] = "Deleted Account";
	}
?>
		  <h1>Modify User Account: <?php echo $userinfo['username']; ?></h1><hr><br>
<?php
if(isset($_SESSION['useredit']))
{
   unset($_SESSION['useredit']);
   
   echo "<h2>Account Successfully Updated</h1>";
   if($userinfo['username'] != "Deleted Account")
   {
	  echo "<a href=\"index.php?p=admin\">Go Back To Admin Page</a><br><a href=\"index.php?p=admin&admin=modify&user=".$_GET['user']."\">Make More Changes To This User</a><br>";
   }
}
else if($userinfo['username'] != "Deleted Account")
{
	if($form->num_errors > 0){
		 echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font><br>";
	}
?>
<form action="process.php" method="POST">
<h1>Password Change</h1>
If you wish to this user's password, please fill out the following fields.
If you are not needing to change the password, just leave this section blank.
<br>
<br>
New Password:<br>
<input type="password" name="newpass" maxlength="30" size="50" value="<?php echo $form->value("newpass"); ?>"> <?php echo $form->error("newpass"); ?><br><br>
<h1>General Settings</h1>
User Rights: <select name="userlevel">
<option value="1"<?php if($userinfo['userlevel'] == 1) echo " selected"; ?>>Normal User</option>
<option value="2"<?php if($userinfo['userlevel'] == 2) echo " selected"; ?>>Query Admin</option>
<option value="3"<?php if($userinfo['userlevel'] == 3) echo " selected"; ?>>Universe Administrator</option>
</select><br>
<input type="checkbox" name="autoaccept" value="1"<?php if($userinfo['autoaccept_buddies'] == 1) echo " checked"; ?>/> <b>Automatically accept new buddy requests</b><br>
<input type="checkbox" name="emailaboutbuddies" value="1"<?php if($userinfo['emailabout_buddies'] == 1) echo " checked"; ?>/> <b>Send me e-mail notifications about buddy requests</b><br><br>
Username:<br><input type="text" name="user" maxlength="50" size="75" value="<?php
if($form->value("user") == ""){
   echo $userinfo['username'];
}else{
   echo $form->value("user");
}
?>"> <?php echo $form->error("user"); ?><br><br>
Email:<br><input type="text" name="email" maxlength="50" size="75" value="<?php
if($form->value("email") == ""){
   echo $userinfo['email'];
}else{
   echo $form->value("email");
}
?>"> <?php echo $form->error("email"); ?><br><br>
<input type="hidden" name="subadminedit" value="1">
<input type="hidden" name="id" value="<?php echo $_GET['user']; ?>">
<input type="submit" value="Save Settings">
</form>
<br><hr>
<form action="process.php" method="POST">
<h1>Account Removal</h1>
If you would like to close this account, click the button below.
<br><b>This action can not be undone!</b><br><br>
<input type="hidden" name="subadmindelete" value="1">
<input type="hidden" name="id" value="<?php echo $_GET['user']; ?>">
<input type="button" value="Delete This Account" onclick="if(confirmSubmit('Are you sure you want to delete this account?')) { if(confirmSubmit('Last warning! This cannot be undone! ARE YOU SURE?')) { submit(); } }">
</form>

<?php
}
?>