phpcms邮箱修改二次认证失败的原因和解决办法

因,phpcms的bug,传输userid失败导致的。
原来的代码如下

/*
* 测试邮件配置
*/
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(''.L('please_click').'',$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;
}


修改后的如下:

/*
* 测试邮件配置
*/
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(''.L('please_click').'',$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;
}


ID传输失败就自然不知道是认证谁了,所以导致的老用户传输ID失败不能邮箱认证。


握手

雷人

路过

鲜花
该文章已有0人参与评论

请发表评论

全部评论



零度资源网 © 2011-2020   蜀ICP备13025384号-1

      安全联盟认证