Skip to content

Instantly share code, notes, and snippets.

@zengxs
Created April 12, 2020 06:13
Show Gist options
  • Save zengxs/ead9fc6e55ab144380b501c441700abd to your computer and use it in GitHub Desktop.
Save zengxs/ead9fc6e55ab144380b501c441700abd to your computer and use it in GitHub Desktop.
`php_info` page with HTTP Basic Auth
<?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