]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/Requirements.php
baculum: Update copyright dates
[bacula/bacula] / gui / baculum / protected / Pages / Requirements.php
1 <?php
2 /**
3  * Bacula® - The Network Backup Solution
4  * Baculum - Bacula web interface
5  *
6  * Copyright (C) 2013-2015 Marcin Haba
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The main author of Bacula is Kern Sibbald, with contributions from many
10  * 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  * Bacula® is a registered trademark of Kern Sibbald.
18  */
19  
20 class Requirements {
21         const ASSETS_DIR = 'assets';
22         const DATA_DIR = 'protected/Data';
23         const RUNTIME_DIR = 'protected/runtime';
24
25         public function __construct($baseDir) {
26                 $this->validateEnvironment($baseDir);
27         }
28
29         private function validateEnvironment($baseDir) {
30                 $requirements = array();
31                 if(!is_writable(self::ASSETS_DIR)) {
32                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::ASSETS_DIR . '</b>';
33                 }
34
35                 if(!is_writable(self::DATA_DIR)) {
36                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::DATA_DIR . '</b>';
37                 }
38
39                 if(!is_writable(self::RUNTIME_DIR)) {
40                         $requirements[] = 'Please make writable by the web server next directory: <b>' . $baseDir . '/' . self::RUNTIME_DIR . '</b>';
41                 }
42
43                 if(!function_exists('curl_init') || !function_exists('curl_setopt') || !function_exists('curl_exec') || !function_exists('curl_close')) {
44                         $requirements[] = 'Please install <b>cURL PHP module</b>.';
45                 }
46
47                 if(!function_exists('bcmul') || !function_exists('bcpow')) {
48                         $requirements[] = 'Please install <b>BCMath PHP module</b>.';
49                 }
50
51                 if(!extension_loaded('pdo_pgsql') && !extension_loaded('pdo_mysql')) {
52                         $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.';
53                 }
54
55                 if(!function_exists('mb_strlen')) {
56                         $requirements[] = 'Please install <b>MB String PHP module</b> for support for multi-byte string handling to PHP.';
57                 }
58
59                 if(!function_exists('json_decode')) {
60                         $requirements[] = 'Please install <b>Module for JSON functions in PHP scripts</b>.';
61                 }
62
63                 if(count($requirements) > 0) {
64                         echo '<html><body><h2>Baculum - Missing dependencies</h2><ul>';
65                         for($i = 0; $i < count($requirements); $i++) {
66                                 echo '<li>' . $requirements[$i] . '</li>';
67                                 
68                         }
69                         echo '</ul>';
70                         echo 'For run Baculum <u>please correct above requirements</u> and refresh this page in web browser.';
71                         echo '</body></html>';
72                         exit();
73                 }
74         }
75 }
76 ?>