|
|
@ -134,16 +134,90 @@ class SsgController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
//注册
|
|
|
|
//注册
|
|
|
|
public function phoneRegister()
|
|
|
|
public function phoneRegister()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//获取手机号
|
|
|
|
//添加用户
|
|
|
|
|
|
|
|
C(api('Config/lists'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$user = $_POST;
|
|
|
|
|
|
|
|
$promoteId =( $user['promote_id'] ? $user['promote_id'] : 0);
|
|
|
|
|
|
|
|
#判断数据是否为空
|
|
|
|
|
|
|
|
if (empty($user)) {
|
|
|
|
|
|
|
|
$this -> set_message(1001, "fail", "注册数据不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#验证短信验证码
|
|
|
|
|
|
|
|
$this -> sms_verify($user['account'], $user['code']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res = $this -> doRegister($user['account'],$user['password'],$user['account'],$promoteId,4,2);
|
|
|
|
|
|
|
|
if(empty($res)){
|
|
|
|
|
|
|
|
$this -> set_message(1017, "fail", "添加失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//添加自动登录
|
|
|
|
|
|
|
|
$_SESSION['user_id'] = $res;
|
|
|
|
|
|
|
|
$this -> set_message(1, "success", "添加成功");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//普通注册
|
|
|
|
|
|
|
|
public function userRegister()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$account = I("account");
|
|
|
|
|
|
|
|
$password = I("password");
|
|
|
|
|
|
|
|
$promoteId = I("promote_id", 0);
|
|
|
|
|
|
|
|
$res = $this -> doRegister($account,$password,'',$promoteId,4,1);
|
|
|
|
|
|
|
|
if(empty($res)){
|
|
|
|
|
|
|
|
$this -> set_message(1017, "fail", "添加失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//添加自动登录
|
|
|
|
|
|
|
|
$_SESSION['user_id'] = $res;
|
|
|
|
|
|
|
|
$this -> set_message(1, "success", "添加成功");
|
|
|
|
# code...
|
|
|
|
# code...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//消息返回
|
|
|
|
|
|
|
|
public function set_message($status=0,$return_code="fail",$return_msg="操作失败"){
|
|
|
|
|
|
|
|
$msg = array(
|
|
|
|
|
|
|
|
"status" => $status,
|
|
|
|
|
|
|
|
"return_code" => $return_code,
|
|
|
|
|
|
|
|
"return_msg" => $return_msg
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->ajaxReturn($msg,'JSON');
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
//真正注册代码
|
|
|
|
//真正注册代码
|
|
|
|
public function doRegister()
|
|
|
|
public function doRegister($account,$password,$phone,$promote_id,$register_way,$register_type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//验证账号
|
|
|
|
|
|
|
|
$is_user_info = M('user', 'tab_') -> where(['account' => $account]) -> find();
|
|
|
|
|
|
|
|
if (!empty($is_user_info)) {
|
|
|
|
|
|
|
|
$this -> set_message(1017, "fail", "用户名已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//2.验证其他平台是否存在账号
|
|
|
|
|
|
|
|
$domain = C('UC_OTHER_WEB_URL');
|
|
|
|
|
|
|
|
if (!empty($domain)) {
|
|
|
|
|
|
|
|
$url = "http://{$domain}/Api/user/checkUserName?account={$account}";
|
|
|
|
|
|
|
|
$check_res = json_decode(file_get_contents($url), true);
|
|
|
|
|
|
|
|
if ($check_res['status'] == 0) {
|
|
|
|
|
|
|
|
$this -> set_message(1017, "fail", "用户名已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
|
|
|
'account' => $account,
|
|
|
|
|
|
|
|
'password' => think_ucenter_md5($password, UC_AUTH_KEY),
|
|
|
|
|
|
|
|
'phone' => $phone,
|
|
|
|
|
|
|
|
'head_img' =>'',
|
|
|
|
|
|
|
|
'promote_id' => $promote_id,
|
|
|
|
|
|
|
|
'promote_account' =>get_promote_account($promote_id),
|
|
|
|
|
|
|
|
'register_way' => $register_way,
|
|
|
|
|
|
|
|
'register_type' => $register_type,
|
|
|
|
|
|
|
|
'register_ip' => get_client_ip(),
|
|
|
|
|
|
|
|
'parent_id'=>get_fu_id($promote_id),
|
|
|
|
|
|
|
|
'parent_name'=>get_parent_name($promote_id),
|
|
|
|
|
|
|
|
'register_time'=>time(),
|
|
|
|
|
|
|
|
'check_time' => time(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
/* 添加用户 */
|
|
|
|
|
|
|
|
$res = M('user', 'tab_') ->add($data);
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
# code...
|
|
|
|
# code...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,4 +336,28 @@ class SsgController extends BaseController {
|
|
|
|
$res = array("day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs);
|
|
|
|
$res = array("day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs);
|
|
|
|
return $res;
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sms_verify($phone="" ,$code="",$type=2){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = R('Common/Sms/verify_sms_code',array($phone,$code,false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($result['code']==200) {
|
|
|
|
|
|
|
|
if($type==1){
|
|
|
|
|
|
|
|
$this->set_message(200,"success","正确");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
switch ($result['code']) {
|
|
|
|
|
|
|
|
case 1021:{
|
|
|
|
|
|
|
|
$this->set_message(1010,"fail","验证码已失效,请重新获取");
|
|
|
|
|
|
|
|
};break;
|
|
|
|
|
|
|
|
case 1022:{
|
|
|
|
|
|
|
|
$this->set_message(1022,"fail","验证码不正确,请重新输入");
|
|
|
|
|
|
|
|
};break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
$this->set_message($result['code'],"fail",$result['msg']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|