Commit 78ed4c20 by 冷斌

fix bug

parent 5eb9a61a
vdqp0pRLH2hBQnLc
\ No newline at end of file
......@@ -8,7 +8,7 @@ class RegController extends HomebaseController {
function index(){
$agentid = checkNull(I("agentid"));
if($agentid){
$agentuid=M('users')->where("user_type=1 and user_activation_key='{$agentid}'")->getField('id');
if(!$agentuid){
......@@ -17,7 +17,7 @@ class RegController extends HomebaseController {
exit;
}
}
$this->assign('agentid',$agentid);
$this->display();
}
......@@ -26,8 +26,8 @@ class RegController extends HomebaseController {
public function wxLogin(){
$agentid=checkNull(I('agentid'));
$configpri=getConfigPri();
$AppID = $configpri['login_wx_appid'];
$AppID = 'wx31ac4d2b862fa9c0'; //$configpri['login_wx_appid'];
$callback = get_upload_path('/Appapi/Reg/wxLoginCallback?agentid='.$agentid); //回调地址
//微信登录
session_start();
......@@ -37,18 +37,18 @@ class RegController extends HomebaseController {
$callback = urlencode($callback);
//snsapi_base 静默 snsapi_userinfo 授权
$wxurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$AppID}&redirect_uri={$callback}&response_type=code&scope=snsapi_userinfo&state={$state}#wechat_redirect ";
header("Location: $wxurl");
}
public function wxLoginCallback(){
$code=I('code');
$agentid=checkNull(I('agentid'));
if($code){
$configpri=getConfigPri();
$AppID = $configpri['login_wx_appid'];
$AppSecret = $configpri['login_wx_appsecret'];
$AppID = 'wx31ac4d2b862fa9c0'; //$configpri['login_wx_appid'];
$AppSecret = '01633b34de498adb3996c26cf745785b'; //$configpri['login_wx_appsecret'];
/* 获取token */
$url="https://api.weixin.qq.com/sns/oauth2/access_token?appid={$AppID}&secret={$AppSecret}&code={$code}&grant_type=authorization_code";
$ch = curl_init();
......@@ -58,13 +58,13 @@ class RegController extends HomebaseController {
$json = curl_exec($ch);
curl_close($ch);
$arr=json_decode($json,1);
if(isset($arr['errcode'])){
$this->assign("reason",$arr['errmsg']);
$this->display(':error');
exit;
}
/* 刷新token 有效期为30天 */
$url="https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={$AppID}&grant_type=refresh_token&refresh_token={$arr['refresh_token']}";
$ch = curl_init();
......@@ -73,7 +73,7 @@ class RegController extends HomebaseController {
curl_setopt($ch, CURLOPT_URL, $url);
$json = curl_exec($ch);
curl_close($ch);
$url="https://api.weixin.qq.com/sns/userinfo?access_token={$arr['access_token']}&openid={$arr['openid']}&lang=zh_CN";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
......@@ -91,26 +91,26 @@ class RegController extends HomebaseController {
exit;
}
$User=M('users');
$userinfo=$User->field("id")->where("openid!='' and openid='{$openid}'")->find();
if(empty($userinfo)){
if($openid!=""){
$pass='123456';
$user_pass=setPass($pass);
if($agentid!=''){
$agentuid=M('users')->where("user_type=1 and user_activation_key='{$agentid}'")->getField('id');
if(!$agentuid){
$this->assign("reason",'邀请码不正确');
$this->display(':error');
exit;
}
}
}
$data=array(
'openid' =>$openid,
'user_login' => "wx_".time().substr($openid,-4),
'user_login' => "wx_".time().substr($openid,-4),
'user_pass' =>$user_pass,
'user_nicename' => $wxuser['nickname'],
'sex'=> $wxuser['sex'],
......@@ -123,16 +123,16 @@ class RegController extends HomebaseController {
'user_status' => 1,
"user_type"=>2,//会员
'signature' =>'这家伙很懒,什么都没留下',
);
);
$userid=$User->add($data);
if($agentuid){
$Proxy=M('users_proxy');
$agentinfo=$Proxy->where("uid={$agentuid}")->find();
if($agentinfo){
$path=$agentinfo['path'].setpath($agentuid);
$data2=[
'uid'=>$userid,
'path'=>$path,
......@@ -143,28 +143,28 @@ class RegController extends HomebaseController {
}
}
}
}
$href=get_upload_path('/index.php?g=Appapi&m=down&a=index');
header("Location: $href");
}
}
/* 手机登录 */
/* 手机验证码 */
public function getCode(){
$rs = array('code' => 0, 'msg' => '发送成功,请注意查收', 'info' => array());
$limit = ip_limit();
$limit = ip_limit();
if( $limit == 1){
$rs['code']=1003;
$rs['msg']='您已当日发送次数过多';
$this->ajaxReturn($rs);
}
$mobile = checkNull(I("mobile"));
$ismobile=checkMobile($mobile);
if(!$ismobile){
......@@ -172,11 +172,11 @@ class RegController extends HomebaseController {
$rs['msg']='请输入正确的手机号';
$this->ajaxReturn($rs);
}
$where="user_login='{$mobile}'";
$checkuser = checkUser($where);
$checkuser = checkUser($where);
if($checkuser){
$rs['code']=1004;
$rs['msg']='该手机号已注册,请登录';
......@@ -188,45 +188,45 @@ class RegController extends HomebaseController {
$rs['msg']='验证码5分钟有效,请勿多次发送';
$this->ajaxReturn($rs);
}
$mobile_code = random(6,1);
//密码可以使用明文密码或使用32位MD5加密
$result = sendCode($mobile,$mobile_code);
$result = sendCode($mobile,$mobile_code);
if($result['code']===0){
$_SESSION['reg_mobile'] = $mobile;
$_SESSION['reg_mobile_code'] = $mobile_code;
$_SESSION['reg_mobile_expiretime'] = time() +60*5;
$_SESSION['reg_mobile_expiretime'] = time() +60*5;
}else if($result['code']==667){
$_SESSION['reg_mobile'] = $mobile;
$_SESSION['reg_mobile_code'] = $result['msg'];
$_SESSION['reg_mobile_expiretime'] = time() +60*5;
$rs['code']=1002;
$rs['msg']='验证码为:'.$result['msg'];
}else{
$rs['code']=1002;
$rs['msg']=$result['msg'];
}
}
$this->ajaxReturn($rs);
}
public function register(){
$rs = array('code' => 0, 'msg' => '注册成功', 'info' => array());
$userlogin = checkNull(I("userlogin"));
$usercode = checkNull(I("usercode"));
$userpass = checkNull(I("userpass"));
$userpass2 = checkNull(I("userpass2"));
$agentid = checkNull(I("agentid"));
if(!$_SESSION['reg_mobile'] || !$_SESSION['reg_mobile_code']){
$rs['code'] = 1001;
$rs['msg'] = '请先获取验证码';
$this->ajaxReturn($rs);
$this->ajaxReturn($rs);
}
if($userlogin==''){
$rs['code']=1002;
$rs['msg']='请输入您的手机号';
......@@ -247,31 +247,31 @@ class RegController extends HomebaseController {
$rs['msg']='请输入确认密码';
$this->ajaxReturn($rs);
}
if($userlogin!=$_SESSION['reg_mobile']){
$rs['code'] = 1001;
$rs['msg'] = '手机号码不一致';
$this->ajaxReturn($rs);
}
if($usercode!=$_SESSION['reg_mobile_code']){
$rs['code'] = 1002;
$rs['msg'] = '验证码错误';
$this->ajaxReturn($rs);
}
}
$check = passcheck($userpass);
if($check==0){
$rs['code'] = 1004;
$rs['msg'] = '密码6-12位数字与字母';
$this->ajaxReturn($rs);
$this->ajaxReturn($rs);
}else if($check==2){
$rs['code'] = 1005;
$rs['msg'] = '密码不能纯数字或纯字母';
$this->ajaxReturn($rs);
}
$this->ajaxReturn($rs);
}
if($userpass!=$userpass2){
$rs['code']=1006;
$rs['msg']='密码和确认密码不一致';
......@@ -286,16 +286,16 @@ class RegController extends HomebaseController {
}
}
$User=M("users");
$ifreg=$User->field("id")->where("user_login='{$userlogin}'")->find();
if($ifreg){
$rs['code']=1008;
$rs['msg']='该账号已被注册';
$this->ajaxReturn($rs);
}
$userpass=setPass($userpass);
/* 无信息 进行注册 */
$configPri=getConfigPri();
$data=array(
......@@ -318,19 +318,19 @@ class RegController extends HomebaseController {
$data['coin']=$configPri['reg_reward'];
}
$userid=$User->add($data);
$userid=$User->add($data);
if(!$userid){
$rs['code']=1009;
$rs['msg']='注册失败,请重试';
$this->ajaxReturn($rs);
}
if($agentuid){
$Proxy=M('users_proxy');
$agentinfo=$Proxy->where("uid={$agentuid}")->find();
if($agentinfo){
$path=$agentinfo['path'].setpath($agentuid);
$data2=[
'uid'=>$userid,
'path'=>$path,
......@@ -339,8 +339,8 @@ class RegController extends HomebaseController {
$Proxy->add($data2);
}
}
$this->ajaxReturn($rs);
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment