Requires: php >= 5.3.4
Requires: php-bcmath
Requires: php-common
-Requires: php-mbstring
Requires: php-mysqlnd
Requires: php-pdo
Requires: php-pgsql
Requires: php-common
Requires: php-json
Requires: php-bcmath
-Requires: php-mbstring
Requires: php-xml
%description web
Requires: php >= 5.3.4
Requires: php-bcmath
Requires: php-common
-Requires: php-mbstring
Requires: php-mysqlnd
Requires: php-pdo
Requires: php-pgsql
Requires: php-common
Requires: php-json
Requires: php-bcmath
-Requires: php-mbstring
Requires: php-xml
%description web
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
session_start();
+Prado::using('Application.API.Pages.Requirements');
Prado::using('Application.Common.Class.BaculumPage');
Prado::using('Application.API.Class.APIConfig');
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('Application.Common.Class.GeneralRequirements');
+
+/**
+ * API part requirements class.
+ */
+class Requirements extends GeneralRequirements {
+
+ /**
+ * Required PHP extensions.
+ *
+ * Note, requirements page is visible before any language is set and before
+ * translation engine initialization. From this reason all messages are not
+ * translated.
+ */
+ private $req_exts = array(
+ array(
+ 'ext' => 'bcmath',
+ 'help_msg' => 'Please install <b>PHP BCMath module</b>.'
+ )
+ );
+
+ public function __construct($app_dir, $base_dir) {
+ parent::__construct($app_dir, $base_dir);
+ $this->validateEnvironment();
+ parent::showResult('Baculum API');
+ }
+
+ /**
+ * Validate all API environment depenencies.
+ *
+ * @return none
+ */
+ public function validateEnvironment() {
+ parent::validateExtensions($this->req_exts);
+ }
+}
+$service_dir = dirname(__DIR__);
+new Requirements(APPLICATION_DIRECTORY, $service_dir);
+?>
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+/**
+ * General requirement class with common dependencies both for API and Web.
+ */
+abstract class GeneralRequirements {
+
+ /**
+ * Required PHP extensions.
+ *
+ * Note, requirements page is visible before any language is set and before
+ * translation engine initialization. From this reason all messages are not
+ * translated.
+ */
+ private $req_exts = array(
+ array(
+ 'ext' => 'json',
+ 'help_msg' => 'Please install <b>PHP JSON module</b>.'
+ ),
+ array(
+ 'ext' => 'dom',
+ 'help_msg' => 'Please install <b>PHP DOM module</b> to support XML documents (usually included in php-xml binary package).'
+ )
+ );
+
+ /**
+ * Required read/write access for these application directories.
+ */
+ private $req_app_rw_dirs = array(
+ 'assets', 'protected/runtime',
+ );
+
+ /**
+ * Required read/wrie access for these directories in base directory.
+ */
+ private $req_base_rw_dirs = array(
+ 'Config', 'Logs',
+ );
+
+ /**
+ * Generic help message for directories without fulfilled dependencies.
+ */
+ const DIR_HELP_MSG = 'Please make readable and writeable by the web server user the following directory: <b>%s</b>';
+
+ /**
+ * This static variable stores all dependency messages to show on the page.
+ * If empty, dependencies are fulfilled.
+ */
+ protected static $requirements = array();
+
+ public function __construct($app_dir, $base_dir) {
+ $this->validateEnvironment($app_dir, $base_dir);
+ }
+
+ /**
+ * Validate all environment depenencies.
+ *
+ * @param string $app_dir full path to main application directory
+ * @param string $base_dir full path to service specific base directory
+ * @return none
+ */
+ private function validateEnvironment($app_dir, $base_dir) {
+ $this->validateDirectories($app_dir, $base_dir);
+ $this->validateExtensions($this->req_exts);
+ }
+
+ /**
+ * Validate directory access depenencies.
+ *
+ * @param string $app_dir full path to main application directory
+ * @param string $base_dir full path to service specific base directory
+ * @return none
+ */
+ private function validateDirectories($app_dir, $base_dir) {
+ for ($i = 0; $i < count($this->req_app_rw_dirs); $i++) {
+ $dir = $app_dir . '/' . $this->req_app_rw_dirs[$i];
+ if (is_readable($dir) && is_writeable($dir)) {
+ // test passed, skip
+ continue;
+ }
+ self::$requirements[] = sprintf(self::DIR_HELP_MSG, $dir);
+ }
+ for ($i = 0; $i < count($this->req_base_rw_dirs); $i++) {
+ $dir = $base_dir . '/' . $this->req_base_rw_dirs[$i];
+ if (is_readable($dir) && is_writeable($dir)) {
+ // test passed, skip
+ continue;
+ }
+ self::$requirements[] = sprintf(self::DIR_HELP_MSG, $dir);
+ }
+ }
+
+ /**
+ * Validate PHP extensions.
+ *
+ * @param array $req_exts extension list
+ * @return none
+ */
+ protected static function validateExtensions($req_exts) {
+ for ($i = 0; $i < count($req_exts); $i++) {
+ if (!extension_loaded($req_exts[$i]['ext'])) {
+ self::$requirements[] = $req_exts[$i]['help_msg'];
+ }
+ }
+ }
+
+ /**
+ * Simple method to show results.
+ *
+ * @param string $product product name ('Baculum Web' or 'Baculum API'...etc.)
+ * @return none
+ */
+ protected static function showResult($product) {
+ if (count(self::$requirements) > 0) {
+ echo '<html><body><h2>' . $product . ' - Missing dependencies</h2><ul>';
+ for ($i = 0; $i < count(self::$requirements); $i++) {
+ echo '<li>' . self::$requirements[$i] . '</li>';
+ }
+ echo '</ul>';
+ echo 'To run ' . $product . ' <u>please correct above requirements</u> and refresh this page in web browser.';
+ echo '</body></html>';
+ exit();
+ }
+ }
+}
+?>
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
session_start();
+Prado::using('Application.Web.Pages.Requirements');
Prado::using('Application.Common.Class.BaculumPage');
Prado::using('Application.Web.Init');
Prado::using('Application.Web.Class.WebConfig');
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
// 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('Pages/Requirements.php');
-$service_dir = __DIR__;
-new Requirements(APPLICATION_DIRECTORY, $service_dir);
-
?>
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
*
* Bacula(R) is a registered trademark of Kern Sibbald.
*/
-
-class Requirements {
- const ASSETS_DIR = 'assets';
- const CONFIG_DIR = 'Config';
- const LOG_DIR = 'Logs';
- const RUNTIME_DIR = 'protected/runtime';
- public function __construct($app_dir, $base_dir) {
- $app_dir .= '/';
- $base_dir .= '/';
- $this->validateEnvironment($app_dir, $base_dir);
- }
-
- private function validateEnvironment($app_dir, $base_dir) {
- $requirements = array();
- $assets_dir = $app_dir . self::ASSETS_DIR;
- if(!is_writable(self::ASSETS_DIR)) {
- $requirements[] = 'Please make writable by the web server next directory: <b>' . $assets_dir . '</b>';
- }
-
- $config_dir = $base_dir . self::CONFIG_DIR;
- if(!is_writable($config_dir)) {
- $requirements[] = 'Please make writable by the web server next directory: <b>' . $config_dir . '</b>';
- }
-
- $log_dir = $base_dir . self::LOG_DIR;
- if(!is_writable($log_dir)) {
- $requirements[] = 'Please make writable by the web server next directory: <b>' . $log_dir . '</b>';
- }
-
- $runtime_dir = $app_dir . self::RUNTIME_DIR;
- if(!is_writable($runtime_dir)) {
- $requirements[] = 'Please make writable by the web server next directory: <b>' . $runtime_dir . '</b>';
- }
-
- if(!function_exists('curl_init') || !function_exists('curl_setopt') || !function_exists('curl_exec') || !function_exists('curl_close')) {
- $requirements[] = 'Please install <b>cURL PHP module</b>.';
- }
+Prado::using('Application.Common.Class.GeneralRequirements');
- if(!function_exists('bcmul') || !function_exists('bcpow')) {
- $requirements[] = 'Please install <b>BCMath PHP module</b>.';
- }
-
- if(!function_exists('mb_strlen')) {
- $requirements[] = 'Please install <b>MB String PHP module</b> for support for multi-byte string handling to PHP.';
- }
-
- if(!function_exists('json_decode')) {
- $requirements[] = 'Please install <b>Module for JSON functions in PHP scripts</b>.';
- }
+/**
+ * Web part requirements class.
+ */
+class Requirements extends GeneralRequirements {
+
+ /**
+ * Required PHP extensions.
+ *
+ * Note, requirements page is visible before any language is set and before
+ * translation engine initialization. From this reason all messages are not
+ * translated.
+ */
+ private $req_exts = array(
+ array(
+ 'ext' => 'curl',
+ 'help_msg' => 'Please install <b>PHP cURL module</b>.'
+ )
+ );
- if(!class_exists('DOMDocument')) {
- $requirements[] = 'Please install <b>PHP DOM XML</b> to support XML documents (usually included in php-xml binary package).';
- }
+ public function __construct($app_dir, $base_dir) {
+ parent::__construct($app_dir, $base_dir);
+ $this->validateEnvironment();
+ parent::showResult('Baculum Web');
+ }
- if(count($requirements) > 0) {
- echo '<html><body><h2>Baculum - Missing dependencies</h2><ul>';
- for($i = 0; $i < count($requirements); $i++) {
- echo '<li>' . $requirements[$i] . '</li>';
-
- }
- echo '</ul>';
- echo 'To run Baculum <u>please correct above requirements</u> and refresh this page in web browser.';
- echo '</body></html>';
- exit();
- }
+ /**
+ * Validate all Web environment depenencies.
+ *
+ * @return none
+ */
+ public function validateEnvironment() {
+ parent::validateExtensions($this->req_exts);
}
}
+
+// Check requirements and if are some needed then show requirements page
+$service_dir = dirname(__DIR__);
+new Requirements(APPLICATION_DIRECTORY, $service_dir);
?>