* @version 1.0.1 (July 02, 2004) * @package AutoIndex */ class UserLoggedIn extends User { /** * Since the user is already logged in, the account options will be * displayed rather than a login box. * * @return string The HTML text that makes up the account options box */ public function login_box() { global $config, $words, $request, $you, $subdir; $PHP_SELF = $request->server('PHP_SELF'); $autoindex_u = empty($PHP_SELF) ? $config->__get('base_dir') : $PHP_SELF; $autoindex_a = str_replace(array('&logout=true', '&logout=true'), array('', ''), $autoindex_u); $txt = '
' . $words->__get('logout') . ' [ ' . Url::html_output($this->username) . ' ]
'; if ($you->level >= MODERATOR) //show admin options if they are a moderator or higher { $admin_panel = new Admin($you); $txt = $admin_panel->__toString() . $txt; } if ($you->level >= LEVEL_TO_UPLOAD) //show upload options if they are a logged in user or higher { $upload_panel = new Upload($you); $txt .= $upload_panel->__toString(); } return $txt; } /** * Logs out the user by destroying the session data and refreshing the * page. */ public function logout() { global $request, $subdir; $this->level = GUEST; $this->sha1_pass = $this->username = ''; session_unset(); session_destroy(); $home = new Url(Url::html_output($request->server('PHP_SELF', '')), true); $home->redirect(); } /** * Validates username and password using the accounts stored in the * user_list file. * * @param string $username The username to login * @param string $sha1_pass The sha-1 hash of the password */ public function __construct($username, $sha1_pass) { parent::__construct($username, $sha1_pass); $accounts = new Accounts(); if (!($accounts->is_valid_user($this))) { global $log; $log->add_entry("Invalid login (Username: $username)"); session_unset(); sleep(1); throw new ExceptionDisplay('Invalid username or password.'); } $this->level = $accounts->get_level($username); if ($this->level <= BANNED) { throw new ExceptionDisplay('Your account has been disabled by the site admin.'); } $this->username = $accounts->get_stored_case($username); $this->home_dir = $accounts->get_home_dir($username); } } ?>