EMLOG(FLY)评论邮件通知及密码找回

  • 内容
  • 相关

FLY模板有用户系统,那么必不可少的就需要密码找回功能。模板原先调用的是系统自带的邮件功能,但是我测试并不能使用,可能是主机环境的问题。遂发现sendmail插件可以正常发信。那么就只需要把密码找回功能的调用方式改成调用插件的方式就行了。具体代码如下:

替换FLY/inc/pwre.php里面的全部内容。

<?php 
require dirname(__FILE__).'/../../../../init.php';

error_reporting(7);
$email = addslashes(trim($_POST['email']));
$CACHE->updateCache('options');
require_once(EMLOG_ROOT.'/content/plugins/kl_sendmail/kl_sendmail_config.php');
require_once(EMLOG_ROOT.'/content/plugins/kl_sendmail/class/class.smtp.php');
require_once(EMLOG_ROOT.'/content/plugins/kl_sendmail/class/class.phpmailer.php');
if (isEmailExist($email)!=true) {
	print_r(json_encode(array('error'=>0, 'status'=>'1')));
	exit;
}else{
	$row = getOneUser($email);
	$uid = $row['uid']; 
	$token = md5($uid.$row['username'].$row['password']);
	$url = BLOG_URL."?reset=reset&email=".$email."&token=".$token;
	$time = date('Y-m-d H:i');

    $blogname = Option::get('blogname');
    $headers = 'From: '.$from . "\r\n";  
    $subject = '密码找回-'.$blogname;  
    $content = '您与'.$time.'提交了找回密码请求。请点击下面的链接重置密码<br/><a href='.$url.' target="_blank">'.$url.'</a>';
    if(kl_sendmail_do(KL_MAIL_SMTP, KL_MAIL_PORT, KL_MAIL_SENDEMAIL, KL_MAIL_PASSWORD, KL_MAIL_TOEMAIL, $subject, $content, $blogname)){
        print_r(json_encode(array('error'=>0, 'msg'=>'系统已向您的邮箱发送了一封邮件,请登录到您的邮箱及时重置您的密码')));  
    }else{
        print_r(json_encode(array('error'=>1, 'msg'=>'密码邮件发送失败,请联系网站管理员'))); 
    }
}

function isEmailExist($email) {
	$db = Database::getInstance();
    $data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM ".DB_PREFIX."user WHERE email='$email'");
    if ($data['total'] > 0) {
        return true;
    }else {
        return false;
    }
}

function getOneUser($email){
	$db = Database::getInstance();
    $row = $db->once_fetch_array("select * from ".DB_PREFIX."user where email='$email'");
    $userData = array();
    if($row) {
        $userData = array(
        	'uid' => htmlspecialchars($row['uid']),
            'username' => htmlspecialchars($row['username']),
            'password' => htmlspecialchars($row['password'])
        );
    }
    return $userData;
}
?>
管理员设置回复可下载

本文标签:

版权声明:若无特殊注明,本文皆为《旧城》原创,转载请保留文章出处。

本文链接:EMLOG(FLY)评论邮件通知及密码找回 - https://50123.xyz/post-20.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

未显示?请点击刷新

允许邮件通知
00:00 / 00:00
顺序播放