127 lines
3.9 KiB
PHP
127 lines
3.9 KiB
PHP
<?php
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| CubeCart 4
|
|
| ========================================
|
|
| CubeCart is a registered trade mark of Devellion Limited
|
|
| Copyright Devellion Limited 2006. All rights reserved.
|
|
| Devellion Limited,
|
|
| 5 Bridge Street,
|
|
| Bishops Stortford,
|
|
| HERTFORDSHIRE.
|
|
| CM23 2JU
|
|
| UNITED KINGDOM
|
|
| http://www.devellion.com
|
|
| UK Private Limited Company No. 5323904
|
|
| ========================================
|
|
| Web: http://www.cubecart.com
|
|
| Email: info (at) cubecart (dot) com
|
|
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
|
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
|
+--------------------------------------------------------------------------
|
|
| forgotPass.inc.php
|
|
| ========================================
|
|
| Password Reset Page
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
if(!defined('CC_INI_SET')){ die("Access Denied"); }
|
|
|
|
// include lang file
|
|
$lang = getLang("includes".CC_DS."content".CC_DS."forgotPass.inc.php");
|
|
|
|
if(isset($_POST['submit'])){
|
|
|
|
$query = "SELECT firstName, lastName FROM ".$glob['dbprefix']."CubeCart_customer WHERE `email` = ".$db->mySQLSafe($_POST['email'])." AND `type`>0";
|
|
$result = $db->select($query);
|
|
|
|
if ($config['floodControl']) $spamCode = fetchSpamCode($_POST['ESC'], true);
|
|
|
|
// start validation
|
|
if ($result == false || empty($_POST['email'])) {
|
|
$errorMsg = $lang['forgotPass']['email_not_found'];
|
|
|
|
} else if ($config['floodControl'] && (!isset($_POST['spamcode']) || ($spamCode['SpamCode']!==strtoupper($_POST['spamcode'])) || (get_ip_address()!==$spamCode['userIp']))) {
|
|
$errorMsg = $lang['forgotPass']['error_code'];
|
|
|
|
} else {
|
|
// update to new password
|
|
$newPass = randomPass();
|
|
$data['password'] = "'".md5($newPass)."'";
|
|
$where = "`email` = ".$db->mySQLSafe($_POST['email']);
|
|
$update = $db->update($glob['dbprefix']."CubeCart_customer", $data, $where);
|
|
|
|
// send email
|
|
require("classes".CC_DS."htmlMimeMail".CC_DS."htmlMimeMail.php");
|
|
|
|
$lang = getLang("email.inc.php");
|
|
|
|
$mail = new htmlMimeMail();
|
|
|
|
$macroArray = array(
|
|
"RECIP_NAME" => $result[0]['firstName']." ".$result[0]['lastName'],
|
|
"EMAIL" => $_POST['email'],
|
|
"PASSWORD" => $newPass,
|
|
"STORE_URL" => $GLOBALS['storeURL']."/index.php?_a=login",
|
|
"SENDER_IP" => get_ip_address()
|
|
);
|
|
|
|
$text = macroSub($lang['email']['reset_password_body'],$macroArray);
|
|
unset($macroArray);
|
|
|
|
$mail->setText($text);
|
|
$mail->setReturnPath($_POST['email']);
|
|
$mail->setFrom($config['masterName'].' <'.$config['masterEmail'].'>');
|
|
$mail->setSubject($lang['email']['reset_password_subject']);
|
|
$mail->setHeader('X-Mailer', 'CubeCart Mailer');
|
|
$send = $mail->send(array($_POST['email']), $config['mailMethod']);
|
|
$passSent = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$forgot_pass = new XTemplate ("content".CC_DS."forgotPass.tpl");
|
|
|
|
$forgot_pass->assign("LANG_FORGOT_PASS_TITLE",$lang['forgotPass']['forgot_pass']);
|
|
|
|
if($passSent == TRUE)
|
|
{
|
|
$forgot_pass->assign("FORGOT_PASS_STATUS", sprintf($lang['forgotPass']['new_pass_sent'],$_POST['email']));
|
|
}
|
|
else
|
|
{
|
|
$forgot_pass->assign("FORGOT_PASS_STATUS",$lang['forgotPass']['enter_email']);
|
|
|
|
$forgot_pass->assign("LANG_EMAIL",$lang['forgotPass']['email']);
|
|
|
|
|
|
// Start Spam Bot Control
|
|
if($config['floodControl']==1) {
|
|
|
|
$spamCode = strtoupper(randomPass(5));
|
|
$ESC = createSpamCode($spamCode);
|
|
$imgSpambot = imgSpambot($ESC);
|
|
|
|
$forgot_pass->assign("VAL_ESC", $ESC);
|
|
$forgot_pass->assign("TXT_SPAMBOT", $lang['forgotPass']['spambot']);
|
|
$forgot_pass->assign("IMG_SPAMBOT", $imgSpambot);
|
|
$forgot_pass->parse("forgot_pass.form.spambot");
|
|
}
|
|
|
|
$forgot_pass->assign("TXT_SUBMIT",$lang['forgotPass']['send_pass']);
|
|
|
|
if(isset($errorMsg)){
|
|
|
|
$forgot_pass->assign("VAL_ERROR",$errorMsg);
|
|
$forgot_pass->parse("forgot_pass.error");
|
|
|
|
}
|
|
|
|
$forgot_pass->parse("forgot_pass.form");
|
|
|
|
}
|
|
|
|
$forgot_pass->parse("forgot_pass");
|
|
$page_content = $forgot_pass->text("forgot_pass");
|
|
?>
|