/** * Returns wether the user is logged in or not. * * @return boolean * True if logged in, else false. */ public function check_login() { if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { $pw_hash = new PasswordHash(); if ($this->access_config->user_exists($_SERVER['PHP_AUTH_USER'])) { $user = $this->access_config->user_get($_SERVER['PHP_AUTH_USER']); if ($pw_hash->check_password($_SERVER['PHP_AUTH_PW'], $user['password'])) { self::$session->set('username', $_SERVER['PHP_AUTH_USER']); // This is for now the only position where we write, so we can close the session for write operations. // This will speed up the performance. self::$session->close_write(); $this->user = $this->get_config()->user_get(self::$session->get('username')); return true; } } } if (self::$session->get('username') != 0) { $this->user = $this->get_config()->user_get(self::$session->get('username')); return true; } header('WWW-Authenticate: Basic realm="PHPMiner "'); header('HTTP/1.0 401 Unauthorized'); }