Skip to content

Instantly share code, notes, and snippets.

@Kcko
Last active August 29, 2015 14:07
Show Gist options
  • Save Kcko/103aec1b1af2bc48df5b to your computer and use it in GitHub Desktop.
Save Kcko/103aec1b1af2bc48df5b to your computer and use it in GitHub Desktop.
Serverová ochrana PHP AUTH
<?
$LoginSuccessful = false;
$login = $password = 'xxx';
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){
$Username = $_SERVER['PHP_AUTH_USER'];
$Password = $_SERVER['PHP_AUTH_PW'];
if ($Username == $login && $Password == $password){
$LoginSuccessful = true;
}
}
if (!$LoginSuccessful)
{
header('WWW-Authenticate: Basic realm="Secret page"');
header('HTTP/1.0 401 Unauthorized');
print "Login failed!\n";
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment