From 494ca2f55bcadcb932248e83224339c6526f461d Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Fri, 8 Aug 2014 19:08:30 +0200 Subject: [PATCH] baculum: Enabled support for run WebGUI in document root subdirectory --- gui/baculum/index.php | 4 +- gui/baculum/protected/Class/API.php | 5 +- gui/baculum/protected/Class/BaculumPage.php | 29 +++++++++- .../protected/Pages/ConfigurationWizard.php | 6 +- gui/baculum/themes/Baculum-v1/style.css | 58 +++++++++---------- gui/baculum/themes/Baculum-v1/wizard.css | 24 ++++---- 6 files changed, 78 insertions(+), 48 deletions(-) diff --git a/gui/baculum/index.php b/gui/baculum/index.php index 41881b4f50..b97b1e0c6d 100644 --- a/gui/baculum/index.php +++ b/gui/baculum/index.php @@ -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 +?> diff --git a/gui/baculum/protected/Class/API.php b/gui/baculum/protected/Class/API.php index f86f4aa7d8..74d9e019a6 100644 --- a/gui/baculum/protected/Class/API.php +++ b/gui/baculum/protected/Class/API.php @@ -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 +?> diff --git a/gui/baculum/protected/Class/BaculumPage.php b/gui/baculum/protected/Class/BaculumPage.php index d3bbac8128..1c9bcd3773 100644 --- a/gui/baculum/protected/Class/BaculumPage.php +++ b/gui/baculum/protected/Class/BaculumPage.php @@ -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 +?> diff --git a/gui/baculum/protected/Pages/ConfigurationWizard.php b/gui/baculum/protected/Pages/ConfigurationWizard.php index bcf84ca287..7c0be6720d 100644 --- a/gui/baculum/protected/Pages/ConfigurationWizard.php +++ b/gui/baculum/protected/Pages/ConfigurationWizard.php @@ -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 +?> diff --git a/gui/baculum/themes/Baculum-v1/style.css b/gui/baculum/themes/Baculum-v1/style.css index 56870cb624..bdf99bf8bf 100644 --- a/gui/baculum/themes/Baculum-v1/style.css +++ b/gui/baculum/themes/Baculum-v1/style.css @@ -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; diff --git a/gui/baculum/themes/Baculum-v1/wizard.css b/gui/baculum/themes/Baculum-v1/wizard.css index a9ed56186f..c90a79c9d7 100644 --- a/gui/baculum/themes/Baculum-v1/wizard.css +++ b/gui/baculum/themes/Baculum-v1/wizard.css @@ -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; } @@ -39,44 +39,44 @@ .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; } -- 2.39.5