Home > php教程 > PHP源码 > body text

前一任的神级代码,速来膜拜

PHP中文网
Release: 2016-05-25 16:58:32
Original
1242 people have browsed it

[PHP]代码 

<?php
/**
 * App用户注册接口
 * return: json
 */
public function signup_old(){
	$yyUser = M(&#39;table.user&#39;,&#39;youyax_&#39;);
	$data[&#39;user&#39;] = $_POST[&#39;userName&#39;];
	$data[&#39;telephone&#39;] = $_POST[&#39;telephone&#39;];
	$password = $_POST[&#39;password&#39;];
	$repassword = $_POST[&#39;repassword&#39;];
	$data[&#39;beAgent&#39;] = $_POST[&#39;beAgent&#39;];
	$data[&#39;realName&#39;] = $_POST[&#39;realName&#39;];
	$data[&#39;email&#39;] = $_POST[&#39;email&#39;];
	$data[&#39;credit&#39;] = I(&#39;identityCard&#39;);
	if(empty($data[&#39;user&#39;]) || empty($password) || empty($repassword) || empty($data[&#39;email&#39;]) ){
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;必填项不能为空!&#39;;
		echo json_encode($arr);
		return false;
	}
	$lenP = strlen($password);
	if($lenP < 6 || $lenP >20){
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;密码必须为6-20位!&#39;;
		echo json_encode($arr);
		return false;
	}
	if( empty($data[&#39;beAgent&#39;]) ){
		$data[&#39;beAgent&#39;] = 0;
	}
	if($data[&#39;beAgent&#39;] == 1){
		if(empty($data[&#39;realName&#39;]) || empty($data[&#39;telephone&#39;]) || empty($data[&#39;credit&#39;])){
			$arr[&#39;code&#39;] = 0;
			$arr[&#39;message&#39;] = &#39;经纪人必须填写手机号、真实姓名、身份证号!&#39;;
			echo json_encode($arr);
			return false;
		}
		$creditLength = strlen($data[&#39;credit&#39;]);
		if (!in_array($creditLength, array(15, 18)))
			$this->response(0, &#39;身份证号码不合法&#39;);
	}
	$verifyE = $this->checkEmail($data[&#39;email&#39;]);
	if($verifyE){
		$email = $data[&#39;email&#39;];
		$mapE[&#39;email&#39;] = array(&#39;in&#39;,$email);
		$count = $yyUser->where($mapE)->count();
		if($count==0){
			if($repassword == $password){
				$data[&#39;pass&#39;] = md5($password);
				$userName = $data[&#39;user&#39;];
				$mapU[&#39;user&#39;] = array(&#39;in&#39;,$userName);
				$count = $yyUser->where($mapU)->count();
				if($count==0){
					$tel = $data[&#39;telephone&#39;];
					$verifyT = $this->checkTel($tel);
					if( !empty($data[&#39;telephone&#39;])){
						if(!$verifyT){
							$arr[&#39;code&#39;] = 0;
							$arr[&#39;message&#39;] = &#39;不是正确的手机号码!&#39;;
							echo json_encode($arr);
							return false;
						}
						$mapT[&#39;telephone&#39;] = array(&#39;in&#39;,$tel);
						$count = $yyUser->where($mapT)->count();
						if($count!=0){
							$arr[&#39;code&#39;] = 0;
							$arr[&#39;message&#39;] = &#39;手机号码已被使用!&#39;;
							echo json_encode($arr);
							return false;
						}
					}
					$data[&#39;status&#39;] = 1;
					$bools = $yyUser->add($data);
					if($bools){
						$id = $yyUser->field(&#39;id&#39;)->where(&#39;user = &#39;.&#39;"&#39;.$data[&#39;user&#39;].&#39;"&#39;)->select();
						$userId = $id[0][&#39;id&#39;];
						$arr[&#39;code&#39;] = 1;
						$arr[&#39;message&#39;] = &#39;注册成功!&#39;;
						$arrData[&#39;userId&#39;] = $userId;
						$arrData[&#39;userName&#39;] = $data[&#39;user&#39;];
						$arrData[&#39;beAgent&#39;] = $data[&#39;beAgent&#39;];
						$arrData[&#39;realName&#39;] = $data[&#39;realName&#39;];
						$arrData[&#39;password&#39;] = $data[&#39;pass&#39;];
						$arrData[&#39;email&#39;] = $data[&#39;email&#39;];
						$arr[&#39;data&#39;] = $arrData;
						echo json_encode($arr);
					}else {
						$arr[&#39;code&#39;] = 0;
						$arr[&#39;message&#39;] = &#39;注册失败,系统异常,请重新注册!&#39;;
						echo json_encode($arr);
					}
				}else {
					$arr[&#39;code&#39;] = 0;
					$arr[&#39;message&#39;] = &#39;用户名已被使用!&#39;;
					echo json_encode($arr);
				}
			}else {
				$arr[&#39;code&#39;] = 0;
				$arr[&#39;message&#39;] = &#39;密码不一致!&#39;;
				echo json_encode($arr);
			}
		}else {
			$arr[&#39;code&#39;] = 0;
			$arr[&#39;message&#39;] = &#39;手机号码已被使用!&#39;;
			echo json_encode($arr);
		}
	}else {
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;手机号码不合法&#39;;
		echo json_encode($arr);
	}
}
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template