This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
/
global.php
179 lines (153 loc) · 5.97 KB
/
global.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2015 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Global Configuration Override
*
* You can use this file for overriding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/
$file = "/etc/bareos-webui/directors.ini";
$config = null;
if(!file_exists($file)) {
echo "Error: Missing configuration file ".$file.".";
exit();
}
else {
$config = parse_ini_file($file, true, INI_SCANNER_NORMAL);
}
function read_dir_config($config, $file)
{
$arr = array();
foreach($config as $instance) {
if(array_key_exists('enabled', $instance) && isset($instance['enabled']) && strtolower($instance['enabled']) == "yes") {
if(array_key_exists('diraddress', $instance) && isset($instance['diraddress'])) {
$arr[key($config)] = array();
$arr[key($config)]['host'] = $instance['diraddress'];
}
else {
echo "Error: Missing parameter 'diraddress' in ".$file.", section ".key($config).".";
exit();
}
if(array_key_exists('dirport', $instance) && isset($instance['dirport'])) {
$arr[key($config)]['port'] = $instance['dirport'];
}
else {
$arr[key($config)]['port'] = 9101;
}
if(array_key_exists('tls_verify_peer', $instance) && isset($instance['tls_verify_peer'])) {
$arr[key($config)]['tls_verify_peer'] = $instance['tls_verify_peer'];
}
else {
$arr[key($config)]['tls_verify_peer'] = false;
}
if(array_key_exists('server_can_do_tls', $instance) && isset($instance['server_can_do_tls'])) {
$arr[key($config)]['server_can_do_tls'] = $instance['server_can_do_tls'];
}
else {
}
if(array_key_exists('server_requires_tls', $instance) && isset($instance['server_requires_tls'])) {
$arr[key($config)]['server_requires_tls'] = $instance['server_requires_tls'];
}
else {
$arr[key($config)]['server_requires_tls'] = false;
}
if(array_key_exists('client_can_do_tls', $instance) && isset($instance['client_can_do_tls'])) {
$arr[key($config)]['client_can_do_tls'] = $instance['client_can_do_tls'];
}
else {
$arr[key($config)]['client_can_do_tls'] = false;
}
if(array_key_exists('client_requires_tls', $instance) && isset($instance['client_requires_tls'])) {
$arr[key($config)]['client_requires_tls'] = $instance['client_requires_tls'];
}
else {
$arr[key($config)]['client_requires_tls'] = false;
}
if(array_key_exists('ca_file', $instance) && isset($instance['ca_file'])) {
$arr[key($config)]['ca_file'] = $instance['ca_file'];
}
else {
$arr[key($config)]['ca_file'] = "";
}
if(array_key_exists('cert_file', $instance) && isset($instance['cert_file'])) {
$arr[key($config)]['cert_file'] = $instance['cert_file'];
}
else {
$arr[key($config)]['cert_file'] = "";
}
if(array_key_exists('cert_file_passphrase', $instance) && isset($instance['cert_file_passphrase'])) {
$arr[key($config)]['cert_file_passphrase'] = $instance['cert_file_passphrase'];
}
else {
$arr[key($config)]['cert_file_passphrase'] = "";
}
if(array_key_exists('allowed_cns', $instance) && isset($instance['allowed_cns'])) {
$arr[key($config)]['allowed_cns'] = $instance['allowed_cns'];
}
else {
$arr[key($config)]['allowed_cns'] = "";
}
}
next($config);
}
return $arr;
}
return array(
'directors' => read_dir_config($config, $file),
'service_manager' => array(
'factories' => array(
'Zend\Session\Config\ConfigInterface' => 'Zend\Session\Service\SessionConfigFactory',
//'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
'abstract_factories' => array(
// to allow other adapters to be called by $sm->get('adaptername')
//'Zend\Db\Adapter\AdapterAbstractServiceFactory',
),
),
'session' => array(
'config' => array(
'class' => 'Zend\Session\Config\SessionConfig',
'options' => array(
'name' => 'bareos',
'use_cookies' => true,
'cookie_lifetime' => '0', // to reset lifetime to maximum at every click
'gc_maxlifetime' => '3600',
'cache_expire' => 3600,
'remember_me_seconds' => 3600,
'use_cookies' => true
),
),
'storage' => 'Zend\Session\Storage\SessionArrayStorage',
'validators' => array(
'Zend\Session\Validator\RemoteAddr',
'Zend\Session\Validator\HttpUserAgent',
),
),
);