3 # http user space authentication layer
4 # ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
5 # can be used with the tools/, if you don't want to
6 # set up the .htaccess and .htpasswd files
9 #-- (pw array - I have such one in an external config file)
11 // "user" => "password",
12 // "u2" => "password",
17 #-- fetch user:password
18 if ($uu = trim($_SERVER["HTTP_AUTHORIZATION"])) {
21 $uu = base64_decode($uu);
22 list($_a_u, $_a_p) = explode(":", $uu, 2);
24 elseif (strlen($_a_u = trim($_SERVER["PHP_AUTH_USER"]))) {
25 $_a_p = trim($_SERVER["PHP_AUTH_PW"]);
30 if (strlen($_a_u) && strlen($_a_p) && ($_a_p == @$passwords[$_a_u])) {
34 #-- request HTTP Basic authentication otherwise
36 header('HTTP/1.1 401 Authentication Required');
37 header('Status: 401 Authentication Required');
38 header('WWW-Authenticate: Basic realm="restricted access"');