You may now continue to the Login Page and start playing the game.
Thanks for playing!","Verify Email",false,false,false);
}
$page = gettemplate("verify");
$topnav = "

";
display($page, "Verify Email", false, false, false);
}
function lostpassword() {
if (isset($_POST["submit"])) {
extract($_POST);
$userquery = doquery("SELECT email FROM {{table}} WHERE email='$email' LIMIT 1","users");
if (mysqli_num_rows($userquery) != 1) { die("No account with that email address."); }
$newpass = "";
for ($i=0; $i<8; $i++) {
$newpass .= chr(rand(65,90));
}
$md5newpass = md5($newpass);
$updatequery = doquery("UPDATE {{table}} SET password='$md5newpass' WHERE email='$email' LIMIT 1","users");
if (sendpassemail($email,$newpass) == true) {
display("Your new password was emailed to the address you provided.
Once you receive it, you may Log In and continue playing.
Thank you.","Lost Password",false,false,false);
} else {
display("There was an error sending your new password.
Please check with the game administrator for more information.
We apologize for the inconvience.","Lost Password",false,false,false);
}
die();
}
$page = gettemplate("lostpassword");
$topnav = "

";
display($page, "Lost Password", false, false, false);
}
function changepassword() {
if (isset($_POST["submit"])) {
extract($_POST);
$userquery = doquery("SELECT * FROM {{table}} WHERE username='$username' LIMIT 1","users");
if (mysqli_num_rows($userquery) != 1) { die("No account with that username."); }
$userrow = mysqli_fetch_array($userquery);
if ($userrow["password"] != md5($oldpass)) { die("The old password you provided was incorrect."); }
if (preg_match("/[^A-z0-9_\-]/", $newpass1)==1) { die("New password must be alphanumeric."); } // Thanks to "Carlos Pires" from php.net!
if ($newpass1 != $newpass2) { die("New passwords don't match."); }
$realnewpass = md5($newpass1);
$updatequery = doquery("UPDATE {{table}} SET password='$realnewpass' WHERE username='$username' LIMIT 1","users");
if (isset($_COOKIE["dkgame"])) { setcookie("dkgame", "", time()-100000, "/", "", 0); }
display("Your password was changed successfully.
You have been logged out of the game to avoid cookie errors.
Please log back in to continue playing.","Change Password",false,false,false);
die();
}
$page = gettemplate("changepassword");
$topnav = "

";
display($page, "Change Password", false, false, false);
}
function sendpassemail($emailaddress, $password) {
$controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control");
$controlrow = mysqli_fetch_array($controlquery);
extract($controlrow);
$email = <<