Exemplo n.º 1
0
 /**
  *c++服务器向php服务器发角色登陆请求 S2P 401 S2P_UserLoginRequest
  * 角色登陆的时候要获取的信息 包括人物的基本信息,装备,时装,技能,
  * 这条协议返回给C++服务器信息 然后转给前端信息
  */
 public function CMD2_401()
 {
     $playerInfo = null;
     $server_state = Com_System::check_server_halt();
     if (!$server_state['state']) {
         #是否在维护状态
         $data = array('err_code' => 4, 'player_id' => $this->_authuser['player_id'], 'player_name' => '', 'career_type' => 0, 'makes' => array(), 'values' => array());
     } else {
         $data = $this->get_game('PlayerBase')->playerInfo($this->_authuser['player_id'], $this->_param[0], $playerInfo);
     }
     Protocol::input($this->_authuser['player_id'], 5, 4, 401, $data);
     #更新登录天数
     $this->get_game('SevenReward')->update_login_date($this->_authuser['player_id'], $playerInfo);
     #累计登录天数
     $this->get_game('PlayerAchieve')->async_trigger_achieve_target($this->_authuser['player_id'], 33, 1, 6, $playerInfo['level']);
     //$this->get_game('AutoPve')->auto_receive_awards($this->_authuser['player_id']);
 }
Exemplo n.º 2
0
 public function dispatch()
 {
     #判断开服状态
     $server_state = Com_System::check_server_halt();
     if (!$server_state['state']) {
         echo $server_state['msg'];
         exit;
     }
     $this->parser_dispatch();
     if (!$this->_action || !$this->load_class($this->_action, PASSPORT_PATH, true)) {
         exit('error action');
     }
     $action_class = $this->_action;
     $action = new $action_class();
     if (!$this->_command || !method_exists($action, $this->_command)) {
         exit('error command');
     }
     $action->set_action($this->_action);
     $action->set_command($this->_command);
     $action->set_parse_data($this->_parseData);
     call_user_func(array($action, $this->_command));
 }
Exemplo n.º 3
0
if (isset($_POST["act"])) {
    TenYear::getInstance();
    $username = $_POST["username"];
    $password = $_POST["password"];
    $server_id = $_POST["server_id"];
    $adult_flag_user = array('banshu001', 'banshu002', 'banshu003', 'banshu007', 'banshu008', 'banshu009', 'gt1');
    if (in_array($username, $adult_flag_user)) {
        $adult_flag = 0;
    } else {
        $adult_flag = 1;
    }
    $ip = Com_System::get_client_ip();
    $time = date("YmdHis");
    $type = 0;
    #判断开服状态
    $server_state = Com_System::check_server_halt();
    if (!$server_state) {
        echo "你没有权限进入游戏";
        exit;
    }
    if (defined('IS_MERGE_SERVER') && IS_MERGE_SERVER) {
        $strText = "account=" . $username . "&active_type={$active_type}&ad_info=0&adult_flag={$adult_flag}&game_time=0&ip=" . $ip . "&sid=" . $server_id . "&time=" . $time . "&tocken=" . md5('uuzu');
    } else {
        $strText = "account=" . $username . "&active_type={$active_type}&ad_info=0&adult_flag={$adult_flag}&game_time=0&ip=" . $ip . "&time=" . $time . "&tocken=" . md5('uuzu');
    }
    $passport_key = SERVER_KEY;
    #$strAuth = base64_encode($strText);
    #$strVerify = md5($strAuth.$passport_key);
    $strVerify = md5($strText . $passport_key);
    #$rurl = SERVER_DOMAIN."/passport.php?action=login&auth=".urlencode($strAuth)."&verify=".urlencode($strVerify)."&nologin=1";
    $rurl = SERVER_DOMAIN . "/passport.php?action=login&" . $strText . "&verify=" . urlencode($strVerify) . "&nologin=1&tocken=" . md5('uuzu') . "&active_type={$active_type}";
Exemplo n.º 4
0
 public function tencent()
 {
     $server_state = Com_System::check_server_halt();
     if (!$server_state['state']) {
         $result = array('ret' => 1001, 'msg' => $server_state['msg']);
         echo json_encode($result);
         exit;
     }
     $arrData = $this->_parseData;
     //平台登陆测试开关
     $is_login_debug = isset($arrData['nologin']) ? $arrData['nologin'] : false;
     $key_list = array('openid', 'openkey', 'pf', 'pfkey');
     $miss_key_arr = array();
     foreach ($key_list as $key) {
         if (empty($arrData[$key])) {
             $miss_key_arr[] = $key;
         }
         //$_SESSION[$key] 			= $arrData[$key];
         $this->public_tencent_params[$key] = $arrData[$key];
     }
     if (!empty($miss_key_arr) && !$is_login_debug) {
         printf("Login param miss: [%s]\n", implode('|', $miss_key_arr));
         exit;
     }
     /*  合服后处理待定
         if($serverid != Config::check('serverId'))
         {
             //todo 后续合服需要调整(通过hefuServerIds)
             $hefuServerIds = Config::check('hefuServerIds');
             if($hefuServerIds)
             {
                 $hefuServerIds = explode(',',$hefuServerIds);
                 if(!in_array($serverid,$hefuServerIds))
                 {
                     printf("Config errro: [Platform_server_id_%s != Config_server_id_%s]\n", $serverid, Config::check('serverId'));
                     exit;
                 }
             } else {
                 printf("Config errro: [Platform_server_id_%s != Config_server_id_%s]\n", $serverid, Config::check('serverId'));
                 exit;
             }
         }
         */
     $result = $this->get_game('Tencent')->isLogin($this->public_tencent_params);
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l1,$_SESSION,$result,$arrData),true)."\n",FILE_APPEND);
     if (!empty($result) && $result['ret'] == 0 || $is_login_debug) {
         //$this->isSafari();
         //游戏登陆
         /*
         $res = $this->ipLimit();
         if(!$res){
             $this->isClose();
         }
         */
         //$_SESSION['account'] = $arrData['openid'];
         //$_SESSION['id'] = 0;
         //$_SESSION['time'] = 0;
         //$this->run();
         //$code = UserRegister::getInstance()->login();
         //Com_System::url_redirect(SERVER_DOMAIN.'/index.php');
     } else {
         //todo 玩家重新登陆
         printf("Login error! [msg=%s]\n", json_encode($result['msg']));
         exit;
     }
     $rurl = MAIN_DOMAIN_URL;
     $strUserAccount = isset($arrData['openid']) ? trim($arrData['openid']) : "";
     $iAdultFlag = isset($arrData["adult_flag"]) ? $arrData["adult_flag"] : 0;
     $iAdultGameTime = isset($arrData["game_time"]) ? $arrData["game_time"] : 0;
     $strClientIp = isset($arrData["ip"]) ? $arrData["ip"] : "";
     $strAdInfo = isset($arrData["ad_info"]) ? trim($arrData["ad_info"]) : "";
     $strTocken = isset($arrData['tocken']) ? $arrData['tocken'] : "";
     $serverId = isset($arrData['serverid']) ? $arrData['serverid'] : 0;
     $active_type = isset($arrData['active_type']) ? $arrData['active_type'] : 1;
     $platform = isset($arrData['platform']) ? trim($arrData['platform']) : "";
     $openid = isset($arrData['openid']) ? trim($arrData['openid']) : "";
     $openkey = isset($arrData['openkey']) ? trim($arrData['openkey']) : "";
     $pf = isset($arrData['pf']) ? trim($arrData['pf']) : "";
     $pfkey = isset($arrData['pfkey']) ? trim($arrData['pfkey']) : "";
     /*
     if($iAdultFlag == 0 && $iAdultGameTime >= (3*3600))
     {
         $msg = Cache_Language::getInstance()->get_language_info(10306);
     	Com_System::url_msg_redirect($msg['content'],$rurl);
         exit;
     }
     */
     //		$playerid = $this->get_data('Account')->get_pid_byaccount($strUserAccount, true, $serverId);
     //        Com_Log::log("===============[start]==============",'login_test',1);
     //        Com_Log::log("user_account:{$strUserAccount}",'login_test',1);
     $account_info = $this->get_data('Account')->get_account_info($strUserAccount);
     //        Com_Log::log($account_info,'login_test',1);
     //        Com_Log::log($_SESSION,'login_test',1);
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l2,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND);
     if (!$account_info || empty($account_info['name'])) {
         //            $sessAccount = $_SESSION["account"];
         //            if(isset($_SESSION['player_id']) && $_SESSION['player_id']
         //                || $sessAccount && $strUserAccount != $sessAccount){
         //
         //            }
         //            session_regenerate_id();
         $_SESSION = array();
         $_SESSION['sid'] = session_id();
         $_SESSION["account"] = $strUserAccount;
         $_SESSION['client_ip'] = $strClientIp;
         $_SESSION['ad_Info'] = $strAdInfo;
         $_SESSION['server_id'] = $serverId;
         $_SESSION['vip'] = 0;
         $_SESSION['level'] = 0;
         $_SESSION['openid'] = $openid;
         $_SESSION['openkey'] = $openkey;
         $_SESSION['pf'] = $pf;
         $_SESSION['pfkey'] = $pfkey;
         $_SESSION['platform'] = $platform;
         foreach (array('app_custom', 'invkey', 'itime', 'iopenid', 'app_appbitmap') as $key) {
             if (!empty($arrData[$key])) {
                 $_SESSION[$key] = $arrData[$key];
             }
         }
         //todo 临时解决
         if (isset($_SESSION['app_custom'])) {
             $tmp_str = urldecode($_SESSION['app_custom']);
             $_SESSION['app_custom'] = str_replace('|', '.', $tmp_str);
         }
         $ad_info = $strAdInfo > 0 ? 1 : 0;
         if (isset($account_info['player_id']) && $account_info['player_id']) {
             $playerid = $account_info['player_id'];
             // Com_DataCenter::getInstance()->publish_data($playerid,'login',array('ad_info'=>$ad_info,'status'=>'on','keep_time'=>0,'time'=>$this->current_time));
         } else {
             $playerid = $this->get_data('Account')->add_account($strUserAccount, '', $serverId, $strAdInfo);
             ###############################################################################
             #  注册用户,上报数据
             Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid);
             if (!($res = Com_TencentDataUpload::getInstance()->register_data_upload())) {
                 Com_Log::write("uploadDataError", "register_data_upload failed!");
             }
             ###############################################################################
             $log_data = array('player_id' => $playerid, 'channel' => 2, 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'client_ip' => $strClientIp, 'reg_time' => $this->current_time, 'type' => 0, 'add_time' => $this->current_time);
             Log_Common::getInstance()->add_log($log_data);
             //Com_DataCenter::getInstance()->publish_data($playerid,'est',array('ad_info'=>$ad_info,'step'=>'get','time'=>$this->current_time));
         }
         $_SESSION['player_id'] = $playerid;
         $_SESSION['name'] = '';
         #zhe shi hou hai mei ming zi
         $_SESSION['career_type'] = '';
         #zhe shi hou hai mei ming zi
         $_SESSION['active_type'] = $active_type;
         $_SESSION['adult_flag'] = $iAdultFlag;
         $this->get_game('Online')->write_session();
         $arr_cache = array('player_id' => $playerid, 'name' => '', 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'reg_time' => 0, 'career_type' => 0, 'first_load' => 0);
         $this->get_data('Player')->set_rookie_loading_cache($playerid, $arr_cache);
         # --------------------------------------------------------------------
         # 活动日志记录
         # --------------------------------------------------------------------
         /**
         			$event_log_info = array(
         				'log_type'		=> 'login',
         				'player_id'		=> $_SESSION['player_id'],
         				'login_time'	=> $this->current_time,
         				'logout_time'	=> 0,
         			);
         			$this->get_game('Event')->async_deal_event_log($event_log_info);
                     **/
         if ($iAdultFlag == 0) {
             $this->get_game('Adlut')->add_timer($playerid);
             #放沉迷定时器
         }
         $this->redis()->hash_set($this->user_tencent_table . ':' . $playerid, $this->public_tencent_params);
         /*#########################################################################
                     #   玩家登陆成功,判断是否从任务集市进入,并保存传入参数到数据中心服redis
                     #   如果不是从任务集市进入,则只写入最后一次登录的服务器ip和id等数据
                     if(isset($arrData['app_user_source']) && $arrData['app_user_source'] == "marketV3"){
                         $app_user_source = $arrData['app_user_source'];
                         $app_contract_id = $arrData['app_contract_id'];
                         $app_custom = $arrData['app_custom'];
                         $arrTask = array(
                             "player_id"=>$account_info['player_id'],
                             "app_user_source"=>$app_user_source,
                             "app_custom"=>$app_custom,
                             "app_contract_id"=>$app_contract_id,
                             "last_server_id"=>SERVER_ID,
                             "last_server_ip"=>PROCESS_MAIN_IP,
                             "last_server_host"=>SERVER_DOMAIN,
                             "last_login_time"=>time()
                         );
                         if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){
                             Com_Log::write("TencentTaskMarket","TaskMarket data failed!");
                         }
                     }else{
                         $arrTask = array(
                             "player_id"=>$account_info['player_id'],
                             "last_server_id"=>SERVER_ID,
                             "last_server_ip"=>PROCESS_MAIN_IP,
                             "last_server_host"=>SERVER_DOMAIN,
                             "last_login_time"=>time()
                         );
                         if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){
                             Com_Log::write("TencentTaskMarket","TaskMarket data failed!");
                         }
                     }
         
                     ##########################################################################*/
         Com_System::url_redirect(SERVER_DOMAIN . '/index.php');
     } else {
         /*
         if($iAdultFlag == 0){
             $flag = $this->get_data('Online')->get_adlut_ban($account_info['player_id']);
             if(!$flag){
                 $this->get_game('Adlut')->add_timer($account_info['player_id']); #放沉迷定时器
             }
             
             if($flag){
                 $msg = Cache_Language::getInstance()->get_language_info(10306);
                 Com_System::url_msg_redirect($msg['content'],$rurl);
                 exit;
             }
         }
         */
         $this->get_game('DailySign')->async_trigger_login_times($account_info['player_id']);
         $objPlayerData = $this->get_data('Player');
         if ($account_info['player_id'] == $_SESSION['player_id']) {
             //                Com_Log::log("account:{$account_info['player_id']} session:{$_SESSION['player_id']} sid:{$_SESSION['']}",'login_test',1);
             $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag);
             //上一次离线时长计算
             $logout_time = $objPlayerData->get_player_info($account_info['player_id'], 'logout_time');
             $last_offline_time = $this->current_time - $logout_time;
             $up_arr['last_offline_time'] = $last_offline_time;
             if ($last_offline_time >= 28800) {
                 //8小时以上给奖励
                 $up_arr['offline_reward_status'] = 1;
             } else {
                 $up_arr['offline_reward_status'] = 0;
             }
             //已经登录
             $objPlayerData->update_player_info($account_info['player_id'], $up_arr);
             $_SESSION['openkey'] = $openkey;
             $_SESSION['pf'] = $pf;
             $_SESSION['pfkey'] = $pfkey;
             $_SESSION['platform'] = $platform;
             $_SESSION['openid'] = $openid;
             //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l3,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND);
             $objOnline = $this->get_game('Online');
             $objOnline->write_session();
             $this->redis()->hash_set($this->user_tencent_table . ':' . $account_info['player_id'], $this->public_tencent_params);
             Com_System::url_redirect(SERVER_DOMAIN . '/index.php');
             exit;
         }
         $arrUser = $objPlayerData->get_player_info($account_info['player_id']);
         ###############################################################################
         #   登录成功,上报数据
         $playerid = $account_info['player_id'];
         Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid);
         $level = $arrUser['level'];
         if (!($res = Com_TencentDataUpload::getInstance()->login_data_upload($level))) {
             Com_Log::write("uploadDataError", "login_data_upload failed!" . var_export($res) . "sss");
         }
         ###############################################################################
         if ($arrUser['is_ban'] == 3) {
             #封号了
             Com_System::url_msg_redirect("亲爱的魔法师,由于您的账号数据存在异常,魔法管理员已暂时将您的账号封停,如有疑问可联系客服咨询。", $rurl);
             exit;
         }
         if (empty($arrData['nologin']) && $arrUser['ban_time'] > $this->current_time) {
             Com_System::url_redirect(SERVER_DOMAIN . '/index.php' . "?ecode=-15");
         }
         $oldPlayerId = isset($_SESSION['player_id']) ? $_SESSION['player_id'] : 0;
         if ($oldPlayerId) {
             //如果有老的playerid 则生成新的session_id
             //                session_regenerate_id();
         }
         $_SESSION = array();
         $_SESSION['sid'] = session_id();
         $_SESSION["player_id"] = $arrUser["player_id"];
         $_SESSION['active_type'] = 0;
         $_SESSION['name'] = $arrUser["name"];
         $_SESSION["account"] = $strUserAccount;
         $_SESSION['career_type'] = $arrUser['career_type'];
         $_SESSION['adult_flag'] = $iAdultFlag;
         $_SESSION['ad_Info'] = $arrUser['ad_Info'];
         $_SESSION['client_ip'] = $strClientIp;
         $_SESSION['server_id'] = $serverId;
         $_SESSION['vip'] = $arrUser['vip'];
         $_SESSION['level'] = $arrUser['level'];
         $_SESSION['openid'] = $openid;
         $_SESSION['openkey'] = $openkey;
         $_SESSION['pf'] = $pf;
         $_SESSION['pfkey'] = $pfkey;
         $_SESSION['platform'] = $platform;
         $objOnline = $this->get_game('Online');
         $objOnline->write_session();
         //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l4,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND);
         $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag);
         //上一次离线时长计算
         $last_offline_time = $this->current_time - $arrUser['logout_time'];
         $up_arr['last_offline_time'] = $last_offline_time;
         if ($last_offline_time >= 28800) {
             //8小时以上给奖励
             $up_arr['offline_reward_status'] = 1;
         } else {
             $up_arr['offline_reward_status'] = 0;
         }
         $objPlayerData->update_player_info($arrUser["player_id"], $up_arr);
         //更新下session
         $log_data = array('player_id' => $arrUser["player_id"], 'channel' => 1, 'client_ip' => $strClientIp, 'game_client_ip' => Com_System::get_client_ip(), 'reg_time' => $arrUser['reg_time'], 'ad_info' => $arrUser['ad_Info'], 'player_level' => $arrUser['level'], 'vip_level' => $arrUser['vip'], 'vip_special_level' => $arrUser['privilege_level']);
         #Log_Login::getInstance()->add_log($log_data);
         Log_Common::getInstance()->add_log($log_data, 'day');
         $arr_cache = array('player_id' => $arrUser["player_id"], 'name' => $arrUser["name"], 'user_account' => $strUserAccount, 'ad_info' => $arrUser['ad_Info'], 'reg_time' => $arrUser['reg_time'], 'career_type' => $arrUser['career_type'], 'first_load' => $arrUser['first_load']);
         $this->get_data('Player')->set_rookie_loading_cache($arrUser["player_id"], $arr_cache);
         $ad_info = $strAdInfo > 0 ? 1 : 0;
         //Com_DataCenter::getInstance()->publish_data($arrUser["player_id"],'login',array('ad_info'=>$ad_info,'status'=>'on','keep_time'=>0,'time'=>$this->current_time));
         if ($ad_info == 1) {
             #广告系统用户推送每天首次登陆
             if (date('Ymd', $arrUser["reg_time"]) != date('Ymd') && date('Ymd') != date('Ymd', $arrUser["login_time"])) {
                 $activelog = Com_System::send_request(array('user_account' => $arrUser['user_account']), 'login');
             }
         }
         #记录登陆登出信息
         $this->get_data('Online')->set_online_list($arrUser["player_id"], array('login_time' => $this->current_time, 'logout_time' => $arrUser['logout_time']));
         //            Com_Log::log("arrUser:{$arrUser["player_id"]} session:{$_SESSION['player_id']} sid:{$_SESSION['sid']}",'login_test',1);
         /*#########################################################################
                     #   玩家登陆成功,判断是否从任务集市进入,并保存传入参数到数据中心服redis
                     if(isset($arrData['app_user_source']) && $arrData['app_user_source'] == "marketV3"){
                         $app_user_source = $arrData['app_user_source'];
                         $app_contract_id = $arrData['app_contract_id'];
                         $app_custom = $arrData['app_custom'];
                         $arrTask = array(
                             "player_id"=>$account_info['player_id'],
                             "app_user_source"=>$app_user_source,
                             "app_custom"=>$app_custom,
                             "app_contract_id"=>$app_contract_id,
                             "last_server_id"=>SERVER_ID,
                             "last_server_ip"=>PROCESS_MAIN_IP,
                             "last_server_host"=>SERVER_DOMAIN,
                             "last_login_time"=>time()
                         );
                         if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){
                             Com_Log::write("TencentTaskMarket","TaskMarket data failed!");
                         }
                     }else{
                         $arrTask = array(
                             "player_id"=>$account_info['player_id'],
                             "last_server_id"=>SERVER_ID,
                             "last_server_ip"=>PROCESS_MAIN_IP,
                             "last_server_host"=>SERVER_DOMAIN,
                             "last_login_time"=>time()
                         );
                         if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){
                             Com_Log::write("TencentTaskMarket","TaskMarket data failed!");
                         }
                     }
         
                     ##########################################################################*/
         # --------------------------------------------------------------------
         # 活动日志记录
         # --------------------------------------------------------------------
         /**
         			$event_log_info = array(
         				'log_type'		=> 'login',
         				'player_id'		=> $_SESSION['player_id'],
         				'login_time'	=> $this->current_time,
         				'logout_time'	=> 0,
         			);
         			$this->get_game('Event')->async_deal_event_log($event_log_info);
                     **/
         $this->redis()->hash_set($this->user_tencent_table . ':' . $arrUser["player_id"], $this->public_tencent_params);
         Com_System::url_redirect(SERVER_DOMAIN . '/index.php');
     }
 }