public function run() { $sessions = $this->redis()->keys("sess:sid:*"); $online_num = count($sessions); #临时 $cc = shell_exec("netstat -natp |grep :19707 |grep -c ESTABLISHED"); $cc = trim($cc); $online_num = (int) $cc; # $ip = array(); if ($sessions) { foreach ($sessions as $val) { $data = $this->redis()->hash_get($val); $ip[$data['client_ip']] = 1; } } #上报在线人数 $arrData = array(); $arrData['gameid'] = GAME_ID; $arrData['type'] = 'online'; $arrData['appid'] = 3248; $arrData['appkey'] = 'd2f83a02a38e0a7c027b8bc7dccf4628'; $arrData['timeline'] = time(); $arrData['value'][] = array('opid' => OPERATOR_ID, 'server' => SERVER_ID ? SERVER_ID : 0, 'area' => AREA_ID ? AREA_ID : 0, 'value' => $online_num); $url = "http://monitor.uuzuonline.com/onlineReport"; Com_System::open_url($url, 'post', json_encode(array($arrData))); $ip_num = count($ip); $now = time(); $sql = "INSERT INTO `log_online` (`num`, `ip_num`, `add_time`) VALUES ( '{$online_num}', '{$ip_num}', '{$now}')"; $result = Com_Db::factory('log')->query($sql); echo "time:{$now} result:" . var_export($result, true) . "\n"; Com_DataCenter::getInstance()->publish_data(0, 'ser', array('time' => $now, 'online_num' => $online_num)); }
public function send() { $this->auth = $this->_parseData; $zoneid = $this->auth['zoneid']; $url = 'http://s' . $zoneid . '.app' . $this->get_game('Tencent')->appid . '.qqopenapp.com/tencentApi.php'; $result = Com_System::open_url($url, 'post', $this->auth); echo $result; }
/** * 初始化参数结构,调用数据上报接口之前,必须初始化 * @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; }
/** * 异步推送协议 * @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); }
public static function get_360_televel($qid, $level) { $server_url = 'http://hd.wan.360.cn/check_privi.html'; #以下参数360提供 $privkey = "360send*test"; $data['aid'] = 1219; $data['gkey'] = 'fhl'; $data['skey'] = 'S1'; $data['type'] = 'privi'; # $data['time'] = time(); $data['level'] = (int) $level; $data['qid'] = $qid; $sign = md5($data['aid'] . "|" . $data['gkey'] . "|" . $data['qid'] . "|" . $data['type'] . "|" . $data['time'] . $privkey); $data['sign'] = $sign; $postString = http_build_query($data); $result = Com_System::open_url($server_url . '?' . $postString, 'get', array(), 300); return $result; }
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}";
public function write($sessID, $sessDara) { if (!$this->_isWrite) { return true; } if (!isset($_SESSION['sid']) || $_SESSION['sid'] != $sessID) { $_SESSION['sid'] = $sessID; } $newExpires = time() + $this->lifeTime; if (!$this->_sessions['expires'] || $newExpires >= $this->_sessions['expires'] + $this->updateTime) { $_SESSION['expires'] = $newExpires; } #$this->log("WRITE:".$sessID."",'sessions',1); #$this->log("OLD_SESSIONS:".var_export($this->_sessions,true)."",'sessions',1); #$this->log("SESSIONS:".var_export($_SESSION,true)."",'sessions',1); $arrChanges = array(); foreach ($_SESSION as $key => $val) { if (isset($this->_sessions[$key])) { //不相同的数据 修改并记录 if ($key != 'data' && $this->_sessions[$key] != $val) { $this->_sessions[$key] = $val; $arrChanges[$key] = $key; } } elseif (!isset($this->_sessions['data'][$key]) || $this->_sessions['data'][$key] != $val) { // 不存在SESSION字段中的数据 插入到DATA字段中 比较原因 不支持数组 $this->_sessions['data'][$key] = $val; $arrChanges['data'] = 'data'; #$this->log("CHANGE:"."{$key}",'sessions',1); } } //判断SESSION DATA数据是否被删除 foreach ($this->_sessions['data'] as $key => $val) { if (!isset($_SESSION[$key])) { unset($this->_sessions['data'][$key]); $arrChanges['data'] = 'data'; #$this->log("CHANGE:"."{$key}",'sessions',1); } } if (!empty($arrChanges)) { #$this->log("WRITECHANGES:".var_export($arrChanges,true),'sessions',1); if (!isset($arrChanges['expires'])) { $arrChanges['expires'] = 'expires'; $this->_sessions['expires'] = time() + $this->lifeTime; } if (isset($arrChanges['sid'])) { //删除已有 //$deleSql = "DELETE FROM sessions WHERE player_id='{$this->_sessions['player_id']}'"; //$this->query($deleSql); $insertSql = "REPLACE INTO sessions (" . implode(',', $arrChanges) . ") VALUES ("; $condition = ""; foreach ($arrChanges as $cField) { if ($cField == 'data') { $cData = Com_System::s_json_encode($this->_sessions[$cField]); } else { $cData = $this->_sessions[$cField]; } $condition .= ($condition ? ', ' : '') . "'{$cData}'"; } $insertSql .= $condition . ")"; $this->query($insertSql); #$this->log("WRITE:".$insertSql,'sessions',1); } else { $updateSql = "UPDATE sessions SET "; $condition = ""; foreach ($arrChanges as $cField) { if ($cField == 'data') { $cData = Com_System::s_json_encode($this->_sessions[$cField]); } else { $cData = $this->_sessions[$cField]; } $condition .= ($condition ? ', ' : '') . "{$cField} = '{$cData}'"; } $condition .= " WHERE sid = '{$sessID}'"; $updateSql .= $condition; $this->query($updateSql); #$this->log("WRITE:".$updateSql,'sessions',1); } $result = $this->affected_rows(); if ($result >= 0) { if ($result > 0 && (isset($arrChanges['sid']) || isset($arrChanges['player_id']) || $this->_sessions['player_level'] < 15)) { $result = $this->set_cache($this->get_cache_name($sessID), $this->_sessions, $this->expire); #$this->log("WRITE CACHE: RESULT = {$result}",'sessions',1); } else { $result = $this->delete_cache($this->get_cache_name($sessID)); #$this->log("DELETE CACHE: RESULT = {$result}",'sessions',1); } } else { return false; } } return true; }
/** * [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; }
} else { if ($checkNum > $checkEndNum || $checkNum <= $checkStartNum) { // echo "need time \n"; continue; } } } elseif (!$runDamon && !$restart) { //echo "not run damon script \n"; //domain进程每分钟检测 continue; } $explode = explode(" ", $process['process_file']); $fileBaseName = str_replace("/", "__", $explode[0]); $newProcess = array(); #获取进程数量 $thread_num = Com_System::get_thread_num($process['process_num']); for ($i = 0; $i < $thread_num; $i++) { $processNum = Process_Server::getProcessNum(PROCESS_PATH . '/' . $process['process_file'], CLI_PATH, array($i)); if (!$processNum) { $newProcess[] = $i; } } // var_dump($newProcess); // echo "process_file {$process['process_file']} processNum {$processNum} \n"; // if($process['process_num'] < 0){ // $process['process_num'] = $cpuNum; // } // $newNum = $process['process_num'] - $processNum; $newNum = count($newProcess); echo "new process num {$newNum} \n"; if (!empty($newProcess)) {
$log_data = array('player_id' => $player_id, 'channel' => 1, 'client_ip' => $strIp, 'game_client_ip' => $client_ip, 'reg_time' => time(), 'ad_info' => $strAdInfo, 'player_level' => 1); #Log_Login::getInstance()->add_log($log_data); Log_Common::getInstance()->add_log($log_data, 'day'); $arr_cache = array('player_id' => $player_id, 'name' => $arrData["name"], 'user_account' => $strUserAccount, 'ad_info' => $arrData['ad_Info'], 'reg_time' => time(), 'career_type' => $arrData['career_type'], 'first_load' => 0); $objPlayer = TenYear::getInstance('Data_Player'); $objPlayer->set_rookie_loading_cache($player_id, $arr_cache); #广告系统用户推送激活 $activelog = Com_System::send_request(array('user_account' => $arrData['user_account']), 'active'); #广告系统用户推送每天首次登陆 $activelog = Com_System::send_request(array('user_account' => $arrData['user_account']), 'login'); #记录登陆登出信息 TenYear::getInstance('Data_Online')->set_online_list($player_id, array('login_time' => time(), 'logout_time' => time())); Com_DataCenter::getInstance()->publish_data($player_id, 'login', array('ad_info' => $ad_info, 'status' => 'on', 'keep_time' => 0, 'time' => time())); TenYear::getInstance('Game_DailySign')->init_daily_sign_info($player_id); #TenYear::getInstance('Game_PackageCode')->async_send_old_account_login_reward($player_id, $arrData['user_account'], $_SESSION['sid']); $rurl = $webUrl . '/index.php'; if ($bAjax) { echo "result=1&msg=" . urlencode($rurl); } else { echo "<meta http-equiv=refresh content='0; url=" . $rurl . "'>"; } } else { //激活用户失败 if ($bAjax) { echo "result=0&msg=" . $arrLanguage["10218"]['content']; } else { Com_System::url_redirect($strTenYearUrl); } } exit; }
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); }
/** * 发给玩家道具接口 发道具都通过这个发 * @param $player_id * @param $prop_id 道具id * @param $prop_num 发送的道具数量 * @param $arrLogs 道具日志 * @param null $channel 0包裹满不发邮件 1 包裹满发邮件 * @param $arrPropConfig 新增道具配置 是用在发邮件的时候 装备要线吧装备属性生成 * @return bool|string */ public function send_prop_auto_overlay($player_id, $prop_id, $prop_num, &$arrLogs, $cmd_id, $bind_flag = null, $channel = 0, $arrPropConfig = null, $player_info = null) { if (!Com_System::is_int_numeric($prop_num)) { $this->throw_error('80004'); //道具数量出错! } if (empty($arrPropConfig)) { $arrPropConfig = Cache_Prop::getInstance()->get_prop_info($prop_id); } if (!is_null($bind_flag)) { $arrPropConfig['bind_flag'] = $bind_flag; } else { $arrPropConfig['bind_flag'] = $arrPropConfig['bind_type']; } $now_time = time(); if (!empty($arrPropConfig['generate_start_time']) && !empty($arrPropConfig['generate_end_time']) && ($now_time < strtotime($arrPropConfig['generate_start_time']) || $now_time > strtotime($arrPropConfig['generate_end_time']))) { return true; #没在掉落时间的去掉 } if (!Com_Array::is_good_arr($arrPropConfig)) { # 对于偶发性的奖励发送报道具配置出错问题添加调试日志 // Com_Log::write('xgame.debug', "Error occured in " . __CLASS__ . ":\t$player_id\t$prop_id\t$prop_num\t".json_encode($arrPropConfig)); $this->throw_error('80003', '101800247'); //道具配置出错,请联系客服! } if ($arrPropConfig['max_lap_num'] > 0) { $objPlayerPropData = $this->get_data("PlayerProp"); $arrPlayerPropList = $objPlayerPropData->get_player_prop_by_prop_id($player_id, $prop_id, 1); if (!$arrPlayerPropList) { return $this->send_prop_to_player($player_id, $prop_id, $prop_num, $arrLogs, $cmd_id, $arrPropConfig, $channel, $player_info); } else { $rest_prop_num = $prop_num; foreach ($arrPlayerPropList as $key => $value) { $can_overlay_num = $arrPropConfig['max_lap_num'] - $value['item_num']; //可叠加数量 if ($arrPropConfig['level'] == $value['level'] && $arrPropConfig['bind_flag'] == $value['bind_flag'] && $arrPropConfig['quality'] == $value['quality'] && $can_overlay_num > 0 && $value['player_id'] == $player_id && $value['prop_id'] == $prop_id && $value['item_position'] == 1) { $overlay_num = min($rest_prop_num, $can_overlay_num); //叠加的数量 if (!$objPlayerPropData->update_prop_num($player_id, $value, $overlay_num, '+', array(), false)) { $this->throw_error('80005'); //更新道具数量失败 } $value['player_prop_id'] = $value['player_prop_id']; $value['prop_id'] = $arrPropConfig['prop_id']; $value['prop_name'] = $arrPropConfig['prop_name']; $value['overlay_num'] = $overlay_num; $value['item_num'] += $overlay_num; $value['grid'] = $value['grid']; $value['item_position'] = $value['item_position']; $arrTempLogs = array_merge($arrPropConfig, $value); $arrLogs[] = $arrTempLogs; unset($arrTempLogs); $rest_prop_num = $rest_prop_num - $overlay_num; if ($rest_prop_num <= 0) { break; } } } if ($rest_prop_num > 0) { return $this->send_prop_to_player($player_id, $prop_id, $rest_prop_num, $arrLogs, $cmd_id, $arrPropConfig, $channel, $player_info); } return true; } } else { return $this->send_prop_to_player($player_id, $prop_id, $prop_num, $arrLogs, $cmd_id, $arrPropConfig, $channel, $player_info); } }
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'); } } }
private function bind_phone($player_id, $phone_num, $sms_code, $session_id) { $player_info = $this->get_data('Player')->get_player_info($player_id); $query_string_arr = array('account' => $player_info['user_account'], 'mobile' => $phone_num, 'app_id' => $this->app_id_bind, 'code' => $sms_code, 'session_id' => $session_id, 'time' => $this->current_time); ksort($query_string_arr); $sign_string = ""; foreach ($query_string_arr as $key => $value) { if (empty($sign_string)) { $sign_string .= $key . "=" . $value; } else { $sign_string .= "&" . $key . "=" . $value; } } $verify = md5($sign_string . $this->secret_key_bind); $query_string_arr['verify'] = $verify; $url = $this->url_bind . "?" . $sign_string . "&verify={$verify}"; # 平台要求以GET方式请求 $return_json = Com_System::open_url($url); $result = json_decode($return_json, true); # 记录行为 Com_Log::write('xgame.authreward', "{$player_id}\t" . "bind_phone\t" . "{$phone_num}\t" . "{$sms_code}\t" . "{$session_id}\t" . "{$return_json}\t"); return $result; }
public function async_trigger_guide_task($player_id, $type, $add_num, $target_type = 0) { $data['player_id'] = $player_id; $data['type'] = $type; $data['target_type'] = $target_type; $data['add_num'] = $add_num; # 获取异步处理队列需要用的频道分割序号 $channel_seq = Com_System::get_queue_channel_seq($player_id, 12); return Com_Queued::send($this->_deal_guide_task_transfer_data_channel . "_" . $channel_seq, json_encode($data)); }
private function CheckAccount($player_id, $time, $user_account, $session_id) { //$player_info = $this->get_data('Player')->get_player_info($player_id, array('user_account', 'session_id')); //$session_info = $this->get_game('Online')->get_session($player_info['session_id']); $arrData = array(); $arrData['account'] = $user_account; $arrData['game_id'] = 1; $arrData['fields'] = 'reg_time'; ksort($arrData); $auth = $this->createAuth($arrData); $arrData['verify'] = md5($auth . 'NBg5akoBBLiiqKsW'); $url = "http://api.uuzu.com/platform/user/info"; $dataArr = json_decode(Com_System::open_url($url, 'post', $arrData, 5), true); $ret = false; if ($dataArr['status'] == 0) { if (isset($dataArr['userinfo']) && isset($dataArr['userinfo']['reg_time']) && !empty($dataArr['userinfo']['reg_time']) && $dataArr['userinfo']['reg_time'] <= $time) { $ret = true; } } return $ret; }
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'); } }
public function curlDate($account, $type, $nowTime, $ip) { $server_url = 'http://adapi.uuzu.com/api.php'; $adKey = '3a3ea00cfc35332cedf6e5e9a32e94da'; $postString = 'm=' . $type; $arrAuth = array(); $arrAuth['project_id'] = OPERATOR_ID; $arrAuth['game_id'] = GAME_ID; $arrAuth['account'] = $account['user_account']; if (empty($arrAuth['project_id']) || empty($arrAuth['game_id'])) { return false; } switch ($type) { case 'active': $arrAuth['game_zone'] = SERVER_ID; $arrAuth['activetime'] = $nowTime; $arrAuth['ip'] = $ip; break; case 'login': $arrAuth['logintime'] = $nowTime; $arrAuth['ip'] = $ip; $arrAuth['origin'] = 1; break; case 'level': $arrAuth['game_zone'] = SERVER_ID; $arrAuth['level'] = $account['level']; $arrAuth['pushtime'] = $nowTime; break; } ksort($arrAuth); $auth = ''; foreach ($arrAuth as $key => $value) { $auth .= $key . '=' . $value . '&'; } $auth = base64_encode(rtrim($auth, '&')); $postString .= '&auth=' . $auth; $postString .= '&verify=' . md5($auth . $adKey); $result = Com_System::open_url($server_url . '?' . $postString, 'get', array(), 300); return $result; }
public function publish_attr($player_id, $data) { # 获取异步处理队列需要用的频道分割序号 $channel_seq = Com_System::get_queue_channel_seq($player_id, 141); return Com_Queued::send($this->_sync_player_attr . "_" . $channel_seq, json_encode($data)); }
<?php define('UUZU_AUTH', 1); require dirname(__FILE__) . '/../global.php'; TenYear::getInstance(); if (!isset($_SESSION['player_id']) || !$_SESSION['player_id']) { Com_System::url_redirect(MAIN_DOMAIN_URL); } TenYear::getInstance(TenYear::game_name('DailySign'))->async_trigger_login_times($_SESSION['player_id']); $strTitleSet = SERVER_TITLE; $flah_version = '201508061503'; #flash版本号 ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="icon" href="/mf.png" /> <title><?php echo $strTitleSet; ?> </title> <style type="text/css"> body{font-size:12px; color:#0B1410; margin:0px; padding:0px; text-align:center;} </style> <script type="text/javascript" src="<?php echo MEDIA_SERVER_HOST; ?> /swfobject.js"></script> <?php
public function param_check_numeric($param_array, $scope = 1, $out_code = 0) { if (!empty($param_array)) { if (!is_array($param_array)) { $param_array = array($param_array); } foreach ($param_array as $param) { if (!Com_System::is_int_numeric($param, $scope)) { $this->throw_error('10107', $out_code); # 参数错误 } } } else { $this->throw_error('10107', $out_code); # 参数错误 } }
/** * 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(); } }
/** * @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)); }
/** * 后台任务管理进程 * 进程重启 * * @author zhangh@uuzu.com * @date 2011-10-01 */ define('UUZU_AUTH', 0); require dirname(__FILE__) . '/global.php'; TenYear::getInstance(); require PROCESS_PATH . '/Process/Server.php'; $objProcess = new Process_Server(); $mainProcess = false; $scriptFile = PROCESS_PATH . '/Process/Control.php'; #Control进程 $hostIP = Com_System::get_host_ip(); if ($hostIP == PROCESS_MAIN_IP) { $mainProcess = true; } # kill Control进程 while (true) { if (Process_Server::killProcess($scriptFile, CLI_PATH)) { break; } sleep(1); } # 获取process_list配置表进程列表,并按条件kill $processList = $objProcess->getProcessList(); foreach ($processList as $process) { //非常驻进程 if ($process['process_interval']) {
protected function parser_dispatch() { $passport_key = SERVER_KEY; $rurl = MAIN_DOMAIN_URL; $timeExpire = 300; // $arrGet = isset($_GET) ? $_GET : array(); // $arrPost = isset($_POST) ? $_POST : array(); // $arrData = array_merge($arrGet,$arrPost); $arrData = $_REQUEST; $strAction = isset($arrData["action"]) ? $arrData["action"] : ""; $strVerify = isset($arrData["verify"]) ? $arrData["verify"] : ""; $iNologin = isset($arrData["nologin"]) ? $arrData["nologin"] : 0; $strTocken = isset($arrData["tocken"]) ? $arrData["tocken"] : ""; $strActive_type = isset($arrData["active_type"]) ? $arrData["active_type"] : 1; if (empty($strAction) || empty($strVerify)) { Com_System::url_redirect($rurl); } else { unset($arrData["action"], $arrData["verify"]); } if (isset($arrData["nologin"])) { unset($arrData["nologin"]); } if (Com_Array::is_good_arr($arrData)) { ksort($arrData); } else { Com_System::url_redirect($rurl); } $strCommand = 'run'; #$strAuth = $_GET["auth"]; #$strVerify = $_GET["verify"]; if (isset($arrData['sid']) || defined('IS_MERGE_SERVER') && IS_MERGE_SERVER) { $arrApiParameter = array('active_type', 'account', 'ad_info', 'adult_flag', 'game_time', 'ip', 'sid', 'time', 'op_id', 'verify', 'tocken'); } else { $arrApiParameter = array('active_type', 'account', 'ad_info', 'adult_flag', 'game_time', 'ip', 'time', 'op_id', 'verify', 'tocken'); # 接口必须的参数 配合平台接口加了个过滤。 } $strAuth = ""; foreach ($arrData as $key => $value) { if (!in_array($key, $arrApiParameter)) { unset($arrData[$key]); } else { if (empty($strAuth)) { $strAuth .= $key . "=" . $value; } else { $strAuth .= "&" . $key . "=" . $value; } } } #$strAuth = http_build_query($arrData); #$strAuth = "account=".$arrData['account']."&ad_info=".$arrData['ad_info']."&adult_flag=".$arrData['adult_flag']."&game_time=".$arrData['game_time']."&ip=".$arrData['ip']."&time=".$arrData['time']; $strMd5Auth = md5($strAuth . $passport_key); #echo $strAuth,"<br>"; #echo $strMd5Auth;exit; #$strBase64Auth = base64_decode($strAuth); #$arrTmp = explode("&",$strBase64Auth); #$iDataLen = count($arrTmp); #$arrData = array(); #for($i = 0,$len = $iDataLen;$i < $len;$i++) { #$tmp = explode("=",$arrTmp[$i]); #if($tmp) { #$arrData[$tmp[0]] = (isset($tmp[1])) ? trim($tmp[1]) : ""; #} #} $strUserAccount = isset($arrData["account"]) ? trim($arrData["account"]) : ""; $strTime = isset($arrData["time"]) ? $arrData["time"] : 0; $result = 0; if ($strMd5Auth != $strVerify) { $result = array('status' => 1); #验证码错误 } else { if ($strTime == 0) { $result = array('status' => 3); #缺少参数 } else { if ($strUserAccount == "") { $result = array('status' => 3); #缺少参数 } else { if (time() - $strTime > $timeExpire) { $result = array('status' => 2); //时间过期 } } } } if ($result > 0) { echo json_encode($result); exit; } $arrData['nologin'] = $iNologin; if ($strTocken) { $arrData['tocken'] = $strTocken; } $this->_action = ucfirst($strAction) . 'Action'; $this->_command = $strCommand; $this->_parseData = $arrData; }
public function run() { if (1 == OPERATOR_ID && SERVER_ID > 2) { $url = "http://api.uuzu.com/platform/user/info"; $oPlayer = new Data_Player(); $oAccount = new Data_Account(); $sql = 'select * from account where plat_reg_time=-1;'; $oAccount->query($sql); $records = array(); while ($oAccount->next_record()) { $records[] = $oAccount->get_record(); } foreach ($records as $user) { $arrData = array(); $arrData['account'] = $user['user_account']; $arrData['game_id'] = 1; $arrData['fields'] = 'reg_time'; ksort($arrData); $auth = $this->createAuth($arrData); $arrData['verify'] = md5($auth . 'NBg5akoBBLiiqKsW'); $dataArr = json_decode(Com_System::open_url($url, 'post', $arrData, 5), true); if ($dataArr['status'] == 0 && isset($dataArr['userinfo']) && isset($dataArr['userinfo']['reg_time']) && !empty($dataArr['userinfo']['reg_time'])) { $oPlayer->start_trans(); if (date('Ymd', $user['add_time']) == date('Ymd', $dataArr['userinfo']['reg_time'])) { $new_acc = 1; } else { $new_acc = 0; } $arr = array('plat_reg_time' => $dataArr['userinfo']['reg_time'], 'new_plat_account' => $new_acc); $sql = 'update account set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=' . $new_acc . ' where player_id=' . $user['player_id']; $ret = $oAccount->query($sql); if ($ret) { if ($user['name'] && $user['new_plat_account'] != $new_acc) { $ret = $oPlayer->update_player_info($user['player_id'], $arr); if ($ret) { $sql = 'update player set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=' . $new_acc . ' where player_id=' . $user['player_id']; $oPlayer->query($sql); if ($oPlayer->affected_rows() > 0) { $ret = true; } else { $ret = false; } } } } if ($ret) { $oPlayer->commit(); } else { $oPlayer->rollback(); } } else { $arr = array('plat_reg_time' => 1, 'new_plat_account' => 0); $oPlayer->start_trans(); $sql = 'update account set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=0 where player_id=' . $user['player_id']; $ret = $oAccount->query($sql); if ($ret) { if ($user['name']) { $ret = $oPlayer->update_player_info($user['player_id'], $arr); if ($ret) { $sql = 'update player set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=0 where player_id=' . $user['player_id']; $oPlayer->query($sql); if ($oPlayer->affected_rows() > 0) { $ret = true; } else { $ret = false; } } else { $ret = false; } } } if ($ret) { $oPlayer->commit(); } else { $oPlayer->rollback(); } } $rd = rand(1, 10); if (1 == $rd) { sleep(1); } } } }
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'); } }
public function sendMessageSuning($dataArr, $type, $nowTime, $ip) { $server_url = 'http://openesb.suning.com/esbadapter/SNGamingPlatformMgmt/createGameRole'; // $dataArr['server_id'] = 406080001; $server_code = $dataArr['server_id'] - 406080000; $server_code = 'UDXZs' . $server_code; $time = substr(microtime(true) * 1000, 0, -2); $loginTime = date('Y-m-d H:i:s', $nowTime); $reqId = $server_code . $dataArr['player_id']; $reqStr = 'serverCode=' . $server_code . '&custNum=' . $dataArr['account'] . '&roleUid=' . $dataArr['account'] . '&roleName=' . $dataArr['player_name'] . '&roleLevel=1&balance=0&loginTime=' . $loginTime . '&reqId=' . $reqId . '×tamp=' . $time; $req = base64_encode($reqStr); $sign = md5($req . 'F94PK5IJT0WP0JTNHYLGSGHAYHV43IDDIK9CH6LJYIEIHEQDU4IIN1X95LZXRVUZOPDKM2SJM4LGHHLYGJ5XTGFAKJ8GQYA9DF35MJYIMPD8FPGRPEXOI0DS8R30RPA6MF1WQRD2JQISHTVHRK8SCB1N05YT89M705JMIRHA223PCMJ7W4RSQZKHFVTXCPE8GJMCQZIIRGVPOWF5B0K8VSPH1FAUN6EF28LPPOSHPEJYA31XE92UJ5IUF4EIGKK9'); $data = 'req=' . $req . '&sign=' . $sign; // file_put_contents(PROJECT_ROOT.'/uuzudo.log' , $server_url . "\n" . $data . "\n" , FILE_APPEND); $result = Com_System::open_url($server_url, 'post', $data, 300); // file_put_contents(PROJECT_ROOT.'/uuzudo.log',$result."\n",FILE_APPEND); return $result; }
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(''); # 参数非法 } }