<?php
	$break = explode('/', $_SERVER["SCRIPT_NAME"]);
	if($break[count($break) - 1] != "index.php") { header("Location: ../index.php"); exit(); } 
?>
			<div class="componentheading">Universal Unreal Account Password Reset</div>
			<div class="module_menu">
				<div>
					<div>
						<div>
							<h3>Password Reset</h3>
<?
/**
 * Forgot Password form has been submitted and no errors
 * were found with the form (the username is in the database)
 */
if(isset($_SESSION['forgotpass'])){
   /**
    * New password was generated for user and sent to user's
    * email address.
    */
   if($_SESSION['forgotpass']){
      echo "<h1>New Password Generated</h1>";
      echo "Your new password has been generated "
          ."and sent to the email associated with your account. If you continue "
		  ."to have difficulties logging in, please contact the ".UNIVERSE_ID." "
		  ."Universe administrator, ".UNIVERSE_ADMIN_NAME." at:<br><br>"
		  ."<a href=\"mailto:".UNIVERSE_ADMIN_EMAIL."\">".UNIVERSE_ADMIN_EMAIL."</a>"
		  ."<br><br>"
          ."<a href=\"index.php\">Proceed To Main Page</a>.";
   }
   /**
    * Email could not be sent, therefore password was not
    * edited in the database.
    */
   else{
      echo "<h1>New Password Failure</h1>";
      echo "There was an error sending you the "
          ."email with the new password, so your password "
		  ."has not been changed. If you continue "
		  ."to have difficulties logging in, please contact the ".UNIVERSE_ID." "
		  ."Universe administrator, ".UNIVERSE_ADMIN_NAME." at:<br><br>"
		  ."<a href=\"mailto:".UNIVERSE_ADMIN_EMAIL."\">".UNIVERSE_ADMIN_EMAIL."</a>"
		  ."<br><br>"
          ."<a href=\"index.php\">Proceed To Main Page</a>.";
   }
       
   unset($_SESSION['forgotpass']);
}
else{

/**
 * Forgot password form is displayed, if error found
 * it is displayed.
 */
?>

A new password will be generated for you and sent to the email address 
associated with your account. To get started, enter your
username and retrieve your secret question. If you are having issues
resetting your password, or your registration e-mail address is no
longer valid, please contact the <?php echo UNIVERSE_ID; ?> Universe administrator,
<?php echo UNIVERSE_ADMIN_NAME; ?> at:<br><br>
<a href="mailto:<?php echo UNIVERSE_ADMIN_EMAIL; ?>"><?php echo UNIVERSE_ADMIN_EMAIL; ?></a>
<br><br><hr><br>
<? echo $form->error("user"); ?>
<form name="forgotpassform" action="process.php" method="POST">
<b>Username or E-Mail Address:</b> <input type="text" name="user" id="user" maxlength="30" value="<? echo $form->value("user"); ?>">
<input type="hidden" name="subforgot" value="1">
<input type="button" value="Retrieve Secret Question" onclick="getAjax('./include/get_secret_question.php?user='+document.forgotpassform.user.value,'scriptoutput')"><br><br>
<span id="scriptoutput">&nbsp;</span><br>
<? echo $form->error("answerq"); ?>
<b>Answer To Secret Question:</b> <input type="text" name="answerq" maxlength="100" value="<? echo $form->value("answerq"); ?>">
<input type="button" value="Get New Password" onclick="document.forgotpassform.submit();return false;">
</form>

<?
}
?>