This was requested by someone, so...
You will need PEAR packages for these to work.
Packages:
Mail:
Mail_Mime:
So what does this do?
Once a user has input their username and password, it'll send them an email with a link. If they click that link, it will change their password and email it to them.
Why have both MySQL and MySQLi?
Because I'm more familiar and comfortable coding with MySQL.
I'm using cPanel and I can't get it to work, help?!
Make sure you have the PEAR packages installed (can be found on cPanel dash), if you are still having problems then click the PHP Pear Packages in cPanel, find the Path and then add this to the file:
It sends the wrong links in the email?
Add this to your .htaccess
What hash does this use?
md5.
What else do I need for this to work?
The table. Query this:
Where is the code?
MySQL:
MySQLi:
You will need PEAR packages for these to work.
Packages:
Mail:
You must be registered to see links
Mail_Mime:
You must be registered to see links
So what does this do?
Once a user has input their username and password, it'll send them an email with a link. If they click that link, it will change their password and email it to them.
Why have both MySQL and MySQLi?
Because I'm more familiar and comfortable coding with MySQL.
I'm using cPanel and I can't get it to work, help?!
Make sure you have the PEAR packages installed (can be found on cPanel dash), if you are still having problems then click the PHP Pear Packages in cPanel, find the Path and then add this to the file:
PHP:
ini_set('include_path','.:PATH'); // Replace PATH with your path
It sends the wrong links in the email?
Add this to your .htaccess
Code:
RewriteRule ^/account/password/reset/([^/]+)(|/)$ /forgotpassword.php?Reset=$1
What hash does this use?
md5.
What else do I need for this to work?
The table. Query this:
PHP:
CREATE TABLE IF NOT EXISTS `password_resets` (
`username` varchar(50) NOT NULL,
`hash` varchar(200) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Where is the code?
MySQL:
PHP:
<?PHP
require_once("config.php");
// Configuration
$SiteLink = "http://example.com/forgotpassword"; // File MUST be named forgotpassword.php unless you edit the code
$LogoLink = "http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/v2/images/habbologo_whiteR.gif";
$FromEmail = "from@lol.com";
if(isset($_GET['Reset'])) {
$arr = explode("-", $_GET['Reset']);
$Username = mysql_real_escape_string($arr[0]);
$query = mysql_query("SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". mysql_real_escape_string($_GET['Reset']) ."'");
if(mysql_num_rows($query) > 0)
{
$GetEmail = mysql_fetch_assoc(mysql_query("SELECT `mail` FROM `users` WHERE `username` = '". $Username ."'"));
echo $GetEmail['mail'];
GenerateNewPasswordEmail($Username, $GetEmail['mail']);
mysql_query("DELETE FROM `password_resets` WHERE `username` ='". $Username ."'");
echo "A new password has been sent to your email address."; die;
}
else {
echo "Invalid hash.";
echo "SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". mysql_real_escape_string($_GET['Reset']) ."'";
die;
}
}
function GenerateValidationEmail($username, $email, $hash) {
global $SiteLink, $LogoLink;
SendMail($email, $username, '
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
To change your password please click <a href="'. $SiteLink .'/account/password/reset/'. $hash .'">this link to reset your password</a>.
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="100" valign="middle">
<table style="margin-left: 12px;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle">
<table style="background-color: #51b708; height: 50px;" height="50px;" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 100%; vertical-align:middle; border:solid 2px #000000" valign="middle">
<p style="font-family: Verdana,Arial,sans-serif; font-weight: bold; font-size: 18px; color:#ffffff; margin-top: 0; margin-bottom: 0;">
<a style="text-decoration: none; padding:15px 20px; color:#ffffff" href="'. $SiteLink .'/account/password/reset/'. $hash .'">
Reset my Habbo password
</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function GenerateNewPasswordEmail($username, $email) {
global $SiteLink, $LogoLink;
$PlainPassword = substr (md5(uniqid(rand(),1)), 3, 10);
$HashedPassword = md5($PlainPassword);
mysql_query("UPDATE `users` SET `password` ='". $HashedPassword ."' WHERE `username` = '". $username ."'");
SendMail($email, $username, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
Your new password is: <b>'. $PlainPassword .'</b>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function SendMail($email, $username, $Body) {
global $FromEmail;
require_once("Mail.php");
require_once('Mail/mime.php');
$headers = array('From' => $FromEmail, 'Subject' => "Password reset");
$break = "\n";
$mime = new Mail_mime($break);
$mime->setHTMLBody($Body);
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = Mail::factory("mail");
$mail->send($email, $headers, $body);
}
if(isset($_POST['actionForgot'])) {
//
$query = mysql_query("SELECT * FROM `users` WHERE `username` = '". mysql_real_escape_string($_POST['forgottenpw-username']). "' AND `mail` = '". mysql_real_escape_string($_POST['forgottenpw-email']) ."'");
if(mysql_num_rows($query) > 0) {
$hash = mysql_real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand())). "-". sha1(md5(uniqid(rand()))) . "-" . md5(uniqid(rand())). "-" . md5(rand()) ;
mysql_query("INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". mysql_real_escape_string($_POST['forgottenpw-username']) ."', '". $hash."')") or die("INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". mysql_real_escape_string($_POST['forgottenpw-username']) ."', '". mysql_real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand()))."'");
GenerateValidationEmail(mysql_real_escape_string($_POST['forgottenpw-username']), mysql_real_escape_string($_POST['forgottenpw-email']), $hash);
}
else echo "Error";
die;
}
?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Hotelname ~ Home </title>
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/common.css" type="text/css">
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/process.css" type="text/css">
<body id="landing" class="process-template">
<div id="overlay"></div>
<div id="container">
<div class="cb process-template-box clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div id="content">
<div id="header" class="clearfix">
<h1><a href="index.php"></a></h1>
</div><style type="text/css">
div.left-column { float: left; width: 50% }
div.right-column { float: right; width: 49% }
label { display: block }
input { width: 98% }
input.process-button { width: auto; float: right }
</style>
<div id="process-content">
<div class="left-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">Forgotten Your Password?</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>Don't panic! Please enter your account information below and we'll send you an email telling you how to reset your password.</p>
<div class="clear"></div>
<form method="post" action="forgotpassword.php" id="forgottenpw-form">
<p>
<label for="forgottenpw-username">Username</label>
<input type="text" name="forgottenpw-username" id="forgottenpw-username" value="">
</p>
<p>
<label for="forgottenpw-email">Email address</label>
<input type="text" name="forgottenpw-email" id="forgottenpw-email" value="">
</p>
<p>
<input type="submit" value="Request information" name="actionForgot" class="submit process-button" id="forgottenpw-submit">
</p>
<input type="hidden" value="default" name="origin">
</form>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<div class="right-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">False Alarm!</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>If you have remembered your password, or if you just came here by accident, click the link below to return to the homepage.</p>
<p><a href="index.php">Back to homepage</a></p>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<!--[if lt IE 7]>
<script type="text/javascript">
Pngfix.doPngImageFix();
</script>
<![endif]-->
<div id="footer">
<p><a href="index.php" target="_self">Homepage</a> </p>
<p>HABBO is a registered trademark of Sulake Corporation. All rights reserved to their respective owner(s).</p>
</div> </div>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
</body></html>
MySQLi:
PHP:
<?PHP
// Configuration
$SiteLink = "http://example.com/forgotpassword"; // File MUST be named forgotpassword.php unless you edit the code
$LogoLink = "http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/v2/images/habbologo_whiteR.gif";
$FromEmail = "from@lol.com";
$host = ""; // Host
$name = ""; // User name
$pass = ""; // Password
$dbname = ""; // Database name
$mysqli = new mysqli($host, $name, $pass, $dbname);
if(isset($_GET['Reset'])) {
$arr = explode("-", $_GET['Reset']);
$Username = $mysqli->real_escape_string($arr[0]);
$query = mysqli_query($mysqli, "SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". $mysqli->real_escape_string($_GET['Reset']) ."'");
$querycount = $query->num_rows;
if($querycount > 0)
{
$GetEmai = mysqli_query($mysqli, "SELECT `mail` FROM `users` WHERE `username` = '". $Username ."'");
$GetEmail = $GetEmai->fetch_assoc();
echo $GetEmail['mail'];
GenerateNewPasswordEmail($Username, $GetEmail['mail']);
mysqli_query($mysqli, "DELETE FROM `password_resets` WHERE `username` ='". $Username ."'");
echo "A new password has been sent to your email address."; die;
}
else {
echo "Invalid hash.";
echo "SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". $mysqli->real_escape_string($_GET['Reset']) ."'";
die;
}
}
function GenerateValidationEmail($username, $email, $hash) {
global $SiteLink, $LogoLink;
SendMail($email, $username, '
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
To change your password please click <a href="'. $SiteLink .'/account/password/reset/'. $hash .'">this link to reset your password</a>.
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="100" valign="middle">
<table style="margin-left: 12px;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle">
<table style="background-color: #51b708; height: 50px;" height="50px;" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 100%; vertical-align:middle; border:solid 2px #000000" valign="middle">
<p style="font-family: Verdana,Arial,sans-serif; font-weight: bold; font-size: 18px; color:#ffffff; margin-top: 0; margin-bottom: 0;">
<a style="text-decoration: none; padding:15px 20px; color:#ffffff" href="'. $SiteLink .'/account/password/reset/'. $hash .'">
Reset my Habbo password
</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function GenerateNewPasswordEmail($username, $email) {
global $mysqli, $LogoLink;
$PlainPassword = substr (md5(uniqid(rand(),1)), 3, 10);
$HashedPassword = md5($PlainPassword);
$query = mysqli_query($mysqli, "UPDATE `users` SET `password` ='". $HashedPassword ."' WHERE `username` = '". $username ."'");
SendMail($email, $username, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
Your new password is: <b>'. $PlainPassword .'</b>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function SendMail($email, $username, $Body) {
global $FromEmail;
require_once("Mail.php");
require_once('Mail/mime.php');
$headers = array('From' => $FromEmail, 'Subject' => "Password reset");
//$GenBody = BodyGenerate($username, $hash);
$break = "\n";
$mime = new Mail_mime($break);
$mime->setHTMLBody($Body);
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = Mail::factory("mail");
$mail->send($email, $headers, $body);
}
if(isset($_POST['actionForgot'])) {
//
$query = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `username` = '". $mysqli->real_escape_string($_POST['forgottenpw-username']). "' AND `mail` = '". $mysqli->real_escape_string($_POST['forgottenpw-email']) ."'");
$querycount = $query->num_rows;
if($querycount > 0) {
$hash = $mysqli->real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand())). "-". sha1(md5(uniqid(rand()))) . "-" . md5(uniqid(rand())). "-" . md5(rand()) ;
mysqli_query($mysqli, "INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". $mysqli->real_escape_string($_POST['forgottenpw-username']) ."', '". $hash."')") or die("INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". $mysqli->real_escape_string($_POST['forgottenpw-username']) ."', '". $mysqli->real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand()))."'");
GenerateValidationEmail($mysqli->real_escape_string($_POST['forgottenpw-username']), $mysqli->real_escape_string($_POST['forgottenpw-email']), $hash);
}
else echo "Error";
die;
}
?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Hotelname ~ Home </title>
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/common.css" type="text/css">
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/process.css" type="text/css">
<body id="landing" class="process-template">
<div id="overlay"></div>
<div id="container">
<div class="cb process-template-box clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div id="content">
<div id="header" class="clearfix">
<h1><a href="index.php"></a></h1>
</div><style type="text/css">
div.left-column { float: left; width: 50% }
div.right-column { float: right; width: 49% }
label { display: block }
input { width: 98% }
input.process-button { width: auto; float: right }
</style>
<div id="process-content">
<div class="left-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">Forgotten Your Password?</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>Don't panic! Please enter your account information below and we'll send you an email telling you how to reset your password.</p>
<div class="clear"></div>
<form method="post" action="forgotpassword.php" id="forgottenpw-form">
<p>
<label for="forgottenpw-username">Username</label>
<input type="text" name="forgottenpw-username" id="forgottenpw-username" value="">
</p>
<p>
<label for="forgottenpw-email">Email address</label>
<input type="text" name="forgottenpw-email" id="forgottenpw-email" value="">
</p>
<p>
<input type="submit" value="Request information" name="actionForgot" class="submit process-button" id="forgottenpw-submit">
</p>
<input type="hidden" value="default" name="origin">
</form>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<div class="right-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">False Alarm!</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>If you have remembered your password, or if you just came here by accident, click the link below to return to the homepage.</p>
<p><a href="index.php">Back to homepage</a></p>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<!--[if lt IE 7]>
<script type="text/javascript">
Pngfix.doPngImageFix();
</script>
<![endif]-->
<div id="footer">
<p><a href="index.php" target="_self">Homepage</a> </p>
<p>HABBO is a registered trademark of Sulake Corporation. All rights reserved to their respective owner(s).</p>
</div> </div>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
</body></html>