Conditions | 7 |
Paths | 48 |
Total Lines | 19 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public static function protect($user = null, $password = null) |
||
21 | { |
||
22 | if (!$user) { |
||
23 | $user = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME'); |
||
24 | } |
||
25 | if (!$password) { |
||
26 | $password = Environment::getEnv('SS_DEFAULT_ADMIN_PASSWORD'); |
||
27 | } |
||
28 | header('Cache-Control: no-cache, must-revalidate, max-age=0'); |
||
29 | $hasSuppliedCredentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW'])); |
||
30 | if ($hasSuppliedCredentials) { |
||
31 | $isNotAuthenticated = ($_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $password); |
||
32 | } else { |
||
33 | $isNotAuthenticated = true; |
||
34 | } |
||
35 | if ($isNotAuthenticated) { |
||
36 | header('HTTP/1.1 401 Authorization Required'); |
||
37 | header('WWW-Authenticate: Basic realm="Access denied"'); |
||
38 | exit; |
||
39 | } |
||
42 |