]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/Init.php
baculum: Assign Baculum copyright to Kern Sibbald
[bacula/bacula] / gui / baculum / protected / Init.php
index a58e640e9bf5265ee77be5f49b34bd55fe159a3b..5c59817720219c36abe19b1a0d03a609881f235c 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2015 Marcin Haba
+ * Copyright (C) 2013-2016 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -31,12 +31,24 @@ if (!ini_get('date.timezone')) {
        date_default_timezone_set($timezone);
 }
 
-// Support for web servers which do not provide direct info about HTTP Basic auth to PHP superglobal $_SERVER array.
-if(!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW'])) {
-    list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
+/*
+ * Support for web servers (for example Lighttpd) which do not provide direct
+ * info about HTTP Basic auth to PHP superglobal $_SERVER array.
+ */
+if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW']) && isset($_SERVER['HTTP_AUTHORIZATION'])) {
+       /*
+        * Substring 'Basic ' from  HTTP authorization header
+        * Example 'Basic YWRtaW46YWRtaW4=' becomes 'YWRtaW46YWRtaW4='
+        */
+       $encoded_credentials = substr($_SERVER['HTTP_AUTHORIZATION'], 6);
+       $decoded_credentials = base64_decode($encoded_credentials);
+
+       // initialize required auth superglobal $_SERVER array
+       list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', $decoded_credentials);
 }
 
+// Check requirements and if are some needed then show requirements page
 require_once('./protected/Pages/Requirements.php');
-new Requirements(__DIR__);
+new Requirements(dirname(__DIR__));
 
 ?>