]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Enabled support for run WebGUI in document root subdirectory
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 8 Aug 2014 17:08:30 +0000 (19:08 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Fri, 8 Aug 2014 17:08:30 +0000 (19:08 +0200)
gui/baculum/index.php
gui/baculum/protected/Class/API.php
gui/baculum/protected/Class/BaculumPage.php
gui/baculum/protected/Pages/ConfigurationWizard.php
gui/baculum/themes/Baculum-v1/style.css
gui/baculum/themes/Baculum-v1/wizard.css

index 41881b4f50ede8cb24783e8da4429b919a470b4c..b97b1e0c6de039e02c7b3aff65b1fe91c6d5e069 100644 (file)
@@ -23,9 +23,11 @@ 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)));
 }
 
+define('APPLICATION_DIRECTORY', __DIR__);
+
 require_once('./protected/Pages/Requirements.php');
 new Requirements(__DIR__);
 require_once('./framework/prado.php');
 $application=new TApplication;
 $application->run();
-?>
\ No newline at end of file
+?>
index f86f4aa7d82c252ee7e62ec8eebe9aba06be44ee..74d9e019a69e60c686f6a9c333c0cd500df2820b 100644 (file)
@@ -52,7 +52,8 @@ class API extends TModule {
                $protocol = !empty($_SERVER['HTTPS']) ? 'https' : 'http';
                $host = $_SERVER['SERVER_NAME'];
                $port = $_SERVER['SERVER_PORT'];
-               $url = sprintf('%s://%s:%d/', $protocol, $host, $port);
+               $urlPrefix = $this->Application->getModule('friendly-url')->getUrlPrefix();
+               $url = sprintf('%s://%s:%d%s/', $protocol, $host, $port, $urlPrefix);
                return $url;
        }
 
@@ -145,4 +146,4 @@ class API extends TModule {
                return $resource;
        }
 }
-?>
\ No newline at end of file
+?>
index d3bbac812809d12c77a21384fac6a7e1a340f1de..1c9bcd3773a6a939935e8f8dfc9f100158043fa0 100644 (file)
@@ -24,6 +24,7 @@ class BaculumPage extends TPage
                parent::onPreInit($param);
                $configuration = $this->getModule('configuration');
                $this->Application->getGlobalization()->Culture = $this->getLanguage();
+               $this->setPrefixForSubdir();
        }
 
        public function getLanguage() {
@@ -43,9 +44,33 @@ class BaculumPage extends TPage
        public function goToPage($pagePath,$getParameters=null) {
                $this->Response->redirect($this->Service->constructUrl($pagePath,$getParameters,false));
        }
-       
+
        public function goToDefaultPage() {
                $this->goToPage($this->Service->DefaultPage);
        }
+
+       public function setPrefixForSubdir() {
+               $fullDocumentRoot = preg_replace('#(\/)$#', '', $this->getFullDocumentRoot());
+               $urlPrefix = str_replace($fullDocumentRoot, '', APPLICATION_DIRECTORY);
+               if(!empty($urlPrefix)) {
+                       $this->Application->getModule('friendly-url')->setUrlPrefix($urlPrefix);
+               }
+       }
+
+       private function getFullDocumentRoot() {
+               $rootDir = array();
+               $dirs = explode('/', $_SERVER['DOCUMENT_ROOT']);
+               for($i = 0; $i < count($dirs); $i++) {
+                       $documentRootPart =  implode('/', $rootDir) . '/' . $dirs[$i];
+                       if(is_link($documentRootPart)) {
+                               $rootDir = array(readlink($documentRootPart));
+                       } else {
+                               $rootDir[] = $dirs[$i];
+                       }
+               }
+
+               $rootDir = implode('/', $rootDir);
+               return $rootDir;
+       }
 }
-?>
\ No newline at end of file
+?>
index bcf84ca28794f98ba47ae16fe340f1308f1fd2e9..7c0be6720d8a446315f6d78d4afc9ef7b7f0c9c1 100644 (file)
@@ -110,8 +110,10 @@ class ConfigurationWizard extends BaculumPage
                                $this->getModule('configuration')->setUsersConfig($cfgData['baculum']['login'], $cfgData['baculum']['password'], $this->firstRun, $previousUser);
                                // Automatic login after finish wizard.
                                $http_protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
-                               $location = sprintf("%s://%s:%s@%s:%d/", $http_protocol, $cfgData['baculum']['login'], $cfgData['baculum']['password'], $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']);
+                               $urlPrefix = $this->Application->getModule('friendly-url')->getUrlPrefix();
+                               $location = sprintf("%s://%s:%s@%s:%d%s", $http_protocol, $cfgData['baculum']['login'], $cfgData['baculum']['password'], $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $urlPrefix);
                                header("Location: $location");
+                               exit();
                        } else { // standard version (user defined auth method)
                                $this->goToDefaultPage();
                        }
@@ -224,4 +226,4 @@ class ConfigurationWizard extends BaculumPage
                $this->Step4Content->render($param->NewWriter);
        }
 }
-?>
\ No newline at end of file
+?>
index 56870cb624820511212df21a5d890ef64a4ea983..bdf99bf8bffd3f89d7997d36c0bcd806d52d4656 100644 (file)
@@ -1,6 +1,6 @@
 body {
        background-color: #b5c9d3;
-       background-image: url('/themes/Baculum-v1/background.png');
+       background-image: url('background.png');
        background-repeat: repeat-x;
        font-family: Arial, Helvetica, sans-serif;
        color: white;
@@ -74,7 +74,7 @@ a:hover {
 #top {
        width: 975px;
        height: 51px;
-       background-image: url('/themes/Baculum-v1/bls_top.png');
+       background-image: url('bls_top.png');
        background-repeat: no-repeat;
        clear: both;
 }
@@ -138,7 +138,7 @@ div.configuration {
 }
 
 div.configuration-progress {
-       background: rgba(182,182,182,0.7) url('/themes/Baculum-v1/progress.gif') no-repeat center center;
+       background: rgba(182,182,182,0.7) url('progress.gif') no-repeat center center;
        width: 443px;
        height: 575px;
        z-index: 10;
@@ -150,7 +150,7 @@ div.configuration-progress {
 }
 
 div.slide-window-progress {
-       background: rgba(182,182,182,0.7) url('/themes/Baculum-v1/progress.gif') no-repeat center center;
+       background: rgba(182,182,182,0.7) url('progress.gif') no-repeat center center;
        width: 100%;
        height: 100%;
        z-index: 10;
@@ -198,7 +198,7 @@ div.slide-window-progress {
 #bottom {
        width: 975px;
        height: 11px;
-       background: transparent url('/themes/Baculum-v1/bls_bottom.png') no-repeat top left;
+       background: transparent url('bls_bottom.png') no-repeat top left;
 }
 
 #message-box {
@@ -237,67 +237,67 @@ div.slide-window-progress {
 }
 
 .storage-btn {
-       background: transparent url('/themes/Baculum-v1/storage_icon_inactive.png') no-repeat top left;
+       background: transparent url('storage_icon_inactive.png') no-repeat top left;
 }
 
 .storage-btn:hover {
-       background: transparent url('/themes/Baculum-v1/storage_icon.png') no-repeat top left;
+       background: transparent url('storage_icon.png') no-repeat top left;
 }
 
 .client-btn {
-       background: transparent url('/themes/Baculum-v1/client_icon_inactive.png') no-repeat top left;
+       background: transparent url('client_icon_inactive.png') no-repeat top left;
 }
 
 .client-btn:hover {
-       background: transparent url('/themes/Baculum-v1/client_icon.png') no-repeat top left;
+       background: transparent url('client_icon.png') no-repeat top left;
 }
 
 .media-btn {
-       background: transparent url('/themes/Baculum-v1/media_icon_inactive.png') no-repeat top left;
+       background: transparent url('media_icon_inactive.png') no-repeat top left;
 }
 
 .media-btn:hover {
-       background: transparent url('/themes/Baculum-v1/media_icon.png') no-repeat top left;
+       background: transparent url('media_icon.png') no-repeat top left;
 }
 
 .pool-btn {
-       background: transparent url('/themes/Baculum-v1/pool_icon_inactive.png') no-repeat top left;
+       background: transparent url('pool_icon_inactive.png') no-repeat top left;
 }
 
 .pool-btn:hover {
-       background: transparent url('/themes/Baculum-v1/pool_icon.png') no-repeat top left;
+       background: transparent url('pool_icon.png') no-repeat top left;
 }
 
 .job-btn {
-       background: transparent url('/themes/Baculum-v1/job_icon_inactive.png') no-repeat top left;
+       background: transparent url('job_icon_inactive.png') no-repeat top left;
 }
 
 .job-btn:hover {
-       background: transparent url('/themes/Baculum-v1/job_icon.png') no-repeat top left;
+       background: transparent url('job_icon.png') no-repeat top left;
 }
 
 .jobrun-btn {
-       background: transparent url('/themes/Baculum-v1/jobrun_icon_inactive.png') no-repeat top left;
+       background: transparent url('jobrun_icon_inactive.png') no-repeat top left;
 }
 
 .jobrun-btn:hover {
-       background: transparent url('/themes/Baculum-v1/jobrun_icon.png') no-repeat top left;
+       background: transparent url('jobrun_icon.png') no-repeat top left;
 }
 
 .restore-btn {
-       background: transparent url('/themes/Baculum-v1/restore_icon_inactive.png') no-repeat top left;
+       background: transparent url('restore_icon_inactive.png') no-repeat top left;
 }
 
 .restore-btn:hover {
-       background: transparent url('/themes/Baculum-v1/restore_icon.png') no-repeat top left;
+       background: transparent url('restore_icon.png') no-repeat top left;
 }
 
 .setting-btn {
-       background: transparent url('/themes/Baculum-v1/setting_icon_inactive.png') no-repeat top left;
+       background: transparent url('setting_icon_inactive.png') no-repeat top left;
 }
 
 .setting-btn:hover {
-       background: transparent url('/themes/Baculum-v1/setting_icon.png') no-repeat top left;
+       background: transparent url('setting_icon.png') no-repeat top left;
 }
 
 .line {
@@ -346,29 +346,29 @@ div.slide-window-progress {
 }
 
 .bbutton input.button-left {
-       background: transparent url('/themes/Baculum-v1/button-left.png') no-repeat left 0;
+       background: transparent url('button-left.png') no-repeat left 0;
 }
 
 .bbutton input.button-center {
        padding: 0 7px;
        min-width: 65px;
-       background: transparent url('/themes/Baculum-v1/button-center.png') repeat-x left 0;
+       background: transparent url('button-center.png') repeat-x left 0;
 }
 
 .bbutton input.button-right {
-       background: transparent url('/themes/Baculum-v1/button-right.png') no-repeat left 0;
+       background: transparent url('button-right.png') no-repeat left 0;
 }
 
 .bbutton:hover input.button-left {
-       background: transparent url('/themes/Baculum-v1/button-left.png') no-repeat left -25px;
+       background: transparent url('button-left.png') no-repeat left -25px;
 }
 
 .bbutton:hover input.button-center {
-       background: transparent url('/themes/Baculum-v1/button-center.png') repeat-x left -25px;
+       background: transparent url('button-center.png') repeat-x left -25px;
 }
 
 .bbutton:hover input.button-right {
-       background: transparent url('/themes/Baculum-v1/button-right.png') no-repeat left -25px;
+       background: transparent url('button-right.png') no-repeat left -25px;
 }
 
 div.slide-window-container {
@@ -477,7 +477,7 @@ tr.file-browser-header th {
 }
 
 div.slide-window-bar {
-       background: transparent url('/themes/Baculum-v1/panel-border-btns.png') no-repeat top right;
+       background: transparent url('panel-border-btns.png') no-repeat top right;
        text-align: center;
        font-size: 10px;
        height: 14px;
@@ -487,7 +487,7 @@ div.slide-window-bar {
 }
 
 div.slide-window-bar-title {
-       background: transparent url('/themes/Baculum-v1/panel-border-bg.png') repeat-x top left;
+       background: transparent url('panel-border-bg.png') repeat-x top left;
        height: 14px;
        margin-right: 51px;
        padding: 0;
index a9ed56186f1e0276522736252fc884abe2fa48ce..c90a79c9d75cf074d67fd70ce63cdc89bef44965 100644 (file)
@@ -9,14 +9,14 @@
 .steps {
        padding: 20px;
        height: 435px;
-       background-image: url('/themes/Baculum-v1/wizard-content.png');
+       background-image: url('wizard-content.png');
        background-repeat: repeat-y;
  }
  
 .navigation {
        text-align: center;
        padding: 11px 0;
-       background-image: url('/themes/Baculum-v1/wizard-bottom.png');
+       background-image: url('wizard-bottom.png');
        background-repeat: no-repeat;
  }
  
  
   .step-first {
        width: 126px;
-       background-image: url('/themes/Baculum-v1/step-first.png');
+       background-image: url('step-first.png');
  }
  
  .step-first-active {
        width: 126px;
-       background-image: url('/themes/Baculum-v1/step-first-active.png');
+       background-image: url('step-first-active.png');
  }
  
  .step-first-next-active{
        width: 126px;
-       background-image: url('/themes/Baculum-v1/step-first-next-active.png');
+       background-image: url('step-first-next-active.png');
  }
 
 .step-last {
        width: 130px;
-       background-image: url('/themes/Baculum-v1/step-last.png');
+       background-image: url('step-last.png');
  }
 
  .step-last-active {
        width: 130px;
-       background-image: url('/themes/Baculum-v1/step-last-active.png');
+       background-image: url('step-last-active.png');
  }
  
  .step-last-next-active{
        width: 130px;
-       background-image: url('/themes/Baculum-v1/step-last-next-active.png');
+       background-image: url('step-last-next-active.png');
  }
 
 .step-normal, .step-prev-active {
-       background-image: url('/themes/Baculum-v1/step.png');
+       background-image: url('step.png');
  }
  
 .step-active{
-       background-image: url('/themes/Baculum-v1/step-active.png');
+       background-image: url('step-active.png');
  }
  
 .step-prev-active {
-       background-image: url('/themes/Baculum-v1/step-prev-active.png');
+       background-image: url('step-prev-active.png');
  }
  
 #licence {
@@ -92,7 +92,7 @@
        clear: left;
        font-size: 14px;
        font-weight: bold;
-       background-image: url('/themes/Baculum-v1/wizard-header.png');
+       background-image: url('wizard-header.png');
        background-repeat: no-repeat;
        padding: 4px;
 }