MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / wiki / ewiki / fragments / auth.php
blobb1a639e4e2805c0e3a0ce83b5399894e539e0a45
1 <?php
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)
10 $passwords = array(
11 // "user" => "password",
12 // "u2" => "password",
17 #-- fetch user:password
18 if ($uu = trim($_SERVER["HTTP_AUTHORIZATION"])) {
19 strtok($uu, " ");
20 $uu = strtok(" ");
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"]);
28 #-- check password
29 $_success = false;
30 if (strlen($_a_u) && strlen($_a_p) && ($_a_p == @$passwords[$_a_u])) {
31 $_success = $_a_u;
34 #-- request HTTP Basic authentication otherwise
35 if (!$_success) {
36 header('HTTP/1.1 401 Authentication Required');
37 header('Status: 401 Authentication Required');
38 header('WWW-Authenticate: Basic realm="restricted access"');
39 die();