function initialize() { $userid = (int) LoginSession::get()->check(); if (!$userid || $userid >= MANAGER_ID_MAX) { $this->setRedirect(HOME_URL); return; } }
protected function checkSession() { $userid = (int) LoginSession::get()->check(); if (!$userid) { throw new VoiceException(CommonMessages::get()->msg('NO_SESSION')); } $this->userid = $userid; }
function handle() { $this->assign('api_url', API_URL); if ($this->userid) { $playlistArray = $this->playlistDb->getUserInfos($this->userid); $this->assign("playlist_array", $playlistArray); } if ($this->memory) { $this->handleProgram(); } if (is_a($this->media, "VoiceInfo")) { $key = LoginSession::get()->getTempKey(); $apiMedia = sprintf("%smedia/%d/%s/%s.mp3", API_URL, $key->userid, $key->tempKey, $this->media->mediaid); $this->assign('media_info', $this->media); $this->assign('api_media', $apiMedia); } }
function initialize() { $path = $_SERVER['PHP_SELF']; $cells = mb_split('/', $path); $filename = array_pop($cells); $key = array_pop($cells); $userid = array_pop($cells); $file = mb_split('\\.', $filename); $mid = $file[0]; $ext = $file[1]; if ($ext != "mp3") { throw new VoiceException(self::ERROR_INVALID_FORMAT); } $_REQUEST[LoginSession::SESSION_USERID] = $userid; $_REQUEST[LoginSession::SESSION_KEY] = $key; if (!LoginSession::get()->check()) { throw new VoiceException(self::ERROR_NO_SESSION); } $this->info = MediaInfo::getInfo($mid); if (!$this->info) { throw new VoiceException(self::ERROR_NO_INFO); } }
function handle() { $command = $_REQUEST['command']; switch ($this->mode) { case self::MODE_NOT_LOGINED: if ($command != 'login') { break; } $this->user = $this->db->authorizeUser($this->user); if (!$this->user->userid) { throw new VoiceException(CommonMessages::get()->msg('LOGIN_ERROR')); } LoginSession::get()->make($this->user->userid); $this->assignHash(LoginSession::get()->getSessionArray()); $this->assign('logined', true); break; case self::MODE_LOGINED: if ($command == 'logout') { LoginSession::get()->clear(); $this->assign('logined', false); } break; } }
protected function assignSession() { $this->assignHash(LoginSession::get()->getSessionArray()); }