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;
 }
Ejemplo n.º 2
0
 public function createKa91Pay($Order, $Pay)
 {
     $oOrder = new Lm_Order();
     $oUser = new Lm_User();
     $this->db->begin();
     $Order['OrderId'] = date("YmdHis", $Order['OrderTime']) . sprintf("%03d", $Order['AppId']) . sprintf("%03d", $Order['PartnerId']) . sprintf("%04d", rand(1, 9999));
     //支付订单
     $Pay['OrderId'] = $Order['OrderId'];
     $Pay['PayId'] = date("YmdHis", $Pay['PayedTime']) . sprintf("%04d", rand(1, 9999));
     $Date = date("Ym", $Pay['PayedTime']);
     $table_date = $this->createUserPayTableDate($Date);
     $table_user = $this->createUserPayTableUser($Pay['AcceptUserId']);
     $table_first = Base_Widget::getDbTable($this->table_first);
     $Date = $this->db->insert($table_date, $Pay);
     $User = $this->db->insert($table_user, $Pay);
     $first = $this->db->insert($table_first, $Pay);
     //合作方订单唯一保证
     $StageOrderArr = array('OrderId' => $Pay['OrderId'], 'StageOrder' => $Pay['StageOrder']);
     $InsertStageOrder = $this->insertKa91StageOrder($StageOrderArr);
     //给收款方加余额
     $UserCoinUpdate = $oUser->updateUserCoin($Pay['AcceptUserId'], $Pay['Coin']);
     //给支付方加积分,如无支付方帐号,则不加
     $UserCreditUpdate = $Pay['PayUserId'] ? $oUser->updateUserCredit($Pay['PayUserId'], $Pay['Coin']) : 1;
     //生成订单
     $Order['PayId'] = $Pay['PayId'];
     $Date = date("Ym", $Order['OrderTime']);
     $table_date = $oOrder->createUserOrderTableDate($Date);
     $table_user = $oOrder->createUserOrderTableUser($Order['AcceptUserId']);
     $table_to_insert = $table_date;
     $order_date = $this->db->insert($table_to_insert, $Order);
     if (intval($order_date) && intval($order_date) != 23000) {
         $table_to_insert = $table_user;
         $user = $this->db->insert($table_to_insert, $Order);
     }
     if ($InsertStageOrder && $Date && $User && $UserCoinUpdate && $UserCreditUpdate && $order_date && $user) {
         $this->db->commit();
         return $Pay['OrderId'];
     } else {
         $this->db->rollBack();
         return false;
     }
 }
Ejemplo n.º 3
0
 public function getUserByPvpRank($Name)
 {
     $table_name = Base_Widget::getDbTable($this->table_pvp_log_total);
     $sql = "select distinct(ServerId) as ServerId from {$table_name}";
     $ServerList = $this->db->getAll($sql);
     $oCharacter = new Lm_Character();
     $oUser = new Lm_User();
     foreach ($ServerList as $key => $value) {
         $sql = "select sum(if(Won=1,10*PvpCount,if(Won=0,2*PvpCount,if(Won=3,-10*PvpCount,0)))) as PvpPoint,UserId from {$table_name} where ServerId = " . $value['ServerId'] . " group by UserId order by PvpPoint desc limit 1000";
         $sql = "select UserId,Sum(Point) as PvpPoint from (select (if(Won=1,10*PvpCount,if(Won=0,2*PvpCount,if(Won=3,-10*PvpCount,0)))) as Point,UserId,Won from {$table_name} where ServerId = " . $value['ServerId'] . ") as log group by UserId Order by PvpPoint Desc";
         $ResultAll = $this->db->getAll($sql);
         $PvpAll[$value['ServerId']] = array();
         foreach ($ResultAll as $k => $v) {
             $PvpRankAll[$value['ServerId']][$k + 1] = $v;
             $CharacterInfo = $oCharacter->getCharacterInfoByUser($v['UserId'], $value['ServerId'], 'CharacterName');
             $UserInfo = $oUser->getCharacterInfoByUser($v['UserId'], 'UserName');
             if (isset($CharacterInfo['0'])) {
                 $PvpRankAll[$value['ServerId']][$k + 1]['CharacterName'] = $CharacterInfo['0']['CharacterName'];
             } else {
                 $PvpRankAll[$value['ServerId']][$k + 1]['CharacterName'] = 0;
             }
             if (isset($UserInfo['UserName'])) {
                 $PvpRankAll[$value['ServerId']][$k + 1]['UserName'] = $UserInfo['UserName'];
             } else {
                 $PvpRankAll[$value['ServerId']][$k + 1]['UserName'] = 0;
             }
         }
     }
     $file_path = "/www/web_usercenter/app/etc/";
     $file_name = "PvpRank.php";
     $var = var_export($PvpRankAll, true);
     $text = '<?php $PvpRankAll=' . $var . '; return $PvpRankAll;?>';
     file_put_contents($file_path . $file_name, $text);
     $file_name = "PvpRank-" . $Name . ".php";
     file_put_contents($file_path . $file_name, $text);
 }
Ejemplo n.º 4
0
 public function ExchangeFail($ExchangeId)
 {
     $ExchangeInfo = $this->getQueuedExchange($ExchangeId);
     if ($ExchangeInfo['ExchangeId']) {
         $this->db->begin();
         //移除到兑换失败队列
         unset($ExchangeInfo['ToSendTime']);
         $addErrorExchangeQueue = $this->addErrorExchange($ExchangeInfo);
         $delExchangeQueue = $this->deleteExchangeQueue($ExchangeInfo['ExchangeId']);
         $updateOrderStatus = false;
         //更新订单状态
         if ($ExchangeInfo['OrderId']) {
             $oOrder = new Lm_Order();
             $updateOrderStatus = $oOrder->updateOrder($ExchangeInfo['OrderId'], $ExchangeInfo['UserId'], array('OrderStatus' => '3'));
         } else {
             $updateOrderStatus = true;
         }
         //退款
         $oUser = new Lm_User();
         $coinUpdate = $oUser->updateUserCoin($ExchangeInfo['UserId'], $ExchangeInfo['Coin']);
         if ($addErrorExchangeQueue && $delExchangeQueue && $updateOrderStatus && $coinUpdate) {
             $this->db->commit();
             return true;
         } else {
             $this->db->rollback();
             return false;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 5
0
 function readLine($file, $ServerInfo)
 {
     if (file_exists($file)) {
         $fd = fopen($file, "r");
         while ($buffer = fgets($fd)) {
             $data = explode(":", substr($buffer, 20, strlen($buffer)));
             if (strstr($buffer, "addcash")) {
                 $function = explode(";", $data[0]);
             } else {
                 if (strstr($buffer, "pickitem")) {
                     $function = explode(";", $data[1]);
                 } else {
                     $function = explode(";", $data[2]);
                 }
             }
             $log = array();
             $log['time'] = substr($buffer, 0, 19);
             $log['type'] = $function[0];
             $log['function'] = $function[1];
             $log['text'] = $buffer;
             unset($function[0], $function[1]);
             foreach ($function as $k => $v) {
                 $newdata = explode("=", $v);
                 $log['data'][$newdata[0]] = $newdata[1];
             }
             $result = array();
             //                if($log['function'] != 'logout')
             //                {
             //continue;
             //                    print_R($log['data']);
             //                }
             //echo "\n".$log['function'];
             switch ($log['function']) {
                 //登陆
                 case "login":
                     $oUser = new Lm_User();
                     $oLogin = new Lm_Login();
                     $UserInfo = $oUser->GetUserById($log['data']['AccountID']);
                     if ($UserInfo['UserId']) {
                         $FirstLogin = $oLogin->getFirstLogin($UserInfo['UserId'], $ServerInfo['AppId'], $ServerInfo['PartnerId'], $ServerInfo['ServerId']);
                         $DataArr = array('UserId' => $log['data']['AccountID'], 'UserLoginIP' => $log['data']['IP'], 'LoginTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId'], 'UserSourceId' => $UserInfo['UserSourceId'], 'UserSourceDetail' => $UserInfo['UserSourceDetail'], 'UserSourceActionId' => $UserInfo['UserSourceActionId'], 'UserSourceProjectId' => $UserInfo['UserSourceProjectId'], 'UserRegTime' => $UserInfo['UserRegTime'], 'FirstLoginTime' => $FirstLogin ? $FirstLogin : strtotime($log['time']));
                         $insertLog = $oLogin->InsertLoginLog($DataArr, $UserInfo['UserName']);
                     } else {
                         break;
                     }
                     break;
                     //创建角色
                 //创建角色
                 case "newname":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => 1, 'CharacterName' => iconv('GBK', 'UTF-8//IGNORE', $log['data']['Name']), 'CharacterCreateTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oCharacter = new Lm_Character();
                     $insertLog = $oCharacter->CreateCharacter($DataArr);
                     break;
                     //获得永久英雄
                 //获得永久英雄
                 case "addhero":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'HeroId' => $log['data']['HeroID'], 'AddReason' => $log['data']['Reason'], 'HeroNum' => $log['data']['HeroNum'], 'TimeLimit' => 0, 'HeroAddTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oHerolog = new Lm_Hero();
                     //$insertLog = $oHerolog->InsertHeroAddLog($DataArr);
                     break;
                     //获得时效英雄
                 //获得时效英雄
                 case "addtimehero":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'HeroId' => $log['data']['HeroID'], 'AddReason' => $log['data']['Reason'], 'HeroNum' => $log['data']['HeroNum'], 'TimeLimit' => $log['data']['validtime'], 'HeroAddTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oHerolog = new Lm_Hero();
                     //$insertLog = $oHerolog->InsertHeroAddLog($DataArr);
                     break;
                     //切换英雄
                 //切换英雄
                 case "changehero":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'CurHeroId' => $log['data']['CurHeroID'], 'NewHeroId' => $log['data']['NewHeroID'], 'HeroChangeTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oHerolog = new Lm_Hero();
                     //$insertLog = $oHerolog->InsertHeroChangeLog($DataArr);
                     break;
                     //接取任务
                 //接取任务
                 case "accepttask":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'TaskId' => $log['data']['TaskID'], 'TaskType' => $log['data']['TaskType'], 'HeroAcceptTaskTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oTask = new Lm_Task();
                     $insertLog = $oTask->InsertCharacterAcceptTaskLog($DataArr);
                     break;
                     //完成任务
                 //完成任务
                 case "taskcomplete":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'TaskId' => $log['data']['TaskID'], 'TaskType' => $log['data']['TaskType'], 'HeroTaskCompleteTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oTask = new Lm_Task();
                     $insertLog = $oTask->InsertCharacterTaskCompleteLog($DataArr);
                     break;
                     //商城购买
                 //商城购买
                 case "shopitem":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'ItemId' => $log['data']['ItemID'], 'ItemNum' => $log['data']['ItemNum'], 'AppCoin' => $log['data']['Gold'], 'AppCoinLast' => $log['data']['LastGold'], 'ItemPrice' => intval($log['data']['Gold'] / $log['data']['ItemNum']), 'PurchaseTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oPurchase = new Lm_Purchase();
                     $insertLog = $oPurchase->InsertPurchaseLog($DataArr);
                     $replaceArr = array('UserId' => $log['data']['AccountID'], 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId'], 'LastMoney' => $log['data']['LastGold'], 'MoneyType' => 1);
                     $replace = $oPurchase->ReplaceUserLastmoney($replaceArr);
                     $insertLog = $insertLog * $replace;
                     break;
                     //npc购买
                 //npc购买
                 case "npcitem":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'NpcID' => $log['data']['NpcID'], 'ItemId' => $log['data']['ItemID'], 'ItemNum' => $log['data']['ItemNum'], 'Money' => $log['data']['Money'], 'MoneyType' => $log['data']['MoneyType'], 'LastMoney' => $log['data']['LastMoney'], 'NpcPurchaseTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oPurchase = new Lm_Purchase();
                     $insertLog = $oPurchase->InsertNpcPurchaseLog($DataArr);
                     $replaceArr = array('UserId' => $log['data']['AccountID'], 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId'], 'LastMoney' => $log['data']['LastMoney'], 'MoneyType' => $log['data']['MoneyType']);
                     $replace = $oPurchase->ReplaceUserLastmoney($replaceArr);
                     $insertLog = $insertLog * $replace;
                     break;
                     //角色死亡日志
                 //角色死亡日志
                 case "dead":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'MonsterId' => $log['data']['MonsterSlkID'], 'HeroId' => $log['data']['HeroID'], 'SlkId' => $log['data']['SlkID'], 'CharacterDeadTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oCharacter = new Lm_Character();
                     //$insertLog = $oCharacter->InsertCharacterDeadLog($DataArr);
                     break;
                     //角色进入副本
                 //角色进入副本
                 case "enterectype":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'HeroId' => $log['data']['HeroID'], 'TeamNum' => $log['data']['TeamNum'], 'SlkId' => $log['data']['SlkID'], 'EctypeId' => $log['data']['EctypeID'], 'CharacterSlkEnterTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oTask = new Lm_Task();
                     $insertLog = $oTask->InsertCharacterSlkLog($DataArr);
                     break;
                     //角色离开副本
                 //角色离开副本
                 case "leaveectype":
                     $bindArr = array($log['data']['AccountID'], $log['data']['SlkID'], $log['data']['EctypeID'], $ServerInfo['AppId'], $ServerInfo['PartnerId'], $ServerInfo['ServerId']);
                     $DataArr = array('CharacterSlkLeaveTime' => strtotime($log['time']), 'CharacterLeaveType' => intval($log['data']['Reason']));
                     $oTask = new Lm_Task();
                     $CharacterSlkEnterTime = $oTask->GetSlkIdMapLog($bindArr, 'CharacterSlkEnterTime');
                     if ($CharacterSlkEnterTime) {
                         $updateLog = $oTask->LeaveSlk($CharacterSlkEnterTime, $DataArr, $bindArr, $log['data']['AccountID']);
                         $insertLog = $updateLog;
                     }
                     break;
                     //登出
                 //登出
                 case "logout":
                     $oUser = new Lm_User();
                     $oLogin = new Lm_Login();
                     $UserInfo = $oUser->GetUserById($log['data']['AccountID']);
                     if ($UserInfo['UserId']) {
                         $DataArr = array('UserId' => $log['data']['AccountID'], 'LogoutTime' => strtotime($log['time']), 'LoginTime' => $log['data']['TimeStamp'], 'ServerId' => $ServerInfo['ServerId']);
                         $insertLog = $oLogin->LogoutByTime($DataArr, $UserInfo['UserName']);
                     } else {
                         break;
                     }
                     break;
                     //                        $DataArr = array(
                     //                        'UserId'=>$log['data']['AccountID'],
                     //                        'LogoutTime'=>strtotime($log['time']),
                     //                        'AppId'=>$ServerInfo['AppId'],
                     //                        'PartnerId'=>$ServerInfo['PartnerId'],
                     //                        'ServerId'=>$ServerInfo['ServerId'],
                     //                        'LoginId'=>$log['data']['LoginID'],
                     //                        'LogoutLevel'=>$log['data']['Level'],
                     //                        'LogoutReason'=>$log['data']['Reason'],
                     //                        'MaxPing'=>$log['data']['MaxPing'],
                     //                        'MinPing'=>$log['data']['MinPing'],
                     //                        );
                     //
                     //                        $oCharacter = new Lm_Character();
                     //                        $insertLog = $oCharacter->InsertCharacterLogoutLog($DataArr);
                     //                        break;
                 //                        $DataArr = array(
                 //                        'UserId'=>$log['data']['AccountID'],
                 //                        'LogoutTime'=>strtotime($log['time']),
                 //                        'AppId'=>$ServerInfo['AppId'],
                 //                        'PartnerId'=>$ServerInfo['PartnerId'],
                 //                        'ServerId'=>$ServerInfo['ServerId'],
                 //                        'LoginId'=>$log['data']['LoginID'],
                 //                        'LogoutLevel'=>$log['data']['Level'],
                 //                        'LogoutReason'=>$log['data']['Reason'],
                 //                        'MaxPing'=>$log['data']['MaxPing'],
                 //                        'MinPing'=>$log['data']['MinPing'],
                 //                        );
                 //
                 //                        $oCharacter = new Lm_Character();
                 //                        $insertLog = $oCharacter->InsertCharacterLogoutLog($DataArr);
                 //                        break;
                 case "levelup":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'CharacterLevel' => $log['data']['Level'], 'CharacterLevelUpTime' => strtotime($log['time']), 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId']);
                     $oCharacter = new Lm_Character();
                     $insertLog = $oCharacter->InsertcharacterLevelUpLog($DataArr);
                     $updateLog = $oCharacter->updateCharacterInfo($log['data']['AccountID'], $ServerInfo['ServerId'], array('CharacterLevel' => $log['data']['Level']));
                     echo "\tupdate:" . $updateLog . "\n";
                     break;
                 case "tower":
                     $DataArr = array('UserId' => $log['data']['AccountID'], 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'ServerId' => $ServerInfo['ServerId'], 'EctypeID' => $log['data']['EctypeID'], 'CreateTowerTime' => strtotime($log['time']) - $log['data']['RunTime'] / 1000, 'EndTowerTime' => strtotime($log['time']), 'CharacterLevel' => $log['data']['Level'], 'HeroID' => $log['data']['HeroID'], 'SlkID' => $log['data']['SlkID'], 'TowerIndex' => $log['data']['Index'], 'PlayerIndex' => $log['data']['PlayerIndex'], 'PlayerNum' => $log['data']['PlayerNum'], 'RunTime' => $log['data']['RunTime']);
                     $oTask = new Lm_Task();
                     $insertLog = $oTask->insertTowerLog($DataArr);
                     break;
             }
             //                if($insertLog)
             //                {
             //                    echo "\tinsert:".$insertLog."\n";
             //                }
         }
         fclose($fd);
     } else {
         echo iconv("utf-8", "gbk", "文件" . $file . "不存在\n");
     }
 }
Ejemplo n.º 6
0
 public function asignProductPackCode($UserName, $unsignedCode)
 {
     $oUser = new Lm_User();
     $UserInfo = $oUser->getUserByName($UserName);
     if ($UserInfo['UserId']) {
         if ($unsignedCode['ProductPackCode']) {
             $PackInfo = $this->getRow($unsignedCode['ProductPackId']);
             $CodeCount = $this->getUserProductPackCodeListCount($UserInfo['UserId'], 0, 0, $unsignedCode['GenId']);
             if ($CodeCount < $PackInfo['AsignCountLimit']) {
                 $this->db->begin();
                 $unsignedCode['AsignTime'] = time();
                 $unsignedCode['AsignUser'] = $UserInfo['UserId'];
                 $position = Base_Common::getUserDataPositionById($UserInfo['UserId']);
                 $table_user = Base_Common::getUserTable($this->table_code, $position);
                 $user = $this->db->replace($table_user, $unsignedCode);
                 $table_code = Base_Widget::getDbTable($this->table_code);
                 $bind = $unsignedCode;
                 unset($bind['ProductPackCode']);
                 $code = $this->db->update($table_code, $bind, '`ProductPackCode` = ?', $unsignedCode['ProductPackCode']);
                 if ($code && $user) {
                     $this->db->commit();
                     return true;
                 } else {
                     $this->db->rollback();
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 7
0
 public function SocketCreateCharacter($buff)
 {
     $oCharacter = new Lm_Character();
     $oUser = new Lm_User();
     $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php");
     $format = "V1uLength/V1uID/v1Type/C1MsgLevel/C1Line/V1UserID/V1ZoneID/C*";
     $unpackArr = @unpack($format, $buff);
     $arrName = "";
     foreach ($unpackArr as $key => $value) {
         if (is_int($key)) {
             $arrName .= chr($value);
         }
     }
     $Character['UserId'] = $unpackArr['UserID'];
     $Character['CharacterName'] = str_replace("", "", iconv('GBK', 'UTF-8//IGNORE', $arrName));
     $Character['ServerId'] = $unpackArr['ZoneID'];
     $Character['CharacterLevel'] = 1;
     $Character['CharacterCreateTime'] = time();
     if ($Character['UserId']) {
         //验证用户名有效性
         if (strlen($Character['CharacterName']) >= 4 && strlen($Character['CharacterName']) <= 20) {
             //查询用户
             $UserInfo = $oUser->GetUserById($Character['UserId']);
             if ($UserInfo['UserId']) {
                 //判断用户所选服务器大区是否存在
                 $ServerInfo = $ServerList[$Character['ServerId']];
                 if ($ServerInfo['ServerId']) {
                     $Character['AppId'] = $ServerInfo['AppId'];
                     $Character['PartnerId'] = $ServerInfo['PartnerId'];
                     $CharacterInfo = $oCharacter->getCharacterInfoByUser($Character['UserId'], $Character['ServerId']);
                     if (count($CharacterInfo) == 0) {
                         $AddLog = $oCharacter->CreateCharacter($Character);
                         if ($AddLog) {
                             $result = array('return' => 1, 'comment' => "角色创建成功");
                         } else {
                             $result = array('return' => 0, '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' => 0, 'comment' => "请选择用户");
     }
     return $result;
 }
Ejemplo n.º 8
0
 public function getUserByPKPoint()
 {
     $oUser = new Lm_User();
     $table_name = Base_Widget::getDbTable($this->character_rank);
     $sql = "select distinct(ServerId) as ServerId from {$table_name}";
     $ServerList = $this->db->getAll($sql);
     foreach ($ServerList as $key => $value) {
         $sql = "select * from {$table_name} where ServerId = " . $value['ServerId'] . " order by PKPoint desc limit 1000";
         $ResultAll = $this->db->getAll($sql);
         $PKPointAll[$value['ServerId']] = array();
         foreach ($ResultAll as $k => $v) {
             $PKPointAll[$value['ServerId']][$k + 1] = $v;
             $UserInfo = $oUser->getCharacterInfoByUser($v['UserId'], 'UserName');
             if (isset($UserInfo['UserName'])) {
                 $PKPointAll[$value['ServerId']][$k + 1]['UserName'] = $UserInfo['UserName'];
             } else {
                 $PKPointAll[$value['ServerId']][$k + 1]['UserName'] = 0;
             }
         }
     }
     $file_path = "/www/web_usercenter/app/etc/";
     $file_name = "PKPoint.php";
     $var = var_export($PKPointAll, true);
     $text = '<?php $PKPointAll=' . $var . '; return $PKPointAll;?>';
     file_put_contents($file_path . $file_name, $text);
     $file_name = "PKPoint-" . date("YmdHis", time()) . ".php";
     file_put_contents($file_path . $file_name, $text);
 }
Ejemplo n.º 9
0
 public function productQueueSendDetailAction()
 {
     $oArea = new Config_Area();
     $oPartnerApp = new Config_Partner_App();
     $oServer = new Config_Server();
     $oPermission = new Config_Permission();
     $oUser = new Lm_User();
     $ProductSendTypeArr = $this->config->ProductSendTypeArr;
     $ProductTypeArr = $this->config->ProductTypeArr;
     //获取用户可以查看的游戏列表
     $permitted_app = $oPermission->getApp($this->manager->data_groups, 'AppId,name');
     $AreaList = $oArea->getAll();
     set_time_limit(0);
     $page = intval(max($this->request->page, 1));
     //检查当前页面权限
     $sign = '?ctl=config/product/product&ac=product.queue.send.detail';
     $this->manager->checkMenuPermission($sign, Widget_Manager::MENU_PURVIEW_SELECT);
     //页面输入变量
     $AppId = intval($this->request->AppId);
     $PartnerId = intval($this->request->PartnerId);
     $PassageId = intval($this->request->PassageId);
     $AreaId = intval($this->request->AreaId) ? intval($this->request->AreaId) : 0;
     $UserName = $this->request->UserName;
     $app_type = intval($this->request->app_type);
     $partner_type = intval($this->request->partner_type);
     $is_abroad = intval($this->request->is_abroad) ? intval($this->request->is_abroad) : 0;
     //页面输入变量
     $ProductSendType = $this->request->ProductSendType;
     $ProductType = $this->request->ProductType;
     //是否导出当前页面表格
     $export = $this->request->export ? intval($this->request->export) : 0;
     $pagesize = $export ? 0 : 20;
     //初始化图表配置
     $Input = array('UserName' => urlencode($UserName), 'AppId' => $AppId, 'PartnerId' => $PartnerId, 'ServerId' => $ServerId, 'ProductSendType' => $ProductSendType, 'export' => 1);
     $export_var = "<a href =" . Base_Common::getUrl('', 'config/product/product', 'product.queue.send.detail', $Input) . "><导出表格></a>";
     //初始化合作商列表
     $permitted_partner = array();
     //获取当前地区列表
     $AreaList = $oArea->getAbroad($is_abroad, $AreaList);
     //生成允许的地区id数组
     if ($app_type > 0) {
         //筛选是否平台产品
         $permitted_app = $this->oApp->getApp($app_type, $permitted_app);
     }
     if ($AppId > 0) {
         //获取可查看的权限总表
         $permitted_partner = $oPermission->getPartner($this->manager->data_groups, $AppId, 'PartnerId,name,AreaId');
         //根据合作方式筛选
         $permitted_partner = $oPartnerApp->getPermittedPartnerByPartnerType($partner_type, $permitted_partner);
         //根据所在地区筛选
         $permitted_partner = $oPartnerApp->getPermittedPartnerByPartnerArea($AreaList, $permitted_partner);
         if ($PartnerId > 0) {
             //获取服务器列表
             $permitted_server = $oPermission->getServer($this->manager->data_groups, $AppId, $PartnerId, 'ServerId,name');
         }
     }
     if ($UserName) {
         $UserInfo = $oUser->getUserByName($UserName);
         if ($UserInfo['UserId']) {
             $UserId = $UserInfo['UserId'];
         } else {
             $UserId = -1;
         }
     } else {
         $UserId = 0;
     }
     $ProductSendQueueDetailArr = $this->oProduct->getProductSendQueueDetail($UserId, $ProductSendType, $ProductType, $ServerId, ($page - 1) * $pagesize, $pagesize);
     $UserInfoList = array();
     if (is_array($ProductSendQueueDetailArr['ProductSendQueueDetail'])) {
         foreach ($ProductSendQueueDetailArr['ProductSendQueueDetail'] as $key => $value) {
             if ($value['UserId']) {
                 if (!isset($UserInfoList[$value['UserId']])) {
                     $UserInfo = $oUser->getUserById($value['UserId']);
                     $UserInfoList[$value['UserId']] = $UserInfo;
                 }
             }
             if (!isset($ServerInfo[$value['ServerId']])) {
                 $ServerInfo[$value['ServerId']] = $oServer->getRow($value['ServerId']);
             }
             $Comment = json_decode($value['Comment'], true);
             $ProductSendQueueDetailArr['ProductSendQueueDetail'][$key]['UserName'] = $value['UserId'] ? $UserInfoList[$value['UserId']]['UserName'] : "******";
             $ProductSendQueueDetailArr['ProductSendQueueDetail'][$key]['ProductSendTypeName'] = $ProductSendTypeArr[$value['SendType']];
             $ProductSendQueueDetailArr['ProductSendQueueDetail'][$key]['ProductTypeName'] = $ProductTypeArr[$value['ProductType']];
             $ProductSendQueueDetailArr['ProductSendQueueDetail'][$key]['ServerName'] = $ServerInfo[$value['ServerId']]['name'];
         }
     }
     $page_title = "道具发送队列详情";
     $page_form_action = $sign;
     //调取模板
     include $this->tpl('Config_Product_ProductSendQueueDetail');
 }