httpRequest->getRawServerValue('PHP_AUTH_USER'))!==null && ($pass = $this->httpRequest->getRawServerValue('PHP_AUTH_PW'))!==null) { return array($user,$pass); } // Most other webservers $auth = $this->httpRequest->getHeader('Authorization'); // Apache could prefix environment variables with REDIRECT_ when urls // are passed through mod_rewrite if (!$auth) { $auth = $this->httpRequest->getRawServerValue('REDIRECT_HTTP_AUTHORIZATION'); } if (!$auth) return false; if (strpos(strtolower($auth),'basic')!==0) return false; return explode(':', base64_decode(substr($auth, 6)),2); } /** * Returns an HTTP 401 header, forcing login * * This should be called when username and password are incorrect, or not supplied at all * * @return void */ public function requireLogin() { $this->httpResponse->setHeader('WWW-Authenticate','Basic realm="' . $this->realm . '"'); $this->httpResponse->sendStatus(401); } }