public function gai_intro() {
if(isset($_POST['dosubmit'])) {
$updateinfo = array();
//修改手机号码
if($_POST['mobile'] && $this->memberinfo['mobile'] != $_POST['mobile']) {//如果接收到数据且与数据库中记录的值不相符才进行操作
$mobile = $_POST['mobile'];
$this->db->update(array('mobile'=>$mobile), array('userid'=>$this->memberinfo['userid']));
}
//修改姓名
$nickname = $_POST['nickname'];
if($nickname) {
$this->db->update(array('nickname'=>$nickname), array('userid'=>$this->memberinfo['userid']));
if(!isset($cookietime)) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
param::set_cookie('_nickname', $nickname, $cookietime);
}
//修改会员邮箱
if($this->memberinfo['email'] != $_POST['email'] && is_email($_POST['email'])) {
$email = $_POST['email'];
$this->db->update(array('email'=>$email), array('userid'=>$this->memberinfo['userid']));
//将新邮箱写入phpsso中
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$res = $this->client->ps_member_edit('', $email, '', '', $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);
$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));
if ($res < 0) showmessage($message_error[$res]);
}
}
//当旧密码和新密码均存在时进行下列操作
if($_POST['password'] && $_POST['newpassword']){
if(!is_password($_POST['password'])) {
showmessage(L('password_format_incorrect'), HTTP_REFERER);
}
//判断传入的旧密码是否与数据库中的密码相符
if($this->memberinfo['password'] != password($_POST['password'], $this->memberinfo['encrypt'])) {
showmessage(L('old_password_incorrect'), HTTP_REFERER);
}
if(!is_password($_POST['newpassword'])) {
showmessage(L('password_format_incorrect'), HTTP_REFERER);
}
$newpassword = password($_POST['newpassword'], $this->memberinfo['encrypt']);
$updateinfo['password'] = $newpassword;
//将新密码写入_member表中
$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));
//将新密码写入phpsso中
if(pc_base::load_config('system', 'phpsso')) {
//初始化phpsso
$this->_init_phpsso();
$res = $this->client->ps_member_edit('', '', $_POST['password'], $_POST['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);
$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));
if ($res < 0) showmessage($message_error[$res]);
}
}
//当旧密码和新密码均存在时进行以上操作
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_validator = true;
$memberinfo = $this->memberinfo;
include template('member', 'gai_intro');
}
}