include($_SERVER["DOCUMENT_ROOT"]."/_common/common.inc"); include("/home/cbhearth/_inc/mail/Mail.php"); $next = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET['next'] : $_POST['next']; $next = isset($next) == false ? "index.html" : $next; $email = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET['email'] : $_POST['email']; if (isset($_POST["btnCancel"])) { header("Location: ".$next); exit; } if (isset($_POST["btnReset"])) { if (strlen($email) == 0) { $error = "Please enter an Email Address"; } else { // See if the user is in the database include("/home/cbhearth/_inc/dbconnect.inc"); $email = mysql_real_escape_string(addslashes($email)); $check = mysql_query ("SELECT ID FROM PUBLICUSER WHERE EMAIL='$email' AND COMPANY='CB'"); if (!$check) { $error = "Email address not found"; } else { $matches = mysql_num_rows($check); // create a random password if ($matches == 1) { $row = mysql_fetch_array($check); $uid = stripslashes($row['ID']); $pw = generatePassword(9, 8); $query = "UPDATE PUBLICUSER SET PASSWORD = '".sha1($pw)."' WHERE ID = ".$uid; $result = mysql_query($query); if ($result) { // email the password $msg = "Below is your password for the Coldwell Banker Hearthside Home Retriever:\n\n"; $msg .= $pw; $mailheaders = "From: contact@cbhearthside.com\r\n"; $to = $email; $recipients = $to; $headers['From'] = 'contact@cbhearthside.com'; $headers['To'] = $to; $headers['Subject'] = "Coldwell Banker Hearthside Home Retriever Password Request"; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); $send = $mail_object->send($recipients, $headers, $msg); if (PEAR::isError($send)) { $error = "There was a problem"; } else { $emailsent = "Y"; } } else { $error = "There was a problem, please try again"; } } else { $error = "Email address not found"; } } } } $isPopup = (isset($_GET['p']) && $_GET['p'] == "Y") || (isset($_POST['p']) && $_POST['p'] == "Y"); $headAppend = $isPopup ? " class=\"popup\"" : ""; ?>
Your password has been emailed to you. Return to login page.
"; } else { if ($error) { echo "Enter your email address below and a new password will be sent to you.
"; } $email = isset($_GET['email']) ? $_GET['email'] : ""; ?>