Last active
August 29, 2015 14:07
-
-
Save Kcko/103aec1b1af2bc48df5b to your computer and use it in GitHub Desktop.
Serverová ochrana PHP AUTH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$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