神速代码

来源:互联网 发布:mac好玩的单机游戏免费 编辑:程序博客网 时间:2024/05/21 14:50
<?php
002/**
003 * App用户注册接口
004 * return: json
005 */
006public functionsignup_old(){
007    $yyUser= M('table.user','youyax_');
008    $data['user'] =$_POST['userName'];
009    $data['telephone'] =$_POST['telephone'];
010    $password= $_POST['password'];
011    $repassword= $_POST['repassword'];
012    $data['beAgent'] =$_POST['beAgent'];
013    $data['realName'] =$_POST['realName'];
014    $data['email'] =$_POST['email'];
015    $data['credit'] = I('identityCard');
016    if(empty($data['user']) || empty($password) ||empty($repassword) ||empty($data['email']) ){
017        $arr['code'] = 0;
018        $arr['message'] ='必填项不能为空!';
019        echojson_encode($arr);
020        returnfalse;
021    }
022    $lenP= strlen($password);
023    if($lenP< 6 || $lenP >20){
024        $arr['code'] = 0;
025        $arr['message'] ='密码必须为6-20位!';
026        echojson_encode($arr);
027        returnfalse;
028    }
029    if(empty($data['beAgent']) ){
030        $data['beAgent'] = 0;
031    }
032    if($data['beAgent'] == 1){
033        if(empty($data['realName']) || empty($data['telephone']) ||empty($data['credit'])){
034            $arr['code'] = 0;
035            $arr['message'] ='经纪人必须填写手机号、真实姓名、身份证号!';
036            echojson_encode($arr);
037            returnfalse;
038        }
039        $creditLength= strlen($data['credit']);
040        if(!in_array($creditLength,array(15, 18)))
041            $this->response(0,'身份证号码不合法');
042    }
043    $verifyE= $this->checkEmail($data['email']);
044    if($verifyE){
045        $email= $data['email'];
046        $mapE['email'] =array('in',$email);
047        $count= $yyUser->where($mapE)->count();
048        if($count==0){
049            if($repassword== $password){
050                $data['pass'] = md5($password);
051                $userName= $data['user'];
052                $mapU['user'] =array('in',$userName);
053                $count= $yyUser->where($mapU)->count();
054                if($count==0){
055                    $tel= $data['telephone'];
056                    $verifyT= $this->checkTel($tel);
057                    if( !empty($data['telephone'])){
058                        if(!$verifyT){
059                            $arr['code'] = 0;
060                            $arr['message'] ='不是正确的手机号码!';
061                            echojson_encode($arr);
062                            returnfalse;
063                        }
064                        $mapT['telephone'] =array('in',$tel);
065                        $count= $yyUser->where($mapT)->count();
066                        if($count!=0){
067                            $arr['code'] = 0;
068                            $arr['message'] ='手机号码已被使用!';
069                            echojson_encode($arr);
070                            returnfalse;
071                        }
072                    }
073                    $data['status'] = 1;
074                    $bools= $yyUser->add($data);
075                    if($bools){
076                        $id= $yyUser->field('id')->where('user = '.'"'.$data['user'].'"')->select();
077                        $userId= $id[0]['id'];
078                        $arr['code'] = 1;
079                        $arr['message'] ='注册成功!';
080                        $arrData['userId'] =$userId;
081                        $arrData['userName'] =$data['user'];
082                        $arrData['beAgent'] =$data['beAgent'];
083                        $arrData['realName'] =$data['realName'];
084                        $arrData['password'] =$data['pass'];
085                        $arrData['email'] =$data['email'];
086                        $arr['data'] =$arrData;
087                        echojson_encode($arr);
088                    }else{
089                        $arr['code'] = 0;
090                        $arr['message'] ='注册失败,系统异常,请重新注册!';
091                        echojson_encode($arr);
092                    }
093                }else{
094                    $arr['code'] = 0;
095                    $arr['message'] ='用户名已被使用!';
096                    echojson_encode($arr);
097                }
098            }else{
099                $arr['code'] = 0;
100                $arr['message'] ='密码不一致!';
101                echojson_encode($arr);
102            }
103        }else{
104            $arr['code'] = 0;
105            $arr['message'] ='手机号码已被使用!';
106            echojson_encode($arr);
107        }
108    }else{
109        $arr['code'] = 0;
110        $arr['message'] ='手机号码不合法';
111        echojson_encode($arr);
112    }
113}
0 0
原创粉丝点击