《CMS案例:phpcms邮箱修改二次认证失败的原因和解决办法》要点:
本文介绍了CMS案例:phpcms邮箱修改二次认证失败的原因和解决办法,希望对您有用。如果有疑问,可以联系我们。
相关主题:PHPCMS教程
/*
* 测试邮件配置
*/
public function send_newmail() {
$_username = param::get_cookie('_regusername');
$_userid = param::get_cookie('_reguserid');
$_ssouid = param::get_cookie('_reguseruid');
$newemail = $_GET['newemail'];
if($newemail==''){//邮箱为空,直接返回错误
return '2';
}
$this->_init_phpsso();
$status = $this->client->ps_checkemail($newemail);
if($status=='-5'){//邮箱被占用
exit('-1');
}
if ($status==-1) {
$status = $this->client->ps_get_member_info($newemail, 3);
if($status) {
$status = unserialize($status); //接口返回序列化,进行判断
if (!isset($status['uid']) || $status['uid'] != intval($_ssouid)) {
exit('-1');
}
} else {
exit('-1');
}
}
//验证邮箱格式
pc_base::load_sys_func('mail');
$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key'));
$code = sys_auth($userid.'|'.SYS_TIME, 'ENCODE', $phpcms_auth_key);
$url = APP_PATH."index.php?m=member&c=index&a=register&code=$code&verify=1";
//读取配置获取验证信息
$member_setting = getcache('member_setting');
$message = $member_setting['registerverifymessage'];
$message = str_replace(array('{click}','{url}','{username}','{email}','{password}'), array('<a href="'.$url.'">'.L('please_click').'</a>',$url,$_username,$newemail,$password), $message);
if(sendmail($newemail, L('reg_verify_email'), $message)){
//更新新的邮箱,用来验证
$this->db->update(array('email'=>$newemail), array('userid'=>$_userid));
$this->client->ps_member_edit($_username, $newemail, '', '', $_ssouid);
$return = '1';
}else{
$return = '2';
}
echo $return;
}CMS案例
转载请注明本页网址:
http://www.vephp.com/jiaocheng/5853.html