]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/Requirements.php
Update ReleaseNotes + ChangeLog
[bacula/bacula] / gui / baculum / protected / Pages / Requirements.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2016 Kern Sibbald
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The original author of Bacula is Kern Sibbald, with contributions
10  * from many others, a complete list can be found in the file AUTHORS.
11  *
12  * You may use this file and others of this release according to the
13  * license defined in the LICENSE file, which includes the Affero General
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and
15  * terms pursuant to its AGPLv3 Section 7.
16  *
17  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22  
23 class Requirements {
24         const ASSETS_DIR = 'assets';
25         const DATA_DIR = 'protected/Data';
26         const RUNTIME_DIR = 'protected/runtime';
27
28         public function __construct($baseDir) {
29                 $this->validateEnvironment($baseDir);
30         }
31
32         private function validateEnvironment($baseDir) {
33                 $requirements = array();
34                 if(!is_writable(self::ASSETS_DIR)) {
35                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::ASSETS_DIR . '</b>';
36                 }
37
38                 if(!is_writable(self::DATA_DIR)) {
39                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::DATA_DIR . '</b>';
40                 }
41
42                 if(!is_writable(self::RUNTIME_DIR)) {
43                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::RUNTIME_DIR . '</b>';
44                 }
45
46                 if(!function_exists('curl_init') || !function_exists('curl_setopt') || !function_exists('curl_exec') || !function_exists('curl_close')) {
47                         $requirements[] = 'Please install <b>cURL PHP module</b>.';
48                 }
49
50                 if(!function_exists('bcmul') || !function_exists('bcpow')) {
51                         $requirements[] = 'Please install <b>BCMath PHP module</b>.';
52                 }
53
54                 if(!extension_loaded('pdo_pgsql') && !extension_loaded('pdo_mysql')) {
55                         $requirements[] = 'Please install <b>PDO (PHP Data Objects) PHP module for PostgreSQL or MySQL</b> depending on what database type you are using with Bacula.';
56                 }
57
58                 if(!function_exists('mb_strlen')) {
59                         $requirements[] = 'Please install <b>MB String PHP module</b> for support for multi-byte string handling to PHP.';
60                 }
61
62                 if(!function_exists('json_decode')) {
63                         $requirements[] = 'Please install <b>Module for JSON functions in PHP scripts</b>.';
64                 }
65
66                 if(!class_exists('DOMDocument')) {
67                         $requirements[] = 'Please install <b>PHP DOM XML</b> to support XML documents (usually included in php-xml binary package).';
68                 }
69
70                 if(count($requirements) > 0) {
71                         echo '<html><body><h2>Baculum - Missing dependencies</h2><ul>';
72                         for($i = 0; $i < count($requirements); $i++) {
73                                 echo '<li>' . $requirements[$i] . '</li>';
74                                 
75                         }
76                         echo '</ul>';
77                         echo 'For run Baculum <u>please correct above requirements</u> and refresh this page in web browser.';
78                         echo '</body></html>';
79                         exit();
80                 }
81         }
82 }
83 ?>