|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Sdk\Controller;
|
|
|
|
|
|
|
|
use Think\Controller;
|
|
|
|
use User\Api\MemberApi;
|
|
|
|
use Think\Log;
|
|
|
|
|
|
|
|
class SimulationRegisterController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
private $key = 'wmkjtx_kj759_kj';
|
|
|
|
public function _initialize()
|
|
|
|
{
|
|
|
|
C(api('Config/lists'));
|
|
|
|
$data = I('request.');
|
|
|
|
unset($data['PHPSESSID']);
|
|
|
|
if (empty($data['time_stamp']) || time() - 60 * 10 > $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=' . $this->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'] = 17;//模拟注册
|
|
|
|
#判断数据是否为空
|
|
|
|
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**/
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|