...
|
...
|
@@ -83,16 +83,87 @@ class ProfileController extends MemberbaseController { |
|
|
|
|
|
// 修改绑定1
|
|
|
public function old_mobile() {
|
|
|
$time = microtime();
|
|
|
$token = '#'.sha1(strtoupper(md5($this->userid.$time)));
|
|
|
$this->user_model->where(array('id'=>$this->userid))->save(array('token'=>$token));
|
|
|
session('time',$time);
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证原手机号码
|
|
|
* @param mobile 手机号码
|
|
|
* @param code 验证码
|
|
|
*/
|
|
|
public function do_old_mobile() {
|
|
|
if(IS_AJAX) {
|
|
|
$mobile = I('post.mobile');
|
|
|
$code = I('post.code');
|
|
|
$code_model = D('Common/Code');
|
|
|
$user_mobile = $this->user_model->where(array('id'=>$this->userid))->getField('mobile');
|
|
|
if($mobile!=$user_mobile) {
|
|
|
$this->ajaxReturn(array('status'=>false, 'msg'=>'手机号码错误'));
|
|
|
}
|
|
|
if(!$code_model->getInfo($mobile, $code, time())) {
|
|
|
$this->ajaxReturn(array('status'=>false, 'msg'=>'验证码不正确'));
|
|
|
}
|
|
|
$this->ajaxReturn(array('status'=>true,'msg'=>'成功','data'=>U('User/Profile/new_mobile')));
|
|
|
} else {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 修改绑定2
|
|
|
public function new_mobile() {
|
|
|
$time = session('time');
|
|
|
if(!$time) {
|
|
|
redirect(U('User/Profile/old_mobile'));
|
|
|
}
|
|
|
$token = $this->user_model->where(array('id'=>$this->userid))->getField('token');
|
|
|
$this_token = '#'.sha1(strtoupper(md5($this->userid.$time)));
|
|
|
if($token != $this_token) {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改新手机号码
|
|
|
* @param mobile 手机号码
|
|
|
* @param code 验证码
|
|
|
*/
|
|
|
public function do_new_mobile() {
|
|
|
if(IS_AJAX) {
|
|
|
$mobile = I('post.mobile');
|
|
|
$code = I('post.code');
|
|
|
$code_model = D('Common/Code');
|
|
|
if(!$code_model->getInfo($mobile, $code, time())) {
|
|
|
$this->ajaxReturn(array('status'=>false, 'msg'=>'验证码不正确'));
|
|
|
}
|
|
|
$result = $this->user_model->where(array('id'=>$this->userid))->save(array('mobile'=>$mobile));
|
|
|
if(!$result) {
|
|
|
$this->ajaxReturn(array('status'=>false,'msg'=>'更换失败,请重试'));
|
|
|
}
|
|
|
$user = $this->user_model->where(array('id'=>$this->userid))->find();
|
|
|
session('user',$user);
|
|
|
$this->ajaxReturn(array('status'=>true,'msg'=>'成功','data'=>U('User/Profile/ok_mobile')));
|
|
|
} else {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 修改绑定3
|
|
|
public function ok_mobile() {
|
|
|
$time = session('time');
|
|
|
if(!$time) {
|
|
|
redirect(U('User/Profile/edit'));
|
|
|
}
|
|
|
$token = $this->user_model->where(array('id'=>$this->userid))->getField('token');
|
|
|
$this_token = '#'.sha1(strtoupper(md5($this->userid.$time)));
|
|
|
if($token != $this_token) {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
session('time','');
|
|
|
$this->display();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -101,6 +172,60 @@ class ProfileController extends MemberbaseController { |
|
|
$this->assign($this->user);
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 原手机号发送短信
|
|
|
* @param mobile 手机号码
|
|
|
*/
|
|
|
public function old_check() {
|
|
|
if(IS_AJAX) {
|
|
|
$mobile = I('post.mobile');
|
|
|
$user_mobile = $this->user_model->where(array('id'=>$this->userid))->getField('mobile');
|
|
|
if($mobile!=$user_mobile) {
|
|
|
$this->ajaxReturn(array('status'=>false, 'msg'=>'手机号码错误'));
|
|
|
}
|
|
|
$this->send($mobile);
|
|
|
} else {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新手机号发送短信
|
|
|
* @param mobile 手机号码
|
|
|
*/
|
|
|
public function new_check() {
|
|
|
if(IS_AJAX) {
|
|
|
$mobile = I('post.mobile');
|
|
|
$count = $this->user_model->where(array('mobile'=>$mobile))->count();
|
|
|
if($count) {
|
|
|
$this->ajaxReturn(array('status'=>false, 'msg'=>'手机号码已存在'));
|
|
|
}
|
|
|
$this->send($mobile);
|
|
|
} else {
|
|
|
$this->error('非法操作');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送短信
|
|
|
* @param mobile 手机号码
|
|
|
*/
|
|
|
private function send($mobile) {
|
|
|
$info['mobile'] = I('post.mobile');
|
|
|
$where['mobile'] = $info['mobile'];
|
|
|
$info['code'] = $this->generate_code(6);
|
|
|
// $result = explode(',', $this->sendSMS($info['mobile'], $info['code']));
|
|
|
// if($result[0] != 1) {
|
|
|
// $this->ajaxReturn(array('status'=>false, 'msg'=>'发送失败', 'data'=>$result));
|
|
|
// }
|
|
|
//如发送成功,将短信发送记录入表中
|
|
|
$info['ctime'] = time();
|
|
|
$info['otime'] = time()+600;
|
|
|
$code_model = D('Common/Code');
|
|
|
$code_model->add($info);
|
|
|
$this->ajaxReturn(array('status'=>true, 'msg'=>'发送成功', 'code'=>$info['code']));
|
|
|
}
|
|
|
|
|
|
// 用户头像上传
|
|
|
public function avatar_upload(){
|
...
|
...
|
|