protected function is_login() { // log_info("main :".getClientIP()."\t".var_export($_SESSION[SESS_USER],true)); if (!empty($_SESSION[SESS_USER])) { return true; } // log_info("main no session_user:".getClientIP()); if (isset($_COOKIE[SDK]) && isset($_COOKIE[SDU]) && isset($_COOKIE[SDP])) { $crypt_key = $_COOKIE[SDK]; $user_name = crypt_decode($_COOKIE[SDU], $crypt_key); $password = crypt_decode($_COOKIE[SDP], $crypt_key); // $password = md5(strtoupper(md5($pwd))); $logSign = md5($user_name . $password . LOGIN_KEY); $data = array('passport' => $user_name, 'password' => $password, 'sign' => $logSign); $resp = $this->curl_request(LOGIN_URL, $data); $resp = json_decode($resp, true); $user_java = $resp[0]; unset($resp); if (empty($user_java) || $user_java['result'] == 'fail') { return false; } $this->loadModel('member_model'); //初始model $userInfo = $this->member_model->getOne("*", array('account_id' => $user_java['account_id']), USER_INFO . $user_java['account_id'], 3600 * 2); $userInfo['account'] = $user_name; $userInfo['account_id'] = $user_java['account_id']; $userInfo['reg_ip'] = empty($userInfo['reg_ip']) ? long2ip($user_java['active_ip']) : $userInfo['reg_ip']; $userInfo['reg_time'] = empty($userInfo['reg_time']) ? $user_java['active_time'] : $userInfo['reg_time']; $_SESSION[SESS_USER] = $userInfo; return true; } return false; }
/** * 登陆平台成功后 进入游戏 */ public function play() { //www.xxx.com/interf/play/游戏ID/服务器ID/KEY/用户名/密码 if (!isset($_GET[2]) || !isset($_GET[3])) { $this->report("登录参数错误!"); } $gameid = intval($_GET[2]); $serverid = intval($_GET[3]); $this->loadModel('game_manager'); $game = $this->game_manager->get_game($gameid); if (empty($game)) { $this->report("登录参数错误!"); } // if (empty($_SESSION[SESS_USER])){ $temp_key = str_ireplace('-', '=', $_GET[4]); $temp_name = str_ireplace('-', '=', $_GET[5]); $temp_pwd = str_ireplace('-', '=', $_GET[6]); $crypt_key = base64_decode($temp_key); $user_name = crypt_decode(base64_decode($temp_name), $crypt_key); $password = crypt_decode(base64_decode($temp_pwd), $crypt_key); $res = $this->login_arg($user_name, $password); if (!$res) { $this->report("您还未登录,或已登陆超时!请您从官网登陆游戏!", $game['url']); } //-----写用户名 密码 重新写 Cookie 有效期12小时 $crypt_key = md5($user_name . time() . ENCRYPT_KEY); setcookie(SDK, $crypt_key, time() + 3600 * 12, '/', DOMAIN); setcookie(SDU, crypt_encode($user_name, $crypt_key), time() + 3600 * 12, '/', DOMAIN); setcookie(SDP, crypt_encode($password, $crypt_key), time() + 3600 * 12, '/', DOMAIN); // } header("Location: http://yy.51yx.com/playgame/index/{$gameid}/{$serverid}"); //TODO: 平台登陆地址 }