From d00a119b8b46f2d2e0ba5f617625e3c9f7815a31 Mon Sep 17 00:00:00 2001 From: zhanglingsheng Date: Mon, 2 Dec 2019 15:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=99=9A=E6=8B=9F=E6=B3=A8?= =?UTF-8?q?=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Conf/config.php | 1 + .../SimulationRegisterController.class.php | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 Application/Sdk/Controller/SimulationRegisterController.class.php diff --git a/Application/Sdk/Conf/config.php b/Application/Sdk/Conf/config.php index f4802681..dbb41739 100644 --- a/Application/Sdk/Conf/config.php +++ b/Application/Sdk/Conf/config.php @@ -25,6 +25,7 @@ $config = array( /*获取信息加密KEY*/ 'GET_INFO_KEY' => 'wmkjtx_kj213', + 'REGISTER_KEY' => 'wmkjtx_kj759_kj', /* 文件上传相关配置 */ 'DOWNLOAD_UPLOAD' => array( diff --git a/Application/Sdk/Controller/SimulationRegisterController.class.php b/Application/Sdk/Controller/SimulationRegisterController.class.php new file mode 100644 index 00000000..042f3a8f --- /dev/null +++ b/Application/Sdk/Controller/SimulationRegisterController.class.php @@ -0,0 +1,122 @@ + $data['time_stamp']) { + return $this->set_message(2002, 'fail,', '链接已过期'); + } else { + $sign = $data['sign']; + unset($data['sign']); + ksort($data); + reset($data); + $str = ""; + foreach ($data as $k => $v) { + $str = $str . $k . "=" . $v; + } + $str = $str . 'key=' . C('REGISTER_KEY'); + if (md5($str) != $sign) { + return $this->set_message(2001, 'fail,', '参数错误'); + } + } + } + + public function user_register() + { + + #获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组 + $user = I('request.'); + $user['register_type'] = 7;//模拟注册 + #判断数据是否为空 + if (empty($user)) { + $this->set_message(1001, "fail", "注册数据不能为空"); + } + Log::write('mn_user_register:' . date('Y-m-d H:i:s') . ' ---- ' . json_encode($user), 'INFO'); + /**是否开启ucenter**/ + if (C('UC_OPEN') == 1) { + //Ucenter注册 + //1.验证本平台是否存在账号 + $is_user_info = M('user', 'tab_')->where(['account' => $user['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={$user['account']}"; + $check_res = json_decode(file_get_contents($url), true); + if ($check_res['status'] == 0) { + $this->set_message(1017, "fail", "用户名已存在"); + } + } + //3.ucenter注册账号 + $ucresult = uc_user_checkname($user['account']); + if ($ucresult == -1) { + $this->set_message(0, "fail", "用户名不合法"); + } elseif ($ucresult == -2) { + $this->set_message(0, "fail", "包含要允许注册的词语"); + } elseif ($ucresult == -3) { + $this->set_message(1017, "fail", "用户名已存在"); + } else { + //同步ucenter注册 + cus_uc_register($user['account'], $user['password'], $user['account'] . '@vlcms.com'); + } + } + $this->reg_data($user); + + } + + + //注册信息 + private function reg_data($user, $type = 1) + { + + #实例化用户接口 + $userApi = new MemberApi(); + + if (!preg_match('/^[0-9a-zA-Z]{6,12}$/', $user['password'])) { + $this->set_message(1027, "fail", "密码长度为6-12位"); + } + if (strlen($user['account']) < 6 || strlen($user['account']) > 15) { + $this->set_message(1027, "fail", "账号长度为6-15位"); + } elseif (!preg_match('/^[0-9]+[a-zA-Z]+[0-9a-zA-Z]*|[a-zA-Z]+[0-9]+[0-9a-zA-Z]*$/', $user['account'])) { + $this->set_message(1027, "fail", "账号必须字母数字组合"); + } + $result = $userApi->sdk_register_($user['account'], $user['password'], 1, $user['register_type'], $user['promote_id'], get_promote_name($user['promote_id']), $phone = "", $user["game_id"], get_game_name($user["game_id"]), $user['sdk_version'], $user['device_type'], $user['unique_code']); + if ($result > 0) { + $this->set_message(200, "success", "注册成功"); + } else { + + switch ($result) { + case -3: + $this->set_message(1017, "fail", "用户名已存在"); + break; + default: + $this->set_message(1027, "fail", "注册失败"); + break; + } + } + } + + + 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); + } + + +}