Created
April 12, 2020 06:13
-
-
Save zengxs/ead9fc6e55ab144380b501c441700abd to your computer and use it in GitHub Desktop.
`php_info` page with HTTP Basic 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
<?php | |
$credentials = array( | |
'admin' => 'your_password', | |
); | |
$valid_users = array_keys($credentials); | |
$user = $_SERVER['PHP_AUTH_USER']; | |
$pass = $_SERVER['PHP_AUTH_PW']; | |
$validated = (in_array($user, $valid_users) && ($pass == $credentials[$user])); | |
if (!$validated) { | |
header('WWW-Authenticate: Basic realm="My Realm"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
die('Not authorized'); | |
} | |
phpinfo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment