public function test() { $data = array("appid" => '24885', "billno" => '4BE1D6AE-5324-11E3-BC76-00163EB7F40B', "cmd" => 'check_award', "contractid" => '24885T320131118114134', "openid" => '000000000000000000000000025900A0', "payitem" => 'pkg', "pf" => 'qzone', "providetype" => '2', "step" => 2, "ts" => '1385089780', "version" => 'V3', "sig" => 'E+S6dC+hooDCtwvhnGTFIFGrfng='); $url = "http://192.168.1.73:9001/tencentTaskMarketApi.php"; $res = Com_TencentDataUpload::send_data($data, $url, "GET"); echo $res; // var_dump(urldecode('E%2BS6dC%2BhooDCtwvhnGTFIFGrfng%3D')); }
/** * 发送聊天信息到37wan接口 * @param $params * @return int errno -3(接口超时),-2(签名验证错误),-1(参数错误),1(推送成功) */ public function report_msg($params) { $params = json_decode($params, true); $player_id = $params[3]; $player_info = $this->get_player_info($player_id); if ($params[0] != 0) { $dpf_player_info = $this->get_player_info($params[0]); } else { // $params[0] 为0的时候,是在世界或者公会聊天 $dpf_player_info['name'] = 'world'; } $post_data = array('game_key' => $this->game_key, 'server_id' => SERVER_ID, 'time' => $params[1], 'login_account' => $player_info['user_account'], 'actor' => $player_info['name'], 'to_login_account' => $params[0], 'to_actor' => $dpf_player_info['name'], 'content' => urlencode($params[2]), 'ip' => $player_info['client_ip']); $sign = $this->make_sign($post_data); $post_data['sign'] = $sign; $result = Com_TencentDataUpload::getInstance()->send_data($post_data, $this->api_url); echo '-------Upload data to 37wan-----status code-----' . $result; if ($result != 1) { //推送不成功,日志打印错误信息 Com_Log::write('uploadDataError', 'Upload data to 37wan failed! Errorcode' . $result); } }
protected function http_request($server_host, $params) { $url = $server_host . '/api.php'; $result = Com_TencentDataUpload::getInstance()->send_data($params, $url, 'post'); return json_decode($result, true); }
/** * 添加多种资源 资源是指 黄金 钻石 等这些资源 * @param $player_id 用户id * @param $level 用户等级 * @param $vip_level vip等级 * @param $cmd_id cmd2 指令 * @param $data array('type',item_id,item_num,amount) 具体含义 参照 add_resource_log 里的 $item * @param $arr_consume array('price',gold,ticket,count) or array() 同 Data/Player.php update_player_resource 里的 $arr_consume * @return bool */ public function add_multi_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data, $arr_consume = array()) { $arr_async = array(); if (Com_Array::is_arr2($data)) { foreach ($data as $param) { if ($param['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $param['type'], $param['item_id'], $param['item_num'], $param['amount'], $param['front_attr'], $param['after_attr']); } $key = Cache_Currency::getInstance()->get_key($param['item_id']); if (isset($param['is_async']) && $param['is_async'] == 0) { #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($param['type'] == 1) { $arr_async[$key] = $param['amount'] + $param['item_num']; } elseif ($param['type'] == 2) { $arr_async[$key] = $param['amount'] - $param['item_num']; ############################################################################### # 道具消费,上报数据 if (OPERATOR_ID == 82) { $playerData = TenYear::getInstance("Data_player")->get_player_info($player_id, array("session_id")); $arrUpload = TenYear::getInstance("Game_online")->get_session($playerData['session_id']); $platform = $arrUpload['platform']; $serverId = $arrUpload['server_id']; $openid = $arrUpload['openid']; Com_TencentDataUpload::getInstance()->init($platform, $serverId, $player_id, $openid); $arr_consume_upload = array("level" => $level, "itemid" => $data['item_id'], "itemtype" => $data['type'], "itemcnt" => $data['item_num']); if (!($res = Com_TencentDataUpload::getInstance()->consume_data_upload($arr_consume_upload))) { Com_Log::write("uploadDataError", "consume_data_upload failed!"); } } ############################################################################### } } } } else { if ($data['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data['type'], $data['item_id'], $data['item_num'], $data['amount'], $data['front_attr'], $data['after_attr']); } $key = Cache_Currency::getInstance()->get_key($data['item_id']); if (isset($data['is_async']) && $data['is_async'] == 0) { #检查否同步前端 #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($data['type'] == 1) { $arr_async[$key] = $data['amount'] + $data['item_num']; } elseif ($data['type'] == 2) { $arr_async[$key] = $data['amount'] - $data['item_num']; } } } if ($arr_consume) { $params['act'] = $cmd_id; $params['level'] = $level; $params['price'] = $arr_consume['price']; $params['gold'] = $arr_consume['gold']; $params['black_gold'] = $arr_consume['ticket']; $params['count'] = $arr_consume['count']; $params['time'] = time(); Com_DataCenter::getInstance()->publish_data($player_id, 'prop', $params); } # 先注释了 if ($arr_async) { Protocol_Player::p2c_part_update($player_id, $arr_async); #同步资 } return true; }
public function payback() { $result = $this->objTencent->verityToken($this->auth, $this->script_name); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay2',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); if ($result['ret'] != 0) { return $result; } $senddata = explode('*', $this->auth['payitem']); $goodsid = $senddata[0]; $price = (int) $senddata[1]; $num = (int) $senddata[2]; /** 所有道具 */ $payGoods = $this->objTencent->payGoods(); if (empty($payGoods[$goodsid])) { return array('ret' => 1, 'msg' => '道具不存在' . $goodsid); } /** @var is_double 是否双倍 */ //$this->is_double = (int) $payGoods[$goodsid]['double']; /** @var $is_cash 是否钻石充值 */ $this->is_cash = (int) $payGoods[$goodsid]['is_cash']; $cash = $price * $num; $this->cash = $cash; // 档次 $this->price = $price; // Token缓存 $tokenKey = $this->objTencent->tokenTable . ':pay:' . $this->player_id; $tokenField = $goodsid; $buy_info_json = $this->redis()->hash_get($tokenKey, $tokenField); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay3',$this->player_id,$this->auth,json_decode($buy_info_json,'array')),true)."\n",FILE_APPEND); $this->redis()->hash_delete($tokenKey, $tokenField); if ($buy_info_json) { $buy_info = json_decode($buy_info_json, 'array'); if ($buy_info['token'] != $this->auth['token']) { return array('ret' => 3, 'msg' => 'token不存在'); } $timeout = $this->objTencent->tokenTypes['pay']['timeout']; if (time() > $timeout + $buy_info['create_time']) { return array('ret' => 2, 'msg' => 'token已过期'); } //charge log $insertData = array('uid' => $this->player_id, 'passport' => $this->auth['openid'], 'tokentype' => 'pay', 'token' => $this->auth['token'], 'create_time' => $buy_info['create_time'], 'content' => $buy_info['url_params'], 'senddata' => $this->auth['payitem'], 'verity_time' => time()); $objPlayerCharge = $this->get_data('PlayerCharge'); $arrCharge = $objPlayerCharge->get_charge_info($this->auth['billno']); if (!empty($arrCharge)) { return array('ret' => 2, 'msg' => '订单号已经存在'); } $arrPlayer = $this->get_data('Player')->get_player_info($this->player_id, array('gold', 'level', 'vip', 'privilege_level', 'qq_blue_points')); $b_gold = $arrPlayer['gold']; #改变之前的钻石 if ($tokenField == 18) { #$this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'qq_blue_points', $cash); } else { $this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'gold', $cash); } $iGold = $cash * 10; $this->start_trans(); $result = $this->get_data('Player')->update_player_resource($this->player_id, $arrPlayer, 111, array('is_pay' => 1)); if ($result) { $after = $arrPlayer['gold']; $result = $objPlayerCharge->add_charge($this->player_id, $this->auth['billno'], $this->auth['openid'], $arrPlayer['level'], $cash, $cash, $b_gold, $after); } if ($result) { $this->commit(); Log_Charge::getInstance()->add_charge_log($this->player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $this->auth['billno'], $cash, $cash, $arrPlayer['gold'], $b_gold); $data['status'] = 0; if ($tokenField != 18) { # 充值回馈活动,蛋疼的次数埋点 $this->get_game('PlayerFunc')->sync_func_tips($this->player_id, 1260); #vip升级 $this->get_game('VipReward')->vip_upgrade($this->player_id, $cash); #新服活动 $pub_day = $this->get_data('NewServerActivity')->get_server_day(); if ($pub_day <= 7) { $this->get_game('NewServerActivity')->add_sign($this->player_id, $pub_day, $cash); } } } else { $this->rollback(); return array('ret' => 1, 'msg' => '充值失败'); } } else { return array('ret' => 1, 'msg' => '充值失败'); } ############################################################################### # 充值成功,上报数据,上报字段信息: # modifyfee是充值金额,上报单位为Q分,1Q币=100Q分 # modifycoin对应为玩家充值变化的钻石数 # totalcoin对应充值完成之后,玩家总钻石数 # level为玩家等级 $arrData = $this->auth; $platform = $arrData['platform']; $serverId = $arrData['serverid']; $openid = $arrData['openid']; $playerid = $this->player_id; $level = $arrPlayer['level']; $modifycoin = $after - $b_gold; $chargeData = array('modifyfee' => $cash * 10, 'modifycoin' => $modifycoin, 'totalcoin' => $after, 'level' => $level); Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid); if (!($res = Com_TencentDataUpload::getInstance()->recharge_data_upload($chargeData))) { Com_Log::write("uploadDataError", "recharge_data_upload failed!"); } ############################################################################### //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay4',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); return array('ret' => 0, 'msg' => 'OK'); }
/** * 离线通知 * @param $player_id * @return bool * @status 0 普通 1被踢 */ public function offline($player_id, $status = 0) { // Com_Log::write("offline.".$player_id,"time:".time()); /*$session_id = $this->get_data('Player')->get_player_info($player_id,'session_id'); $objSession = TenYear::getInstance('session'); $objSession->destory($session_id);*/ // $this->get_data('Online')->del_online_list($player_id);# #获取玩家信息 $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'map_id', 'user_account', 'session_id', 'login_time', 'privilege_level', 'heart_time')); $time = time(); if ($status == 1) { $this->get_data('Player')->update_player_info($player_id, array('logout_time' => $time)); } else { $this->online_time($player_id, $player_info); $this->get_data('Player')->update_player_info($player_id, array('is_online' => 0, 'logout_time' => $time)); $this->get_data("Player")->del_player_online_list($player_id); } #记录登陆登出信息 $this->get_data('Online')->set_online_list($player_id, array('login_time' => $player_info['login_time'], 'logout_time' => $time)); #向平台发送离线通知 $arrData = array(); $arrData['data'] = $player_info['user_account'] . ":" . $time; $arrData['game_id'] = GAME_ID; $arrData['server_id'] = SERVER_ID; $arrData['tid'] = OPERATOR_ID; $arrData['time'] = $time; $arrData['type'] = 'n'; $str = "data=" . $arrData['data'] . "&game_id=" . $arrData['game_id'] . "&server_id=" . $arrData['server_id'] . "&tid=" . $arrData['tid'] . "&time=" . $arrData['time'] . "&type=" . $arrData['type']; # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- /** $event_log_info = array( 'log_type' => 'login', 'player_id' => $player_id, 'login_time' => $player_info['login_time'], 'logout_time' => $time, ); $this->get_game('Event')->async_deal_event_log($event_log_info); **/ $arrData['verify'] = md5($str . SERVER_KEY); $url = "http://api.uuzu.com/game/fcm/offline"; // $result = Com_System::open_url($url, 'post', $arrData, 1); if (!empty($result) && is_string($result)) { $result = json_decode($result, true); } #如果没有发送成功多发几次 /* if($result['status'] > 0){ $i = 0; while($result['status'] > 0){ if($i > 5) { break; } $result = Com_System::open_url($url, 'post', $arrData, 5); if (!empty($result) && is_string($result)) $result = json_decode($result, true); $i++; } } */ #下线日志 $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id, array('main_val')); if (!empty($arr_player_task['main_val'])) { $res = reset($arr_player_task['main_val']); $task_id = $res['task_id']; } else { $task_id = 0; } Log_Logout::getInstance()->add_logout_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], $player_info['login_time'], $time, $task_id, $player_info['map_id']); ############################################################################### # 退出游戏,上报数据 if (OPERATOR_ID == 82) { $arrUpload = $this->get_session($player_info['session_id']); $platform = $arrUpload['platform']; $serverId = $arrUpload['server_id']; $openid = $arrUpload['openid']; Com_TencentDataUpload::getInstance()->init($platform, $serverId, $player_id, $openid); $onlinetime = $time - $player_info['login_time']; if (!($res = Com_TencentDataUpload::getInstance()->quit_data_upload($onlinetime, $player_info['level']))) { Com_Log::write("uploadDataError", "quit_data_upload failed!" . $res); } } ############################################################################### return; }
<?php /** * 腾讯罗盘数据上报异步进行 * Created by PhpStorm. * User: pengdc * Date: 2015/8/5 * Time: 17:51 */ require dirname(__FILE__) . '/../global.php'; TenYear::getInstance(); //只在腾讯服务器上执行此脚本,其他服务器,周期性休眠 if (OPERATOR_ID != 82) { while (true) { sleep(86400); } } ini_set("default_socket_timeout", -1); Com_AdCache::factory()->set_timeout(0); Com_TencentDataUpload::getInstance()->receive_data(); echo "register chat receive \r\n"; echo "start receive \r\n"; //开始接收 Com_Queued::receive_all();
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'); } }