protected function authenticate()
{
// Get credentials stored ...
$credentials = $this->getCredentials();
$username = $credentials['username'];
$password = $credentials['password'];
// Check if $username set = login required!
if ($username !== null && !($this->getAction() === self::ACTION_NEUTRAL) && !($this->getAction() === self::ACTION_LOGOUT && $username === 'logout' && $password === 'logout')) {
if (isset($_SERVER['PHP_AUTH_USER']) === false || isset($_SERVER['PHP_AUTH_PW']) === false || $_SERVER['PHP_AUTH_USER'] !== $username || $_SERVER['PHP_AUTH_PW'] !== $password) {
Header('WWW-Authenticate: Basic realm="phpMemAdmin | Login"');
Header('HTTP/1.0 401 Unauthorized');
echo '<html><body><h1>Access denied</h1><b>Invalid credentials.</b></body></html>';
exit;
}
}
// Return this instance ...
return $this;
}