Exemplo n.º 1
0
 /**
  * 初始化参数结构,调用数据上报接口之前,必须初始化
  * @param $platform
  * @param $worldid
  * @param $opuid
  * @param $opopenid
  * TODO: 正式上线之后需要修改$svrip,现在是测试环境的固定ip
  */
 public function init($platform, $worldid, $opuid, $opopenid)
 {
     //$userip = $_SERVER['HTTP_VIA']?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
     $domain = $this->get_domain($platform);
     $userip = Com_System::get_client_ip();
     $svrip = Com_System::get_host_ip();
     $this->arr_upload_info['userip'] = ip2long($userip);
     $this->arr_upload_info['svrip'] = ip2long('10.251.192.175');
     $this->arr_upload_info['time'] = time();
     $this->arr_upload_info['domain'] = intval($domain);
     $this->arr_upload_info['worldid'] = intval($worldid);
     $this->arr_upload_info['opuid'] = intval($opuid);
     $this->arr_upload_info['opopenid'] = $opopenid;
 }
Exemplo n.º 2
0
 /**
  * 异步推送协议
  * @param $player_id
  * @param $raw_data 已经封装好的协议
  * @return unknown
  */
 public function rsync_protocol($player_id, $raw_data, $client_ip = null)
 {
     if (empty($client_ip)) {
         if (isset($_GET['debug']) && $_GET['debug'] == 1) {
             $client_ip = GATEWAY_IP;
         } else {
             $client_ip = Com_System::get_client_ip();
             //            || $client_ip == '127.0.0.1'
             if (empty($client_ip)) {
                 $client_ip = GATEWAY_IP;
             }
         }
     }
     $channel_seq = Com_System::get_queue_channel_seq($player_id, 6);
     return Com_Queued::send($this->_channel . "_" . $channel_seq, json_encode(array('player_id' => $player_id, 'client_ip' => $client_ip, 'data' => base64_encode($raw_data))));
 }
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $username = $userInfo_array['user_account'];
     $server_id = $userInfo_array['server_id'];
     $player_id = $userInfo_array['player_id'];
     $ip = Com_System::get_client_ip();
     $time = date("YmdHis");
     $type = 0;
     if (defined('IS_MERGE_SERVER') && IS_MERGE_SERVER) {
         $strText = "account=" . $username . "&ad_info=sdf&adult_flag=1&game_time=0&ip=" . $ip . "&sid=" . $server_id . "&time=" . $time . "&tocken=" . md5('uuzu');
     } else {
         $strText = "account=" . $username . "&ad_info=sdf&adult_flag=1&game_time=0&ip=" . $ip . "&time=" . $time . "&tocken=" . md5('uuzu');
     }
     $passport_key = SERVER_KEY;
     $strVerify = md5($strText . $passport_key);
     $rurl = SERVER_DOMAIN . "/passport.php?action=login&" . $strText . "&verify=" . urlencode($strVerify) . "&nologin=1";
     $data['status'] = 1;
     $data['data'] = $rurl;
     echo json_encode($data);
 }
Exemplo n.º 4
0
 /**
  * [check_auth 检测是否有导表权限,返回导表人的IP]
  * @return [type] [description]
  */
 public function check_auth()
 {
     //黑暗IP 列表
     $unlock_ips = array('192.168.119.152', '192.168.119.216', '192.168.122.255', '192.168.125.134');
     if (isset($_ENV["HOSTNAME"])) {
         $MachineName = $_ENV["HOSTNAME"];
     } elseif (isset($_ENV["COMPUTERNAME"])) {
         $MachineName = $_ENV["COMPUTERNAME"];
     } else {
         $MachineName = "";
     }
     //获取导表使用者的IP地址
     $ip = gethostbyname($MachineName);
     if (empty($ip)) {
         $ip = Com_System::get_client_ip();
     }
     if (in_array($ip, $unlock_ips)) {
         $message = "您是海外的策划:{$ip},不能把表导入到国内,只能导出!";
         exit("<script type=\"text/javascript\">alert(\"{$message}\");history.go(-1);</script>");
     }
     return $ip;
 }
Exemplo n.º 5
0
         exit("result=0&msg=" . $arrLanguage["10217"]['content']);
     } else {
         Com_System::url_redirect($webUrl . "/active.php?e_code=-20");
     }
 }
 $playerid = $objAccount->set_account_name($player_id, $strUserAccount, $name);
 if (!$playerid) {
     //激活用户失败
     if ($bAjax) {
         exit("result=0&msg=" . $arrLanguage["10218"]['content']);
     } else {
         Com_System::url_redirect($strTenYearUrl);
     }
 }
 $objPlayerInitGame = TenYear::getInstance('Game_PlayerInit');
 $client_ip = Com_System::get_client_ip();
 $arrData = array();
 $arrData['player_id'] = $player_id;
 $arrData['user_account'] = $strUserAccount;
 $arrData['name'] = $name;
 $arrData['career_type'] = $arrCharacter['career_type'];
 $arrData['avatar'] = $arrCharacter['avatar'];
 $arrData['sex'] = $arrCharacter['sex'];
 $arrData['ad_info'] = $strAdInfo;
 $arrData['client_ip'] = $client_ip;
 $arrData['session_id'] = $session_id;
 $arrData['adult_flag'] = $adult_flag;
 $arrData['exec'] = 1;
 $affectedRows = $objPlayerInitGame->active($arrData);
 if ($affectedRows > 0) {
     $_SESSION = array();
Exemplo n.º 6
0
 /**
  * C++重启 重置序章用户任务
  */
 public function CMD2_528()
 {
     $this->get_data("Player")->del_all_player_online_list();
     $gateway = Com_System::get_client_ip();
     if ($gateway == '127.0.0.1') {
         $this->get_game('TaskMain')->reset_task();
     }
 }
Exemplo n.º 7
0
 public function set_inter_day_login()
 {
     $player_list = $this->get_data('Online')->get_online_list();
     foreach ($player_list as $player_id => $v) {
         if (empty($player_id)) {
             continue;
         }
         if (1 == $v) {
             continue;
         }
         $arr_time = json_decode($v, true);
         if ($arr_time['login_time'] >= $arr_time['logout_time']) {
             $arrUser = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'reg_time', 'ad_Info', 'level', 'vip', 'privilege_level'));
             $log_data = array('player_id' => $arrUser["player_id"], 'channel' => 1, 'client_ip' => Com_System::get_client_ip(), '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_Common::getInstance()->add_log($log_data, 'day');
         }
     }
 }
Exemplo n.º 8
0
 /**
  * 多玩平台推送数据
  * @param unknown_type $account
  * @param unknown_type $type
  * @return Ambigous <mixed, Ambigous>
  */
 public static function send_message($account, $op, $nowTime = 0)
 {
     if (empty($nowTime)) {
         $nowTime = time();
     }
     $ip = Com_System::get_client_ip();
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('sendMessage',$account,$op,$nowTime,$ip),true)."\n",FILE_APPEND);
     Com_Feed::getInstance()->publish_data('sendMessage', $account, $op, $nowTime * 1000, $ip);
 }
Exemplo n.º 9
0
 public function getPayToken($player_id, $goodsid)
 {
     $session_info = $this->get_param($player_id);
     $_SESSION = $session_info;
     $argsObj = array();
     $openid = $session_info['openid'];
     $pfkey = $session_info['pfkey'];
     $ts = time();
     $payitem = '';
     $goodsmeta = '';
     $goodsurl = '';
     $zoneid = '';
     $num = 1;
     $id = $goodsid;
     $tokentype = 'pay';
     $tokentype = $tokentype == 'pay' ? 'pay' : 'tencent';
     // 道具
     //$payGoods = $this->payGoods();
     if (!in_array($id, array_keys($this->goodsInfo)) || $num <= 0) {
         $this->throw_error('');
         # 参数非法
     }
     // Token缓存
     $tokenKey = $this->tokenTable . ':' . $tokentype . ':' . $player_id;
     // $tokenField = $id.':'.$num;
     $tokenField = $id;
     $tokenInfo_json = $this->redis()->hash_get($tokenKey, $tokenField);
     if ($tokenInfo_json) {
         // 是否过期
         $tokenInfo = json_decode($tokenInfo_json, 'array');
         $timeout = $tokenInfo['create_time'] + $this->tokenTypes[$tokentype]['timeout'];
         if ($timeout > time()) {
             //return array('url_params'=>$tokenInfo['url_params'],'sandbox'=>$this->sandbox,);	//正式
             return array('url_params' => $tokenInfo['url_params'], 'sandbox' => true);
             //沙箱测试
         }
     }
     $create_time = time();
     $params = array();
     $payGoods = $this->goodsInfo;
     $params['ts'] = $create_time;
     $params['payitem'] = $payGoods[$id]['goodsid'] . '*' . $payGoods[$id]['price'] . '*' . $num;
     $params['goodsmeta'] = $payGoods[$id]['meta'];
     $params['goodsurl'] = SERVER_DOMAIN . '/' . $payGoods[$id]['url'];
     // $params['zoneid']		= $user->server_id;//合服后server_id不变
     $params['zoneid'] = $session_info['server_id'];
     if ($params['zoneid'] != $session_info['server_id']) {
         $params['cee_extend'] = $session_info['server_id'];
     }
     if (isset($payGoods[$id]['appmode'])) {
         $params['appmode'] = $payGoods[$id]['appmode'];
     }
     if (!is_numeric($params['zoneid'])) {
         $this->throw_error('');
         # 参数非法
     }
     $res = $this->api($this->tokenApi['pay'], $params, 'post', 'https');
     //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('p1',$res,$session_info,$params),true)."\n",FILE_APPEND);
     if ($res['ret'] != 0) {
         return $res;
     }
     if (true) {
         // 入缓存
         $data = array('gxid' => $id, 'type' => $tokentype, 'num' => $num, 'url_params' => $res['url_params'], 'create_time' => $create_time, 'token' => $res['token'], 'pf' => $session_info['pf'], 'userip' => Com_System::get_client_ip());
         $this->redis()->hash_set($tokenKey, $tokenField, json_encode($data));
         $this->redis()->commit();
         return array('url_params' => $res['url_params'], 'sandbox' => true);
     } else {
         $this->throw_error('');
         # 参数非法
     }
 }
Exemplo n.º 10
0
 public function run()
 {
     $rurl = MAIN_DOMAIN_URL;
     $arrData = $this->_parseData;
     $strUserAccount = isset($arrData["account"]) ? trim($arrData["account"]) : "";
     $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['sid']) ? $arrData['sid'] : 0;
     $active_type = isset($arrData['active_type']) ? $arrData['active_type'] : 1;
     if ($iAdultFlag == 0 && $iAdultGameTime >= 3 * 3600) {
         $msg = Cache_Language::getInstance()->get_language_info(10306);
         Com_System::url_msg_redirect($msg['content'], $rurl);
         exit;
     }
     $account_info = $this->get_data('Account')->get_account_info($strUserAccount);
     if (!$account_info || empty($account_info['name'])) {
         $_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;
         $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);
             $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);
             #放沉迷定时器
         }
         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;
             }
         }
         $client_ip = Com_System::get_client_ip();
         $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, 'client_ip' => $client_ip);
             //上一次离线时长计算
             $pinfo = $objPlayerData->get_player_info($account_info['player_id'], array('logout_time', 'heart_time', 'offline_reward_time'));
             $logout_time = max($pinfo['logout_time'], $pinfo['heart_time'], $pinfo['offline_reward_time']);
             $last_offline_time = $this->current_time - $logout_time;
             $up_arr['last_offline_time'] = $last_offline_time;
             $up_arr['offline_reward_time'] = $this->current_time;
             if ($last_offline_time >= 3600) {
                 //1小时以上给奖励
                 $up_arr['offline_reward_status'] = 1;
             } else {
                 $up_arr['offline_reward_status'] = 0;
             }
             //已经登录
             $objPlayerData->update_player_info($account_info['player_id'], $up_arr);
             Com_System::url_redirect(SERVER_DOMAIN . '/index.php');
             exit;
         }
         $arrUser = $objPlayerData->get_player_info($account_info['player_id']);
         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'];
         $objOnline = $this->get_game('Online');
         $objOnline->write_session();
         $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag, 'client_ip' => $client_ip);
         //上一次离线时长计算
         $logout_time = max($arrUser['logout_time'], $arrUser['heart_time'], $arrUser['offline_reward_time']);
         $last_offline_time = $this->current_time - $logout_time;
         $up_arr['last_offline_time'] = $last_offline_time;
         $up_arr['offline_reward_time'] = $this->current_time;
         if ($last_offline_time >= 3600) {
             //1个小时以上给奖励
             $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' => $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);
         # --------------------------------------------------------------------
         # 活动日志记录
         # --------------------------------------------------------------------
         /**
         			$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);
                     **/
         Com_System::url_redirect(SERVER_DOMAIN . '/index.php');
     }
 }
Exemplo n.º 11
0
 /**
  * @param $player_id
  * @param $player_info array('exp','level','level_exp','after_hero_hole')  使用升级的时候传下这几个数据
  * @return unknown
  */
 public function publish_upgrade($player_id, $player_info)
 {
     $data['player_id'] = $player_id;
     $data['exp'] = $player_info['exp'];
     $data['level'] = $player_info['level'];
     $data['level_exp'] = $player_info['level_exp'];
     $data['career_type'] = $player_info['career_type'];
     $data['after_hero_hole'] = $player_info['after_hero_hole'];
     $data['privilege_level'] = $player_info['privilege_level'];
     $data['name'] = $player_info['name'];
     $data['vip'] = $player_info['vip'];
     $data['union_id'] = $player_info['union_id'];
     //		Com_Log::write('xgame.upgrade', "publish_upgrade:\t".json_encode($data));
     $gateway = Com_System::get_client_ip();
     if (empty($gateway)) {
         $data['gateway'] = GATEWAY_IP;
     } else {
         $data['gateway'] = $gateway;
     }
     # 获取异步处理队列需要用的频道分割序号
     $channel_seq = Com_System::get_queue_channel_seq($player_id, 11);
     return Com_Queued::send($this->upgradeChannel . "_" . $channel_seq, json_encode($data));
 }
Exemplo n.º 12
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');
     }
 }
Exemplo n.º 13
0
 public function flush_cache()
 {
     Com_Cache::factory('setting')->flush();
     //		Com_Cache::factory("game")->flush();
     //		Com_Queued::send("process", "restart");
     $data[0] = intval(1);
     Protocol::make_data($data);
     $raw_data = Protocol::output(7, 4, 402, 2);
     $server_ip = Com_System::get_client_ip();
     $url = "http://{$server_ip}/nginx2cppsvr.do";
     //        $url = SERVER_DOMAIN.'/nginx2cppsvr.do';
     $header = "Content-type: application/octet-stream";
     $ch = curl_init();
     //初始化curl
     curl_setopt($ch, CURLOPT_URL, $url);
     //设置链接
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //设置是否返回信息
     curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
     //设置HTTP头
     curl_setopt($ch, CURLOPT_POST, 1);
     //设置为POST方式
     curl_setopt($ch, CURLOPT_POSTFIELDS, $raw_data);
     //POST数据
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
     curl_exec($ch);
     curl_close($ch);
 }