首页 > php教程 > PHP源码 > 正文

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

PHP中文网
发布: 2016-05-25 16:58:32
原创
1241 人浏览过

[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);
	}
}
登录后复制

                   

                   

相关标签:
php
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板