www.gusucode.com > citySHOP B2C商城系统 进销存 2.0.6码程序 > upload/retrieve_password.php

    <?php
define('NOROBOT', true);
include_once './include/common.inc.php';

if ($mall_uid) {
    showmessage('login_success','index.php');
}

$def_username = isset($_MCOOKIE['lusername']) ? $_MCOOKIE['lusername'] : '';
if(submitcheck('postsubmit')){
	if (preg_match("/[\'\"\s]+/", $usernamel)) {
        showmessage('用户名输入不正确或包含非法字符!');
    }
    dsetcookie('lusername', $usernamel, $cookietime);
	if(!$gemail = $db->result_first("SELECT email FROM {$tablepre}members WHERE username='$usernamel'")){
		showmessage('用户名不存在!');
	}
	if($gemail!==$emaill){
		showmessage('Email地址不正确!');
	}
	$newpassword = rand(100000,999999);
	
	$newpassword_md5 = md5(md5($newpassword));
    $db->query("UPDATE {$tablepre}members SET `password`='$newpassword_md5' WHERE username='$usernamel'");
    include(APP_ROOT . './uc_client/client.php');
	$ucresult = uc_user_edit($usernamel,'',$newpassword,$emaill,1);
	include(APP_ROOT.'./include/mail.class.php');
	$mail = new mails;
	$mail->email_subject = '亲爱的['.$usernamel.']你好,你在'.$sitename.'找回的密码已发送。';
	$mail->email_message = '你好,系统已将你的密码重置为:'.$newpassword.'。请登录我们的网站('.$siteurl.')及时更改密码。';
	$mail->bbname = $sitename;  //网站名称
	$mail->email_from = $sitemail;  //发件人
	$mail->email_to = $emaill; //收件人 多个用逗号隔开
	$mail->auth = $sitemail_auth; //SMTP 服务器要求身份验证  1:是,2:否
	$mail->auth_username = $sitemail;  //SMTP 身份验证用户名
	$mail->auth_password = $sitemail_password;   //SMTP 身份验证密码
	$mail->efrom = $sitemail;
	$mail->server = $sitemail_server; //smtp地址
	$mail->port = $sitemail_port; //端口
		
	$mail->send();
	showmessage('系统已将重置的密码发送到你的Email邮箱,如果长时间未收到,可再尝试一次。','KEEP');
}

include (template('retrieve_password'));
?>