accountId = $_REQUEST['account_id']; $this->sessionId = $_REQUEST['session_id']; if (!phpcommon\isValidSessionId($this->accountId, $this->sessionId)) { phpcommon\sendError(500, '无效的session_id'); die(); } } protected function getAccountId() { return $this->accountId; } protected function getChannel() { return phpcommon\extractChannel($this->getAccountId()); } protected function getSessionId() { return $this->sessionId; } protected function getRegisterTime() { $registertime = phpcommon\extractRegisterTimeFromSessionId($this->sessionId); return $registertime; } protected function getMysql($data) { $mysql_conf = getMysqlConfig(crc32($data)); $conn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] )); return $conn; } protected function getSelfMysql() { if (!$this->mysqlConn) { $this->mysqlConn = $this->getMysql($this->getAccountId()); } return $this->mysqlConn; } protected function getRedis($data) { $redis_conf = getRedisConfig(crc32($data)); $r = new phpcommon\Redis(array( 'host' => $redis_conf['host'], 'port' => $redis_conf['port'], 'passwd' => $redis_conf['passwd'] )); return $r; } protected function isValidSex($sex) { return in_array($sex, array(0, 1, 2)); } }