Ejemplo n.º 1
0
 public function UserLogin($User, $UserInfo)
 {
     $oUser = new Lm_User();
     $AppList = @(include __APP_ROOT_DIR__ . "/etc/App.php");
     $PartnerAppList = @(include __APP_ROOT_DIR__ . "/etc/PartnerApp.php");
     $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php");
     if ($UserInfo['UserId']) {
         if ($UserInfo['UserPassWord'] != "0") {
             if ($User['UserPassWord'] == $UserInfo['UserPassWord']) {
                 unset($User['UserPassWord'], $User['ReturnType']);
                 //判断用户所选服务器大区是否存在
                 $ServerInfo = $ServerList[$User['ServerId']];
                 if ($ServerInfo['ServerId']) {
                     $Comment = json_decode($ServerInfo['Comment'], true);
                     if (isset($Comment['IpListBlack'][$User['UserLoginIP']])) {
                         $result = array('return' => 0, 'comment' => "您的IP已经被限制登录");
                     } else {
                         //判断当前时间是否在开服之前
                         if (time() >= intval($ServerInfo['LoginStart']) || isset($Comment['IpListWhite'][$User['UserLoginIP']])) {
                             //判断当前时间是否处于停机维护
                             if (time() > $ServerInfo['NextEnd'] && time() < $ServerInfo['NextStart'] && !isset($Comment['IpListWhite'][$User['UserLoginIP']])) {
                                 $result = array('return' => 0, 'comment' => "您所选的服务器处于停机维护中");
                             } else {
                                 //判断服务器信息附带的游戏-运营商信息是否合法
                                 $bind = array($ServerInfo['PartnerId'], $ServerInfo['AppId']);
                                 $PartnerInfo = $PartnerAppList[$ServerInfo['AppId']][$ServerInfo['PartnerId']];
                                 if ($PartnerInfo['AppId'] && $PartnerInfo['PartnerId']) {
                                     $is_freeze = $oUser->getCharacterFreeze($UserInfo['UserId'], $ServerInfo['ServerId']);
                                     if (!$is_freeze['FreezeCount']) {
                                         $Active = 0;
                                         if ($PartnerInfo['IsActive'] == 1) {
                                             $UserActive = $oUser->getUserActive($UserInfo['UserId'], $ServerInfo['AppId'], $ServerInfo['PartnerId']);
                                             $Active = count($UserActive) ? 1 : 0;
                                         } else {
                                             $Active = 1;
                                         }
                                         //检查用户是否激活
                                         if ($Active) {
                                             $AppInfo = $AppList[$ServerInfo['AppId']];
                                             //检查游戏配置是否存在
                                             if ($AppInfo['AppId']) {
                                                 $Comment = json_decode($AppInfo['comment'], true);
                                                 //检查是否由平台生成登陆ID
                                                 if ($Comment['create_loginid']) {
                                                     $FirstLogin = $this->getFirstLogin($UserInfo['UserId'], $ServerInfo['AppId'], $ServerInfo['PartnerId'], $ServerInfo['ServerId']);
                                                     $User['AppId'] = $ServerInfo['AppId'];
                                                     $User['PartnerId'] = $ServerInfo['PartnerId'];
                                                     $User['UserSourceId'] = $UserInfo['UserSourceId'];
                                                     $User['UserSourceDetail'] = $UserInfo['UserSourceDetail'];
                                                     $User['UserSourceActionId'] = $UserInfo['UserSourceActionId'];
                                                     $User['UserSourceProjectId'] = $UserInfo['UserSourceProjectId'];
                                                     $User['UserRegTime'] = $UserInfo['UserRegTime'];
                                                     $User['FirstLoginTime'] = $FirstLogin ? $FirstLogin : $User['LoginTime'];
                                                     $AddLog = $this->InsertLoginLog($User, $UserInfo['UserName']);
                                                     //获取用户生日信息
                                                     $UserBirthday = $oUser->GetUserCommunication($User['UserId'], "UserBirthDay");
                                                     //根据用户生日信息判断是否为成年(1成年,0未成年,2为空)
                                                     $adult = base_common::checkAdult($UserBirthday['UserBirthDay']);
                                                     //返回用户ID,不包含(23000)
                                                     if ($AddLog) {
                                                         $result = array('return' => 1, 'LoginId' => $AddLog, 'UserId' => $UserInfo['UserId'], 'adult' => $adult, 'comment' => "登录成功");
                                                     } else {
                                                         $result = array('return' => 2, 'comment' => "登录失败");
                                                     }
                                                 } else {
                                                     $UserBirthday = $oUser->GetUserCommunication($User['UserId'], "UserBirthDay");
                                                     //根据用户生日信息判断是否为成年(1成年,0未成年,2为空)
                                                     $adult = base_common::checkAdult($UserBirthday['UserBirthDay']);
                                                     $result = array('return' => 1, 'LoginId' => 0, 'UserId' => $UserInfo['UserId'], 'adult' => $adult, 'comment' => "登录成功");
                                                 }
                                             } else {
                                                 $result = array('return' => 2, 'comment' => "无此游戏");
                                             }
                                         } else {
                                             $result = array('return' => 0, 'comment' => "您尚未激活");
                                         }
                                     } else {
                                         $result = array('return' => 2, 'comment' => "账号处于" . $is_freeze['FreezeCount'] . "次封停中<br>" . date("Y-m-d H:i:s", $is_freeze['MaxTime']) . "前禁止登陆");
                                     }
                                 } else {
                                     $result = array('return' => 2, 'comment' => "服务器配置信息错误");
                                 }
                             }
                         } else {
                             $result = array('return' => 0, 'comment' => "您所选的服务器尚未开启");
                         }
                     }
                 } else {
                     $result = array('return' => 0, 'comment' => "您所选择的服务器不存在");
                 }
             } else {
                 $result = array('return' => 2, 'comment' => "账号或密码错误");
             }
         } else {
             $result = array('return' => 0, 'comment' => "用户已被封停");
         }
     } else {
         $result = array('return' => 2, 'comment' => "账号或密码错误");
     }
     return $result;
 }