Esempio n. 1
0
 public function test()
 {
     $username = '******';
     $mobi = '123';
     $email = '*****@*****.**';
     $celluuid = 'a';
     $row = unique_verifying($username, $mobi, $email, $celluuid);
     //header("Content-type: text/html; charset=utf-8");
     utf8_encode(var_dump($row));
     $arrlength = count($row);
     echo '<br>+++++++++++++' . $arrlength;
     echo '<br>+++++++++++++' . $row[0]['UserName'];
     while (0) {
         if ($row["UserName"] == $username) {
             //$error=true;
             echo "用户名已存在<br>";
             //return $this->send_error( OP_API_TOKEN_ERROR , "用户名已存在<br>" );
         }
         if ($row["Email"] == $email) {
             //$error=true;
             echo "用户邮箱已经注册<br>";
             //return $this->send_error( OP_API_TOKEN_ERROR , "用户邮箱已经注册<br>" );
         }
     }
 }
Esempio n. 2
0
 public function register()
 {
     $request_body = file_get_contents('php://input');
     //json_flag
     $data = json_decode($request_body);
     //json_flag
     // $username = z(t($_GET['username']));				//jsonp_flag
     // $password = z(t($_GET['password']));				//jsonp_flag
     // $confirmpassword = z(t($_GET['repeatpassword']));	//jsonp_flag
     // $name = z(t($_GET['name']));						//jsonp_flag
     // $gender = z(t($_GET['gender']));					//jsonp_flag
     // $mobi = z(t($_GET['mobile']));						//jsonp_flag
     // //$email = z(t(v('email')));
     // //$celluuid = z(t(v('celluuid')));
     $username = $data->{'username'};
     //json_flag
     $password = $data->{'password'};
     //json_flag
     $confirmpassword = $data->{'repeatpassword'};
     //json_flag
     $name = $data->{'name'};
     //json_flag
     $gender = $data->{'gender'};
     //json_flag
     $mobi = $data->{'mobile'};
     //json_flag
     //$actnum="";
     //$data = var_dump($data);
     //return $this->send_result( array( 'user' => $data->{'username'} ) );
     //调用函数,检测用户输入的数据
     $UserNameGood = $this->Check_username($username);
     $PasswordGood = $this->Check_Password($password);
     //$EmailGood=$this->Check_Email($email);
     $ConfirmPasswordGood = $this->Check_ConfirmPassword($password, $confirmpassword);
     //$error=false;//定义变量判断注册数据是否出现错误
     if ($UserNameGood != "用户名检测正确") {
         //$error=true;//改变 error 的值表示出现了错误
         return $this->send_error(9999, $UserNameGood);
         //echo $UserNameGood;//输出错误信息
         //echo "<br>";
     }
     if ($PasswordGood != "密码检测正确") {
         //$error=true;
         return $this->send_error(OP_API_TOKEN_ERROR, $PasswordGood);
         //echo $PasswordGood;
         //echo "<br>";
     }
     /*if($EmailGood !="邮箱检测正确") {
     			//$error=true;
     			return $this->send_error( OP_API_TOKEN_ERROR , $EmailGood );
     			//echo $EmailGood;
     			//echo "<br>";
     		}*/
     if ($ConfirmPasswordGood != "两次密码输入一致") {
         //$error=true;
         return $this->send_error(OP_API_TOKEN_ERROR, $ConfirmPasswordGood);
         //echo $ConfirmPasswordGood;
         //echo "<br>";
     }
     //判断数据库中 UserName、Mobile、Email、celluuid 是否已经存在
     //$query="select * from $dbloginTable where UserName='******' or Email='$email'";
     //$result=mysql_query($query);
     //
     //$row = unique_verifying( $username, $mobi, $email, $celluuid );
     $row = unique_verifying($username, $mobi);
     if ($row) {
         $arrlength = count($row);
         //必须对$row进行判断,因为如果$row无返回,则为false,而count(false) == 1;
         //return $this->send_error( OP_API_TOKEN_ERROR , $arrlength.'==='.$username.", 注册失败!".$row[0]['UserName'] );
         //return $this->send_result( $row );
         for ($i = 0; $i < $arrlength; $i++) {
             if ($row[$i]["UserName"] == $username) {
                 //$error=true;
                 //echo "用户名已存在<br>";
                 return $this->send_error(OP_API_TOKEN_ERROR, "用户名已存在");
             }
             /*if ($mobi!='' && $row[$i]["Mobile"]===$mobi) {
             			//$error=true;
             			//echo "用户邮箱已经注册<br>";
             			return $this->send_error( OP_API_TOKEN_ERROR , "用户手机号码已经注册" );
             		}
             		if ($row[$i]["Email"]==$email) {
             			//$error=true;
             			//echo "用户邮箱已经注册<br>";
             			return $this->send_error( OP_API_TOKEN_ERROR , "用户邮箱已经注册" );
             		}*/
             if ($row[$i]["mobile"] == $mobi) {
                 //$error=true;
                 //echo "用户邮箱已经注册<br>";
                 return $this->send_error(OP_API_TOKEN_ERROR, "该手机号码已经注册");
             }
         }
     }
     //如果数据检测都合法,则将用户资料写进数据库表
     //$actnum=$this->Check_actnum();//调用激活码函数
     //$Datetime=date("y-m-d H:i:s");//获取注册时间,也就是数据写入到用户表的时间
     $result = insert_user_info($username, sha1($password), $name, $mobi, $gender);
     if ($result) {
         return $this->send_result(array('user' => $name, 'username' => $username));
     } else {
         return $this->send_error(OP_API_TOKEN_ERROR, db_error() . ", 注册失败!");
     }
     //echo $actnum;
     /*$to=$email;//用户注册的邮箱
     		$subject="激活码";
     		$message="您的激活码为$actnum";
     		$header="From:alexgzhou@163.com"."\r\n";//邮件头信息
     
     		if(mail($to,$subject,$message,$header)) {//php 中 mail()函数用来发送邮件,需要更改 php.ini 文件,最好安装 SMTP 服务器
     			//产生链接,链接到激活页面
     			echo "请登陆邮箱获取激活码。然后点击<a href="activate.php">这里</a>激活。"
     		}*/
 }