From 8c2e9ee179220587b23992d4044bfdfeccd1745e Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:42:27 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E9=87=8D=E5=86=99=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.php | 499 +++++++++--------- .../Sdk/Controller/UserController.class.php | 18 + 2 files changed, 270 insertions(+), 247 deletions(-) diff --git a/Application/Base/Service/UserService.php b/Application/Base/Service/UserService.php index 66ccabf2..125371b7 100644 --- a/Application/Base/Service/UserService.php +++ b/Application/Base/Service/UserService.php @@ -1,198 +1,148 @@ select(['id'])->where(['tag' => ['in', [$ip, $deviceNum]]])->limit(1)->find(); - if (empty($ban)) { - return false; - } - return true; - } - - public function login() + public function loginSdk($params) { - #获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组 - $user = json_decode(base64_decode(file_get_contents("php://input")), true); - #判断数据是否为空 - if (empty($user)) { - $this -> set_message(1001, "fail", "登录数据不能为空"); + if ($this->loginLimit($params)) { + $this->resetLoginLimit(); + return ['status' => false, 'message' => '登录人数过多,请稍后再试']; } - - $account = $params['account']; - $password = $params['password']; - $gameId = $params['game_id']; + $account = $params['account'] ?? ''; + $password = $params['password'] ?? ''; + $gameId = $params['game_id'] ?? 0; $sdkVersion = $params['sdk_version']; - $deviceNum = $params['unique_code']; - - $ip = get_client_ip(); - - if ($this->isBan($ip, $user['unique_code'])) { - $this->set_message(1004, "fail", "设备已被禁用"); - } + $deviceNum = $params['unique_code'] ?? ''; + $clientIp = get_client_ip(); $game = M('game', 'tab_')->where(['game_id' => $gameId])->find(); - $user = M('user', 'tab_')->where(['account' => $account])->find(); - if (empty($user)) { - $this->set_message(1005, "fail", "账号或密码错误"); + $result = $this->doLogin($account, $password, $game, ['client_ip' => $clientIp, 'device_num' => $deviceNum]); + if (!$result['status']) { + $this->resetLoginLimit(); + return ['status' => false, 'message' => $result['message']]; } + $user = $result['data']['user']; - $userApi = new MemberApi(); - $result = $userApi->login_sdk($account, $password, 1, $gameId, $game['game_name'], $sdkVersion, $deviceNum); + $noticeCount = $this->getNoticeCount(); + $this->addUserPlay($user, $game, $clientIp); - $res_msg = array(); - switch ($result) { - - case - 1: -// $log['remarks'] = '扶持号被禁用'; -// log_action($log); - $this -> set_message(1005, "fail", "密码错误"); - break; - case - 2: -// $log['remarks'] = '密码错误'; -// log_action($log); - $this -> set_message(1005, "fail", "密码错误"); - break; - default: - if (is_array($result)) { - $user["user_id"] = $result['user_id']; - $user['puid'] = 0; - $this -> add_user_play($user); - $platform = $this -> get_platform($user['user_id']); - $small_list = $this -> small_list($user['user_id'], $user['game_id']); - $small_list[] = array('is_platform' => $platform, 'user_id' => $user['user_id'], 'account' => $user['account'], 'user_account' => $user['account']); - $user_res = M('User', 'tab_') -> where(['account' => $user['account']]) -> find(); - $unread_count = 0; - $time = time(); - $notice = M('notice', 'tab_')->where('start_time < ' . $time . ' AND game_id = ' . $user['game_id']. ' AND (end_time = 0 OR end_time >' . $time . ')')->getField('id',true); - if(!empty($notice)) - { - $unread_count += count($notice); - $where['notice_id'] = ['in', implode(',', $notice)]; - $where['user_id'] = $user['user_id']; - $where['is_read'] = 1; - $notice_read_count = M('notice_read', 'tab_')->where($where)->count(); - $unread_count -= $notice_read_count; - } - $unread_count += M('share_record', 'tab_') -> where(['invite_id' => $user['user_id'], 'award_coin' => ['gt', 0], 'read' => 0]) -> count(); - $unread_count += M('point_record', 'tab_') -> where(['type_id' => 6, 'user_id' => $user['user_id'], 'point' => ['gt', 0], 'read' => 0]) -> count(); - $notice_count = $unread_count; - $buddies_request = get_buddies_unagree_count($user['user_id']); - $unread_count += $buddies_request; - - $userToken = $result['user_token']; - $res_msg = array( - "status" => 200, - "return_code" => "success", - "return_msg" => "登录成功", - "user_id" => $user["user_id"], - "account" => $user["account"], - "nickname" => $user_res["nickname"] ? $user_res["nickname"] : $user["account"], - "sex" => $user_res["sex"] ? $user_res["sex"] : 0, - "is_platform" => $platform, - "token" => $result['token'], - "user_token" => $userToken, - "OTP_token" => think_encrypt(json_encode(array('uid' => $user["user_id"], 'time' => time())), 1), - 'is_uc' => 0, - "is_open_small_account" => C('IS_OPEN_SMALL_ACCOUNT'), - 'url' => 'http://' . str_replace(array('http://'), '', C('WEB_SITE')) . '/mobile.php', - 'small_list' => $small_list, - 'ios_packagename' => C('WEB_IOS_PACKAGENAME'), - 'android_packagename' => C('WEB_AND_PACKAGENAME'), - 'site_status' => C('SDK_SITE_STATUS'), - 'head_img' => !empty($user_res['head_img']) ? $user_res['head_img'] : '', - 'unread_count' => $unread_count, - 'notice_count' => $notice_count, - 'request_count' => $buddies_request, - ); - - // 通知后台 TASK_URLhttp://47.111.118.107:9501 - $url = C('TASK_URL')."/game-event/login"; - try { - post_async($url, [ - 'form_params' => [ - 'game_id' => $user["game_id"], - 'user_id' => $user["user_id"], - 'login_time' => time() - ] - ]); - } catch(\Exception $e) { - - } - - } else { -// $log['remarks'] = '未知错误'; -// log_action($log); - $this -> set_message(1028, "fail", "未知错误"); + $response = [ + 'status' => 200, + 'return_code' => 'success', + 'return_msg' => '登录成功', + 'user_id' => $user['id'], + 'account' => $user['account'], + 'nickname' => $user['nickname'] ? $user['nickname'] : $user['account'], + 'sex' => $user['sex'] ? $user['sex'] : 0, + 'is_platform' => $user['is_platform'], + 'token' => $result['data']['token'], + 'user_token' => $result['data']['user_token'], + 'OTP_token' => think_encrypt(json_encode(array('uid' => $user['id'], 'time' => time())), 1), + 'is_uc' => 0, + 'is_open_small_account' => C('IS_OPEN_SMALL_ACCOUNT'), + 'url' => 'http://' . str_replace(array('http://'), '', C('WEB_SITE')) . '/mobile.php', + 'small_list' => [], + 'ios_packagename' => C('WEB_IOS_PACKAGENAME'), + 'android_packagename' => C('WEB_AND_PACKAGENAME'), + 'site_status' => C('SDK_SITE_STATUS'), + 'head_img' => !empty($user['head_img']) ? $user['head_img'] : '', + 'unread_count' => $noticeCount, + 'notice_count' => $noticeCount, + 'request_count' => 0, + ]; - } - break; + $this->resetLoginLimit(); + return ['status' => true, 'message' => '登录成功', 'data' => $data]; + } + protected function isBan($ip, $deviceNum) + { + $ban = M('device_bans','tab_')->select(['id'])->where(['tag' => ['in', [$ip, $deviceNum]]])->limit(1)->find(); + if (empty($ban)) { + return false; } - $log['uid'] = $user['user_id']; -// log_action($log); - echo base64_encode(json_encode($res_msg)); + return true; } - protected function doLogin($user, $game, $clientIp, $deviceNum) + protected function doLogin($account, $password, $game, $params = []) { + $clientIp = $params['client_ip'] ?? get_client_ip(); + $deviceNum = $params['device_num'] ?? ''; + + if ($this->isBan($clientIp, $deviceNum)) { + return ['status' => false, 'message' => '设备已被禁用']; + } + + $user = M('user', 'tab_')->where(['account' => $account])->find(); + /* 获取用户数据 */ if (empty($user) || $user['lock_status'] != 1 && $user['check_status'] != 1) { - return null; + return ['status' => false, 'message' => '账号或密码错误']; } if (think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']) { - return null; + return ['status' => false, 'message' => '账号或密码错误']; } - $userData = []; - if (!$user['device_number']) { - $userData['device_number'] = $deviceNum; - } - - $testResource = M('test_resource','tab_')->select(['device_number'])->where("user_id=%s and apply_status=2", $user['id'])->find(); //测试资源(扶持号) + $testResource = M('test_resource','tab_')->select(['device_number'])->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) if ($testResource) { + if ($this->isIpWarning($user, $testResource, $deviceNum)) { + $this->ipWarningLog($user, $testResource, $deviceNum); + } if ($this->isDeviceError($user, $testResource, $deviceNum)) { $userData['last_device_number'] = $deviceNum; $userData['lock_status'] = 0 ; $this->deviceErrorLog($user, $testResource, $deviceNum); - return null; - } - if ($this->isIpWarning($user, $testResource, $deviceNum)) { - $this->ipWarningLog($user, $testResource, $deviceNum); + return ['status' => false, 'message' => '该账号已被禁用']; } } - $userData["id"] = $uid; - $userData["login_time"] = NOW_TIME; - $userData["login_ip"] = $clientIp; - $userData["last_login_ip"] = $clientIp; - $userData["last_device_number"] = $deviceNum; - $userData["token"] = $this->generateToken($uid,$account,$password); + $result = $this->getLoginToken($user, $game, $password); + if (!$result) { + return ['status' => false, 'message' => '系统异常']; + } + [$token, $userToken] = $result; + $userData = []; + if (!$user['device_number']) { + $userData['device_number'] = $deviceNum; + } + $userData['login_time'] = NOW_TIME; + $userData['login_ip'] = $clientIp; + $userData['last_login_ip'] = $clientIp; + $userData['last_device_number'] = $deviceNum; + + if(!$user['fgame_id']) { + $userData['fgame_id'] = $game['id']; + $userData['fgame_name'] = $game['game_name']; + } + $userData['token'] = $token; + $status = M('user', 'tab_')->where(['id' => $user['id']])->save($userData); + if ($status) { + return ['status' => false, 'message' => '登录异常']; + } - $userToken = 0; - if($testResource) { //扶持号 - if($user['device_number'] && $unique_code && $user['device_number'] != $unique_code){ //#当前登录设备信息与历史登录设备信息不一致,触发账户冻结 - $this->sdklogin_device_error($user,$test_resource,$unique_code); - $this->sdklogin_ip_error($user,$test_resource,get_client_ip()); - return -1;//扶持号被禁用 - }else{ - $token = $this->sdklogin_update($user,$account,$password,$user['fgame_id'],$game_id,$game_name,$unique_code,$userToken); //更新用户登录信息 - $this->user_login_record2($user,$type,$game_id,$game_name,$sdk_version); - $this->sdklogin_ip_error($user,$test_resource,get_client_ip()); - return array("user_id"=>$user['id'],"token"=>$token, "user_token" => $userToken); //登录成功,返回用户ID - } - }else{ - $token = $this->sdklogin_update($user,$account,$password,$user['fgame_id'],$game_id,$game_name,$unique_code,$userToken); //更新用户登录信息 - $this->user_login_record2($user,$type,$game_id,$game_name,$sdk_version); - return array("user_id"=>$user['id'],"token"=>$token, "user_token" => $userToken); //登录成功,返回用户ID + $this->addUserLoginRecord($user, $game, $clientIp, $deviceNum); + $this->addGameUserLoginRecord($user, $game, $clientIp, $deviceNum); + + if (!$user['device_type']) { + $this->oaDeviceTypeUpdate($user, $game); } + + $data = [ + 'user' => $user, + 'token' => $token, + 'user_token' => $userToken, + ]; + return ['status' => true, 'message' => '登录异常', 'data' => $data]; } protected function isDeviceError($user, $testResource, $deviceNum) @@ -215,15 +165,15 @@ class UserService $data['promote_id'] = $testResource['promote_id']; $data['promote_account'] = $testResource['promote_account']; $data['type'] = 2; - $data['detail'] = "登录设备号异常,本次异常设备号:" . $deviceNum . ",历史登录设备号:" . $user['device_number']; + $data['detail'] = '登录设备号异常,本次异常设备号:' . $deviceNum . ',历史登录设备号:' . $user['device_number']; $data['create_time'] = NOW_TIME; M('protect_log','tab_')->add($data); } protected function isIpWarning($user, $testResource, $deviceNum) { - $newResult = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$clientIp); - $oldResult = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$user['login_ip']); + $newResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIp); + $oldResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$user['login_ip']); $newResult = json_decode($newResult, true); $oldResult = json_decode($oldResult, true); if($newResult['data']['city'] != $oldResult['data']['city']) { @@ -245,7 +195,7 @@ class UserService $data['promote_id'] = $testResource['promote_id']; $data['promote_account'] =$testResource['promote_account']; $data['type'] = 1; - $data['detail'] = "登录IP异常,本次异常IP:" . $clientIp . ",历史登录IP:" . $user['login_ip']; + $data['detail'] = '登录IP异常,本次异常IP:' . $clientIp . ',历史登录IP:' . $user['login_ip']; $data['create_time'] = NOW_TIME; M('protect_log','tab_')->add($data); } @@ -256,112 +206,80 @@ class UserService return $token; } - protected function sdklogin_update($user, $account, $password, $user_fgame_id, $game_id, $game_name, $unique_code='', &$userToken=''){ - $model = M('User','tab_'); - $uid = $user['id']; - $data["id"] = $uid; - $data["login_time"] = NOW_TIME; - $data["login_ip"] = get_client_ip(); -// $data["device_number"] = $unique_code; - $data["last_login_ip"] = $user['login_ip']; - $data["last_device_number"] = $user['device_number'] ? $user['device_number'] : ''; - $data["token"] = $this->generateToken($uid,$account,$password); - - M('user_token','tab_')->startTrans(); - $userToken = $this->generateToken($uid,$account,$password).uniqid().rand(1000, 9999); - $relationGameId = M('game', 'tab_')->where([ - 'id' => $game_id - ])->getField('relation_game_id'); - - $userTokens = M('user_token','tab_')->where([ - 'user_id' => $uid, - 'game_id' => $game_id - ])->find(); - - if (!$userTokens) { - $r = M('user_token', 'tab_')->add([ - 'user_id' => $uid, - 'game_id' => $game_id, - 'relation_game_id' => $relationGameId, + protected function getLoginToken($user, $game, $password) + { + $token = $this->generateToken($user['id'], $user['account'], $password); + $userToken = $this->generateToken($user['id'], $user['account'], $password) . uniqid() . rand(1000, 9999); + $record = M('user_token','tab_')->where(['user_id' => $user['id'], 'game_id' => $game['id']])->find(); + if (!$record) { + M('user_token', 'tab_')->add([ + 'user_id' => $user['id'], + 'game_id' => $game['id'], + 'relation_game_id' => $game['relation_game_id'], 'user_token' => $userToken, 'login_cnt' => 1, 'create_time' => time(), 'update_time' => time() - ]); - if (!$r) { - M('user_token','tab_')->rollback(); - $msg = array( - "status" => 5, - "return_code" => 5, - "return_msg" => "数据出错", - "msg" => '1' - ); - echo base64_encode(json_encode($msg)); - exit(); - } - - $r = M('user_token', 'tab_')->where([ - 'user_id' => $uid, - 'relation_game_id' => $relationGameId + ]); + + M('user_token', 'tab_')->where([ + 'user_id' => $user['id'], + 'relation_game_id' => $game['relation_game_id'] ])->save([ 'user_token' => $userToken, - 'login_cnt' => $userTokens['login_cnt'] + 1, + 'login_cnt' => $record['login_cnt'] + 1, 'update_time' => time() ]); - if ($r === false) { - M('user_token','tab_')->rollback(); - $msg = array( - "status" => 5, - "return_code" => 5, - "return_msg" => "数据出错2", - "msg" => '1' - ); - echo base64_encode(json_encode($msg)); - exit(); - } } else { - $r = M('user_token', 'tab_')->where([ + M('user_token', 'tab_')->where([ 'user_id' => $uid, - 'game_id|relation_game_id' => $relationGameId + 'game_id|relation_game_id' => $game['relation_game_id'] ])->save([ 'user_token' => $userToken, - 'login_cnt' => $userTokens['login_cnt'] + 1, + 'login_cnt' => $record['login_cnt'] + 1, 'update_time' => time() ]); - if ($r === false) { - M('user_token','tab_')->rollback(); - exit(); - } } - M('user_token','tab_')->commit(); - - if($user_fgame_id){ - $model->save($data); - }else{ - $data['fgame_id']=$game_id; - $data['fgame_name']=$game_name; - $model->save($data); - $device_type = M('User','tab_')->where(['id' => $user['id']])->getField('device_type'); - if(empty($device_type)){ - $gameServer = substr($game_name, -10, 9); - if($gameServer == '安卓版'){ - $arr['device_type'] = 'Android'; - } elseif($gameServer == '苹果版') { - $arr['device_type'] = 'IOS'; - } - $arr['time'] = time(); - $arr['account'] = $account; - ksort($arr); - reset($arr); - $sign = md5(http_build_query($arr) . C('GET_INFO_KEY')); - $arr['sign'] = $sign; - $reData = curl_post('http://oa.76ba.com/api/wanmeng/deviceTypeUpdate',$arr); - } + return [$token, $userToken]; + } + + public function oaDeviceTypeUpdate($user, $game) + { + $gameServer = substr($game['game_name'], -10, 9); + if($gameServer == '安卓版'){ + $arr['device_type'] = 'Android'; + } elseif($gameServer == '苹果版') { + $arr['device_type'] = 'IOS'; } - return $data["token"]; + $arr['time'] = time(); + $arr['account'] = $user['account']; + ksort($arr); + reset($arr); + $sign = md5(http_build_query($arr) . C('GET_INFO_KEY')); + $arr['sign'] = $sign; + $reData = curl_post('http://oa.76ba.com/api/wanmeng/deviceTypeUpdate', $arr); + } + + protected function addUserLoginRecord($user, $game, $clientIp, $deviceNum){ + $data = [ + 'user_id' => $user['id'], + 'user_account' => $user['account'], + 'user_nickname' => $user['nickname'], + 'game_id' => $game['id'], + 'promote_id' => $user['promote_id'], + 'game_name' => $game['game_name'], + 'sdk_version' => $game['sdk_version'], + 'type' => 1, + 'server_id' => null, + 'server_name' => null, + 'login_time' => NOW_TIME, + 'login_ip' => $clientIp, + 'lpuid' => $user['puid'], + ]; + return M('user_login_record','tab_')->add($data); } - public function saveUserGameLoginRecord($user, $game, $clientIp, $deviceNum){ + protected function addUserGameLoginRecord($user, $game, $clientIp, $deviceNum){ $data = [ 'user_id' => $user['id'], 'user_account' => $user['account'], @@ -379,4 +297,91 @@ class UserService ]; return M('user_game_login_record','tab_')->add($data); } + + protected function dispatchLoginEvent($params) + { + try { + $client = new TaskClient(); + $client->post('/game-event/login', $params); + } catch(\Exception $e) { + + } + } + + protected function addUserPlay($user, $game, $clientIp) + { + $user_play = M('user_play', 'tab_'); + $map['game_id'] = $game['id']; + $map['user_id'] = $user['id']; + $map['sdk_version'] = $game['sdk_version']; + $userPlay = M('user_play', 'tab_')->where($map)->find(); + if (empty($userPlay)) { + $data = []; + $data['user_id'] = $user['user_id']; + $data['user_account'] = $user['account']; + $data['user_nickname'] = $user['nickname']; + $data['game_id'] = $user['game_id']; + $data['game_appid'] = $user['game_appid']; + $data['game_name'] = $game['game_name']; + $data['server_id'] = 0; + $data['server_name'] = ''; + $data['role_id'] = 0; + $data['parent_id'] = $user['parent_id']; + $data['parent_name'] = $user['parent_name']; + $data['role_name'] = ''; + $data['role_level'] = 0; + $data['bind_balance'] = 0; + $data['promote_id'] = $user['promote_id']; + $data['promote_account'] = $user['promote_account']; + $data['play_time'] = time(); + $data['play_ip'] = $clientIp; + $data['sdk_version'] = $game['sdk_version']; + $data['ppuid'] = $user['puid'] == '' ? 0 : $user['puid']; + $data['check_time'] = time(); + $data['create_time'] = time(); + $userPlay->add($data); + } + } + + protected function getNoticeCount() + { + $noticeCount = 0; + $time = time(); + $noticeIds = M('notice', 'tab_') + ->where('start_time < ' . $time . ' AND game_id = ' . $user['game_id']. ' AND (end_time = 0 OR end_time >' . $time . ')') + ->getField('id',true); + if(!empty($noticeIds)) + { + $noticeCount += count($noticeIds); + $where['notice_id'] = ['in', implode(',', $noticeIds)]; + $where['user_id'] = $user['id']; + $where['is_read'] = 1; + $noticeReadCount = M('notice_read', 'tab_')->where($where)->count(); + $noticeCount -= $noticeReadCount; + } + return $noticeCount; + } + + protected function loginLimit($params) + { + $isLoginLimit = intval(C('LOGIN_LIMIT_OPEN', null, 1)); + if ($isLoginLimit == 0) { + return false; + } + $loginLimitNum = C('LOGIN_LIMIT_NUM', null, 300); + $count = Redis::incr(Redis::KEY_LOGIN_LIMIT); + if ($count >= $loginLimitNum) { + Log::write('login_limit:' . date('Y-m-d H:i:s') . ' ---- ' . $count, 'INFO', '', C('LOG_PATH')."login_limit.log"); + return true; + } + return false; + } + + protected function resetLoginLimit() + { + $isLoginLimit = intval(C('LOGIN_LIMIT_OPEN', null, 1)); + if ($isLoginLimit != 0) { + Redis::decr(Redis::KEY_LOGIN_LIMIT); + } + } } \ No newline at end of file diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index 3567c1fa..c929691d 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -14,10 +14,28 @@ use Think\Log; use Sdk\Model\SmsLogModel; use Base\Tool\TaskClient; use Base\Tool\Redis; +use Base\Service\UserService; class UserController extends BaseController { + public function user_login_new() + { + $params = json_decode(base64_decode(file_get_contents("php://input")), true); + + if (empty($user)) { + $this -> set_message(1001, "fail", "登录数据不能为空"); + } + + $userService = new UserService(); + $result = $userService->loginSdk($params); + if ($result['status']) { + echo base64_encode(json_encode($result['data'])); + } else { + $this->set_message(1001, "fail", "登录数据不能为空"); + } + } + public function isBan($ip, $deviceNum) { $ban = M('device_bans','tab_')->field(['id'])->where(['tag' => ['in', [$ip, $deviceNum]]])->limit(1)->find(); From 127a49d4add5a0ac61d69cc7ebeb279d3bdf1e7a Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:45:39 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/BaseController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Sdk/Controller/BaseController.class.php b/Application/Sdk/Controller/BaseController.class.php index 51934b56..2a7f954c 100644 --- a/Application/Sdk/Controller/BaseController.class.php +++ b/Application/Sdk/Controller/BaseController.class.php @@ -16,7 +16,7 @@ class BaseController extends RestController{ ]; protected $noToken = [ - 'user_login', 'send_sms', 'verify_sms', 'forget_password', + 'user_login','user_login_new', 'send_sms', 'verify_sms', 'forget_password', 'init_sdk', 'device_record', 'force_update', 'thirdparty', 'get_customer_question', 'get_down_time', 'customer_contact', 'user_info','customer_question_list','user_phone_register' ]; From 5f8b002b73f22fc0a092dbefb5e0d453e777db03 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:47:26 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/UserController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index c929691d..96e77485 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -23,7 +23,7 @@ class UserController extends BaseController { $params = json_decode(base64_decode(file_get_contents("php://input")), true); - if (empty($user)) { + if (empty($params)) { $this -> set_message(1001, "fail", "登录数据不能为空"); } From 07417e6e71f7c6d3c13d8de6e64dbb84a57ae064 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:49:13 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Service/{UserService.php => UserService.class.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Application/Base/Service/{UserService.php => UserService.class.php} (100%) diff --git a/Application/Base/Service/UserService.php b/Application/Base/Service/UserService.class.php similarity index 100% rename from Application/Base/Service/UserService.php rename to Application/Base/Service/UserService.class.php From c283e45b10bccc9fe301aa9124f4a4f281e39d30 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:50:17 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 125371b7..fc5350e3 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -66,7 +66,7 @@ class UserService protected function isBan($ip, $deviceNum) { - $ban = M('device_bans','tab_')->select(['id'])->where(['tag' => ['in', [$ip, $deviceNum]]])->limit(1)->find(); + $ban = M('device_bans','tab_')->field(['id'])->where(['tag' => ['in', [$ip, $deviceNum]]])->limit(1)->find(); if (empty($ban)) { return false; } @@ -92,7 +92,7 @@ class UserService return ['status' => false, 'message' => '账号或密码错误']; } - $testResource = M('test_resource','tab_')->select(['device_number'])->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) + $testResource = M('test_resource','tab_')->field(['device_number'])->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) if ($testResource) { if ($this->isIpWarning($user, $testResource, $deviceNum)) { $this->ipWarningLog($user, $testResource, $deviceNum); From aed454e0c751b1b33f66e8bbf37b8b664e276e51 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:52:13 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index fc5350e3..1ee933e9 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -88,7 +88,7 @@ class UserService if (empty($user) || $user['lock_status'] != 1 && $user['check_status'] != 1) { return ['status' => false, 'message' => '账号或密码错误']; } - if (think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']) { + if ($this->password($password, UC_AUTH_KEY) === $user['password']) { return ['status' => false, 'message' => '账号或密码错误']; } @@ -384,4 +384,8 @@ class UserService Redis::decr(Redis::KEY_LOGIN_LIMIT); } } + + public function password($str, $key = 'ThinkUCenter'){ + return '' === $str ? '' : md5(sha1($str) . $key); + } } \ No newline at end of file From acc418644a2a1090c1c481841a3dc740a1208877 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:53:41 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/UserController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index 96e77485..2198c2e8 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -32,7 +32,7 @@ class UserController extends BaseController if ($result['status']) { echo base64_encode(json_encode($result['data'])); } else { - $this->set_message(1001, "fail", "登录数据不能为空"); + $this->set_message(1001, "fail", $result['message']); } } From be22d944f0c9f89bfc0650cde0f4494e98666cd3 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:56:32 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 1ee933e9..35468b3c 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -89,7 +89,7 @@ class UserService return ['status' => false, 'message' => '账号或密码错误']; } if ($this->password($password, UC_AUTH_KEY) === $user['password']) { - return ['status' => false, 'message' => '账号或密码错误']; + return ['status' => false, 'message' => '密码错误']; } $testResource = M('test_resource','tab_')->field(['device_number'])->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) From cd96d299eb782efe752531ba512227940cfccd20 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:57:32 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 35468b3c..9011673c 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -88,7 +88,7 @@ class UserService if (empty($user) || $user['lock_status'] != 1 && $user['check_status'] != 1) { return ['status' => false, 'message' => '账号或密码错误']; } - if ($this->password($password, UC_AUTH_KEY) === $user['password']) { + if ($this->password($password, UC_AUTH_KEY) !== $user['password']) { return ['status' => false, 'message' => '密码错误']; } From 4e1c37cd9095c9dd845facbdeff2eeb9d324dd07 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 12:58:42 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 9011673c..0e5e8b8c 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -92,7 +92,7 @@ class UserService return ['status' => false, 'message' => '密码错误']; } - $testResource = M('test_resource','tab_')->field(['device_number'])->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) + $testResource = M('test_resource','tab_')->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) if ($testResource) { if ($this->isIpWarning($user, $testResource, $deviceNum)) { $this->ipWarningLog($user, $testResource, $deviceNum); From bc3f71e715ff7634be5c28f2e6dfc2fc6d491ac4 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:00:16 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 0e5e8b8c..ec0b202f 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -126,7 +126,7 @@ class UserService } $userData['token'] = $token; $status = M('user', 'tab_')->where(['id' => $user['id']])->save($userData); - if ($status) { + if (!$status) { return ['status' => false, 'message' => '登录异常']; } @@ -142,7 +142,7 @@ class UserService 'token' => $token, 'user_token' => $userToken, ]; - return ['status' => true, 'message' => '登录异常', 'data' => $data]; + return ['status' => true, 'message' => '登录成功', 'data' => $data]; } protected function isDeviceError($user, $testResource, $deviceNum) From 5a967ac3459f34f10bef0eaecaff3e63dcbf672f Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:01:22 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index ec0b202f..4908ecf8 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -131,7 +131,7 @@ class UserService } $this->addUserLoginRecord($user, $game, $clientIp, $deviceNum); - $this->addGameUserLoginRecord($user, $game, $clientIp, $deviceNum); + $this->addUserGameLoginRecord($user, $game, $clientIp, $deviceNum); if (!$user['device_type']) { $this->oaDeviceTypeUpdate($user, $game); From ff6af3dbbc9e415d6d87d333cc4ac2aef3283452 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:02:20 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 4908ecf8..5bada77b 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -32,7 +32,7 @@ class UserService } $user = $result['data']['user']; - $noticeCount = $this->getNoticeCount(); + $noticeCount = $this->getNoticeCount($user); $this->addUserPlay($user, $game, $clientIp); $response = [ @@ -343,7 +343,7 @@ class UserService } } - protected function getNoticeCount() + protected function getNoticeCount($user) { $noticeCount = 0; $time = time(); From 77b58eeb52a347767e50e6bfae75fb43f884cdee Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:03:35 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 5bada77b..7846ae34 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -32,7 +32,7 @@ class UserService } $user = $result['data']['user']; - $noticeCount = $this->getNoticeCount($user); + $noticeCount = $this->getNoticeCount($user, $game); $this->addUserPlay($user, $game, $clientIp); $response = [ @@ -343,12 +343,12 @@ class UserService } } - protected function getNoticeCount($user) + protected function getNoticeCount($user, $game) { $noticeCount = 0; $time = time(); $noticeIds = M('notice', 'tab_') - ->where('start_time < ' . $time . ' AND game_id = ' . $user['game_id']. ' AND (end_time = 0 OR end_time >' . $time . ')') + ->where('start_time < ' . $time . ' AND game_id = ' . $game['id']. ' AND (end_time = 0 OR end_time >' . $time . ')') ->getField('id',true); if(!empty($noticeIds)) { From 097c104430422ac41ae6e9e44a6f0602d0968829 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:04:21 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 7846ae34..f1678797 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -35,7 +35,7 @@ class UserService $noticeCount = $this->getNoticeCount($user, $game); $this->addUserPlay($user, $game, $clientIp); - $response = [ + $data = [ 'status' => 200, 'return_code' => 'success', 'return_msg' => '登录成功', From 15be4ccb5cd401c06444c4cb680769aea7907d49 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:07:47 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index f1678797..4667e5cb 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -35,6 +35,14 @@ class UserService $noticeCount = $this->getNoticeCount($user, $game); $this->addUserPlay($user, $game, $clientIp); + $smallList = []; + $smallList[] = [ + 'is_platform' => $user['is_platform'], + 'user_id' => $user['id'], + 'account' => $user['account'], + 'user_account' => $user['account'] + ]; + $data = [ 'status' => 200, 'return_code' => 'success', @@ -50,7 +58,7 @@ class UserService 'is_uc' => 0, 'is_open_small_account' => C('IS_OPEN_SMALL_ACCOUNT'), 'url' => 'http://' . str_replace(array('http://'), '', C('WEB_SITE')) . '/mobile.php', - 'small_list' => [], + 'small_list' => $smallList, 'ios_packagename' => C('WEB_IOS_PACKAGENAME'), 'android_packagename' => C('WEB_AND_PACKAGENAME'), 'site_status' => C('SDK_SITE_STATUS'), From 7283eb13831b1c80e734985b05286170ad027a2b Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:16:53 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 4667e5cb..a09073d3 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -34,6 +34,11 @@ class UserService $noticeCount = $this->getNoticeCount($user, $game); $this->addUserPlay($user, $game, $clientIp); + $this->dispatchLoginEvent([ + 'game_id' => $game['id'], + 'user_id' => $user['id'], + 'login_time' => time(), + ]); $smallList = []; $smallList[] = [ @@ -102,7 +107,7 @@ class UserService $testResource = M('test_resource','tab_')->where('user_id=%s and apply_status=2', $user['id'])->find(); //测试资源(扶持号) if ($testResource) { - if ($this->isIpWarning($user, $testResource, $deviceNum)) { + if ($this->isIpWarning($user, $deviceNum)) { $this->ipWarningLog($user, $testResource, $deviceNum); } if ($this->isDeviceError($user, $testResource, $deviceNum)) { @@ -178,7 +183,7 @@ class UserService M('protect_log','tab_')->add($data); } - protected function isIpWarning($user, $testResource, $deviceNum) + protected function isIpWarning($user, $deviceNum) { $newResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIp); $oldResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$user['login_ip']); From 73f56eb06f520ce218a2484ee5da9b14caead610 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:24:54 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index a09073d3..f5a1a01f 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -225,7 +225,7 @@ class UserService $userToken = $this->generateToken($user['id'], $user['account'], $password) . uniqid() . rand(1000, 9999); $record = M('user_token','tab_')->where(['user_id' => $user['id'], 'game_id' => $game['id']])->find(); if (!$record) { - M('user_token', 'tab_')->add([ + $status = M('user_token', 'tab_')->add([ 'user_id' => $user['id'], 'game_id' => $game['id'], 'relation_game_id' => $game['relation_game_id'], @@ -234,6 +234,10 @@ class UserService 'create_time' => time(), 'update_time' => time() ]); + + if (!$status) { + return null; + } M('user_token', 'tab_')->where([ 'user_id' => $user['id'], @@ -244,14 +248,17 @@ class UserService 'update_time' => time() ]); } else { - M('user_token', 'tab_')->where([ + $status = M('user_token', 'tab_')->where([ 'user_id' => $uid, 'game_id|relation_game_id' => $game['relation_game_id'] ])->save([ 'user_token' => $userToken, 'login_cnt' => $record['login_cnt'] + 1, 'update_time' => time() - ]); + ]); + if ($status === false) { + return null; + } } return [$token, $userToken]; } From a0f36881b401268a12ce1505574d39da50df7c97 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:36:35 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/UserController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index 2198c2e8..a74ca647 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -19,7 +19,7 @@ use Base\Service\UserService; class UserController extends BaseController { - public function user_login_new() + public function user_login() { $params = json_decode(base64_decode(file_get_contents("php://input")), true); @@ -48,7 +48,7 @@ class UserController extends BaseController /** *SDK用户登录 */ - public function user_login() + public function user_login_old() { $count = Redis::incr(Redis::KEY_LOGIN_LIMIT); if ($count >= 300) { From 4653d80a10c72c540ccaf7cb7d7fa495102c18fe Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:46:12 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index f5a1a01f..c1acdabe 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -330,7 +330,7 @@ class UserService protected function addUserPlay($user, $game, $clientIp) { - $user_play = M('user_play', 'tab_'); + $map = []; $map['game_id'] = $game['id']; $map['user_id'] = $user['id']; $map['sdk_version'] = $game['sdk_version']; @@ -359,7 +359,7 @@ class UserService $data['ppuid'] = $user['puid'] == '' ? 0 : $user['puid']; $data['check_time'] = time(); $data['create_time'] = time(); - $userPlay->add($data); + M('user_play', 'tab_')->add($data); } } From eb5b868eada0d9ac5332f4da9f0f6d9171ae2b5a Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 13:57:53 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/BaseController.class.php | 2 +- Application/Sdk/Controller/UserController.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/Sdk/Controller/BaseController.class.php b/Application/Sdk/Controller/BaseController.class.php index 2a7f954c..5c95ccab 100644 --- a/Application/Sdk/Controller/BaseController.class.php +++ b/Application/Sdk/Controller/BaseController.class.php @@ -16,7 +16,7 @@ class BaseController extends RestController{ ]; protected $noToken = [ - 'user_login','user_login_new', 'send_sms', 'verify_sms', 'forget_password', + 'user_login','user_login_new', 'user_login_old', 'send_sms', 'verify_sms', 'forget_password', 'init_sdk', 'device_record', 'force_update', 'thirdparty', 'get_customer_question', 'get_down_time', 'customer_contact', 'user_info','customer_question_list','user_phone_register' ]; diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index a74ca647..2198c2e8 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -19,7 +19,7 @@ use Base\Service\UserService; class UserController extends BaseController { - public function user_login() + public function user_login_new() { $params = json_decode(base64_decode(file_get_contents("php://input")), true); @@ -48,7 +48,7 @@ class UserController extends BaseController /** *SDK用户登录 */ - public function user_login_old() + public function user_login() { $count = Redis::incr(Redis::KEY_LOGIN_LIMIT); if ($count >= 300) { From 94532e9522f0dfbae67b5281ee036a0f8dc18d6f Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 14:07:17 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Controller/UserController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index 2198c2e8..a74ca647 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -19,7 +19,7 @@ use Base\Service\UserService; class UserController extends BaseController { - public function user_login_new() + public function user_login() { $params = json_decode(base64_decode(file_get_contents("php://input")), true); @@ -48,7 +48,7 @@ class UserController extends BaseController /** *SDK用户登录 */ - public function user_login() + public function user_login_old() { $count = Redis::incr(Redis::KEY_LOGIN_LIMIT); if ($count >= 300) { From 7b27a12a77f1c1d7a94d911babf2108570aaed1a Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 14:27:29 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index c1acdabe..985831cd 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -239,7 +239,7 @@ class UserService return null; } - M('user_token', 'tab_')->where([ + $status = M('user_token', 'tab_')->where([ 'user_id' => $user['id'], 'relation_game_id' => $game['relation_game_id'] ])->save([ @@ -249,7 +249,7 @@ class UserService ]); } else { $status = M('user_token', 'tab_')->where([ - 'user_id' => $uid, + 'user_id' => $user['id'], 'game_id|relation_game_id' => $game['relation_game_id'] ])->save([ 'user_token' => $userToken, From e8aa46709c02b2ded6cac9c7e69d38001a8129fc Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 14:33:47 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Base/Service/UserService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 985831cd..b36effdf 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -24,7 +24,7 @@ class UserService $deviceNum = $params['unique_code'] ?? ''; $clientIp = get_client_ip(); - $game = M('game', 'tab_')->where(['game_id' => $gameId])->find(); + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); $result = $this->doLogin($account, $password, $game, ['client_ip' => $clientIp, 'device_num' => $deviceNum]); if (!$result['status']) { $this->resetLoginLimit(); From 2a9e2b3451895602c5bc9f23bca077a007aa1e66 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Apr 2020 18:07:39 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Common/Conf/config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Application/Common/Conf/config.php b/Application/Common/Conf/config.php index b260afc6..0a0b06fd 100644 --- a/Application/Common/Conf/config.php +++ b/Application/Common/Conf/config.php @@ -87,7 +87,9 @@ $config = array( //错误页面 'ERROR_MESSAGE' => '页面错误!请稍后再试~',//错误显示信息,非调试模式有效 'ERROR_PAGE' => 'public/error/404.html', // 错误定向页面 - + + 'LOGIN_LIMIT_OPEN' => 1, + 'LOGIN_LIMIT_NUM' => 100, ); $config = array_merge($config, $env); return array_merge($config, $cache_config);