1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \AppserverIo\Server\Configuration\ServerXmlConfiguration |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Johann Zelger <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/server |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Server\Configuration; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Server\Interfaces\ServerConfigurationInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class ServerXmlConfiguration |
27
|
|
|
* |
28
|
|
|
* @author Johann Zelger <[email protected]> |
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/appserver-io/server |
32
|
|
|
* @link http://www.appserver.io |
33
|
|
|
*/ |
34
|
|
|
class ServerXmlConfiguration implements ServerConfigurationInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* The configured rewrite rules |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $rewrites; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The configured locations. |
45
|
|
|
* |
46
|
|
|
* @var array |
47
|
|
|
*/ |
48
|
|
|
protected $locations; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The configured headers |
52
|
|
|
* |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $headers; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Holds the environmentVariables array |
59
|
|
|
* |
60
|
|
|
* @var array |
61
|
|
|
*/ |
62
|
|
|
protected $environmentVariables = array(); |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Constructs config |
66
|
|
|
* |
67
|
|
|
* @param \SimpleXMLElement $node The simple xml element used to build config |
68
|
|
|
*/ |
69
|
|
|
public function __construct($node) |
70
|
|
|
{ |
71
|
|
|
// prepare properties |
72
|
|
|
$this->name = (string)$node->attributes()->name; |
|
|
|
|
73
|
|
|
$this->type = (string)$node->attributes()->type; |
|
|
|
|
74
|
|
|
$this->workerType = (string)$node->attributes()->worker; |
|
|
|
|
75
|
|
|
$this->socketType = (string)$node->attributes()->socket; |
|
|
|
|
76
|
|
|
$this->streamContextType = (string)$node->attributes()->streamContext; |
|
|
|
|
77
|
|
|
$this->serverContextType = (string)$node->attributes()->serverContext; |
|
|
|
|
78
|
|
|
$this->requestContextType = (string)$node->attributes()->requestContext; |
|
|
|
|
79
|
|
|
$this->loggerName = (string)$node->attributes()->loggerName; |
|
|
|
|
80
|
|
|
$this->transport = (string)array_shift($node->xpath("./params/param[@name='transport']")); |
|
|
|
|
81
|
|
|
$this->address = (string)array_shift($node->xpath("./params/param[@name='address']")); |
|
|
|
|
82
|
|
|
$this->port = (int)array_shift($node->xpath("./params/param[@name='port']")); |
|
|
|
|
83
|
|
|
$this->flags = (string)array_shift($node->xpath("./params/param[@name='flags']")); |
|
|
|
|
84
|
|
|
$this->software = (string)array_shift($node->xpath("./params/param[@name='software']")); |
|
|
|
|
85
|
|
|
$this->workerNumber = (int)array_shift($node->xpath("./params/param[@name='workerNumber']")); |
|
|
|
|
86
|
|
|
$this->workerAcceptMin = (int)array_shift($node->xpath("./params/param[@name='workerAcceptMin']")); |
|
|
|
|
87
|
|
|
$this->workerAcceptMax = (int)array_shift($node->xpath("./params/param[@name='workerAcceptMax']")); |
|
|
|
|
88
|
|
|
$this->certPath = (string)array_shift($node->xpath("./params/param[@name='certPath']")); |
|
|
|
|
89
|
|
|
$this->passphrase = (string)array_shift($node->xpath("./params/param[@name='passphrase']")); |
|
|
|
|
90
|
|
|
$this->documentRoot = (string)array_shift($node->xpath("./params/param[@name='documentRoot']")); |
|
|
|
|
91
|
|
|
$this->directoryIndex = (string)array_shift($node->xpath("./params/param[@name='directoryIndex']")); |
|
|
|
|
92
|
|
|
$this->admin = (string)array_shift($node->xpath("./params/param[@name='admin']")); |
|
|
|
|
93
|
|
|
$this->keepAliveMax = (string)array_shift($node->xpath("./params/param[@name='keepAliveMax']")); |
|
|
|
|
94
|
|
|
$this->keepAliveTimeout = (string)array_shift($node->xpath("./params/param[@name='keepAliveTimeout']")); |
|
|
|
|
95
|
|
|
$this->autoIndex = (boolean)array_shift($node->xpath("./params/param[@name='autoIndex']")); |
|
|
|
|
96
|
|
|
$this->errorsPageTemplatePath = (string)array_shift($node->xpath("./params/param[@name='errorsPageTemplatePath']")); |
|
|
|
|
97
|
|
|
$this->welcomePageTemplatePath = (string)array_shift($node->xpath("./params/param[@name='welcomePageTemplatePath']")); |
|
|
|
|
98
|
|
|
$this->autoIndexTemplatePath = (string)array_shift($node->xpath("./params/param[@name='autoIndexTemplatePath']")); |
|
|
|
|
99
|
|
|
$this->dhParamPath = (string)array_shift($node->xpath("./params/param[@name='dhParamPath']")); |
|
|
|
|
100
|
|
|
$this->privateKeyPath = (string)array_shift($node->xpath("./params/param[@name='privateKeyPath']")); |
|
|
|
|
101
|
|
|
$this->cryptoMethod = (string)array_shift($node->xpath("./params/param[@name='cryptoMethod']")); |
|
|
|
|
102
|
|
|
$this->peerName = (string)array_shift($node->xpath("./params/param[@name='peerName']")); |
|
|
|
|
103
|
|
|
$this->verifyPeer = (boolean)array_shift($node->xpath("./params/param[@name='verifyPeer']")); |
|
|
|
|
104
|
|
|
$this->verifyPeerName = (boolean)array_shift($node->xpath("./params/param[@name='verifyPeerName']")); |
|
|
|
|
105
|
|
|
$this->disableCompression = (boolean)array_shift($node->xpath("./params/param[@name='disableCompression']")); |
|
|
|
|
106
|
|
|
$this->allowSelfSigned = (boolean)array_shift($node->xpath("./params/param[@name='allowSelfSigned']")); |
|
|
|
|
107
|
|
|
$this->honorCipherOrder = (boolean)array_shift($node->xpath("./params/param[@name='honorCipherOrder']")); |
|
|
|
|
108
|
|
|
$this->ecdhCurve = (string)array_shift($node->xpath("./params/param[@name='ecdhCurve']")); |
|
|
|
|
109
|
|
|
$this->singleEcdhUse = (boolean)array_shift($node->xpath("./params/param[@name='singleEcdhUse']")); |
|
|
|
|
110
|
|
|
$this->singleDhUse = (boolean)array_shift($node->xpath("./params/param[@name='singleDhUse']")); |
|
|
|
|
111
|
|
|
|
112
|
|
|
// prepare analytics |
113
|
|
|
$this->analytics = $this->prepareAnalytics($node); |
|
|
|
|
114
|
|
|
// prepare modules |
115
|
|
|
$this->headers = $this->prepareHeaders($node); |
116
|
|
|
// prepare modules |
117
|
|
|
$this->modules = $this->prepareModules($node); |
|
|
|
|
118
|
|
|
// prepare connection handlers |
119
|
|
|
$this->connectionHandlers = $this->prepareConnectionHandlers($node); |
|
|
|
|
120
|
|
|
// prepare handlers |
121
|
|
|
$this->handlers = $this->prepareHandlers($node); |
|
|
|
|
122
|
|
|
// prepare virutalHosts |
123
|
|
|
$this->virtualHosts = $this->prepareVirtualHosts($node); |
|
|
|
|
124
|
|
|
// prepare rewrites |
125
|
|
|
$this->rewrites = $this->prepareRewrites($node); |
126
|
|
|
// prepare environmentVariables |
127
|
|
|
$this->environmentVariables = $this->prepareEnvironmentVariables($node); |
128
|
|
|
// prepare authentications |
129
|
|
|
$this->authentications = $this->prepareAuthentications($node); |
|
|
|
|
130
|
|
|
// prepare accesses |
131
|
|
|
$this->accesses = $this->prepareAccesses($node); |
|
|
|
|
132
|
|
|
// prepare locations |
133
|
|
|
$this->locations = $this->prepareLocations($node); |
134
|
|
|
// prepare rewrite maps |
135
|
|
|
$this->rewriteMaps = $this->prepareRewriteMaps($node); |
|
|
|
|
136
|
|
|
// prepare certificates |
137
|
|
|
$this->certificates = $this->prepareCertificates($node); |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Prepares the headers array based on a simple xml element node |
142
|
|
|
* |
143
|
|
|
* @param \SimpleXMLElement $node The xml node |
144
|
|
|
* |
145
|
|
|
* @return array |
146
|
|
|
*/ |
147
|
|
|
public function prepareHeaders(\SimpleXMLElement $node) |
148
|
|
|
{ |
149
|
|
|
$headers = array(); |
150
|
|
|
if ($node->headers) { |
151
|
|
|
foreach ($node->headers->header as $headerNode) { |
152
|
|
|
// Cut of the SimpleXML attributes wrapper and attach it to our headers |
153
|
|
|
$override = false; |
154
|
|
|
$overrideAttribute = strtolower((string)$headerNode->attributes()->override); |
155
|
|
|
if ($overrideAttribute && $overrideAttribute === 'true') { |
156
|
|
|
$override = true; |
157
|
|
|
} |
158
|
|
|
$append = false; |
159
|
|
|
$appendAttribute = strtolower((string)$headerNode->attributes()->append); |
160
|
|
|
if ($appendAttribute && $appendAttribute === 'true') { |
161
|
|
|
$append = true; |
162
|
|
|
} |
163
|
|
|
$header = array( |
164
|
|
|
'type' => (string) $headerNode->attributes()->type, |
165
|
|
|
'name' => (string) $headerNode->attributes()->name, |
166
|
|
|
'value' => (string) $headerNode->attributes()->value, |
167
|
|
|
'uri' => (string) $headerNode->attributes()->uri, |
168
|
|
|
'override' => $override, |
169
|
|
|
'append' => $append |
170
|
|
|
); |
171
|
|
|
$headers[(string) $headerNode->attributes()->type][] = $header; |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
return $headers; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Prepares the modules array based on a simple xml element node |
179
|
|
|
* |
180
|
|
|
* @param \SimpleXMLElement $node The xml node |
181
|
|
|
* |
182
|
|
|
* @return array |
183
|
|
|
*/ |
184
|
|
|
public function prepareModules(\SimpleXMLElement $node) |
185
|
|
|
{ |
186
|
|
|
$modules = array(); |
187
|
|
|
if ($node->modules) { |
188
|
|
|
foreach ($node->modules->module as $moduleNode) { |
189
|
|
|
$modules[] = new ModuleXmlConfiguration($moduleNode); |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
return $modules; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Prepares the connectionHandlers array based on a simple xml element node |
197
|
|
|
* |
198
|
|
|
* @param \SimpleXMLElement $node The xml node |
199
|
|
|
* |
200
|
|
|
* @return array |
201
|
|
|
*/ |
202
|
|
|
public function prepareConnectionHandlers(\SimpleXMLElement $node) |
203
|
|
|
{ |
204
|
|
|
$connectionHandlers = array(); |
205
|
|
|
if ($node->connectionHandlers) { |
206
|
|
|
foreach ($node->connectionHandlers->connectionHandler as $connectionHandlerNode) { |
207
|
|
|
$connectionHandlerType = (string)$connectionHandlerNode->attributes()->type; |
208
|
|
|
$connectionHandlers[] = $connectionHandlerType; |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
return $connectionHandlers; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Prepares the handlers array based on a simple xml element node |
216
|
|
|
* |
217
|
|
|
* @param \SimpleXMLElement $node The xml node |
218
|
|
|
* |
219
|
|
|
* @return array |
220
|
|
|
*/ |
221
|
|
|
public function prepareHandlers(\SimpleXMLElement $node) |
222
|
|
|
{ |
223
|
|
|
$handlers = array(); |
224
|
|
|
if ($node->handlers) { |
225
|
|
View Code Duplication |
foreach ($node->handlers->handler as $handlerNode) { |
|
|
|
|
226
|
|
|
$params = array(); |
227
|
|
|
if ($handlerNode->params->param) { |
228
|
|
|
foreach ($handlerNode->params->param as $paramNode) { |
229
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
230
|
|
|
$params[$paramName] = (string)array_shift($handlerNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
$handlers[(string)$handlerNode->attributes()->extension] = array( |
234
|
|
|
'name' => (string)$handlerNode->attributes()->name, |
235
|
|
|
'params' => $params |
236
|
|
|
); |
237
|
|
|
} |
238
|
|
|
} |
239
|
|
|
return $handlers; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Prepares the virtual hosts array based on a simple xml element node |
244
|
|
|
* |
245
|
|
|
* @param \SimpleXMLElement $node The xml node |
246
|
|
|
* |
247
|
|
|
* @return array |
248
|
|
|
*/ |
249
|
|
|
public function prepareVirtualHosts(\SimpleXMLElement $node) |
250
|
|
|
{ |
251
|
|
|
$virutalHosts = array(); |
252
|
|
|
if ($node->virtualHosts) { |
253
|
|
|
foreach ($node->virtualHosts->virtualHost as $virtualHostNode) { |
254
|
|
|
$virtualHostNames = explode(' ', (string)$virtualHostNode->attributes()->name); |
255
|
|
|
$params = array(); |
256
|
|
|
foreach ($virtualHostNode->params->param as $paramNode) { |
257
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
258
|
|
|
$params[$paramName] = (string)array_shift($virtualHostNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
259
|
|
|
} |
260
|
|
View Code Duplication |
foreach ($virtualHostNames as $virtualHostName) { |
|
|
|
|
261
|
|
|
// set all virtual hosts params per key for faster matching later on |
262
|
|
|
$virutalHosts[trim($virtualHostName)] = array( |
263
|
|
|
'params' => $params, |
264
|
|
|
'headers' => $this->prepareHeaders($virtualHostNode), |
265
|
|
|
'rewriteMaps' => $this->prepareRewriteMaps($virtualHostNode), |
266
|
|
|
'rewrites' => $this->prepareRewrites($virtualHostNode), |
267
|
|
|
'locations' => $this->prepareLocations($virtualHostNode), |
268
|
|
|
'environmentVariables' => $this->prepareEnvironmentVariables($virtualHostNode), |
269
|
|
|
'authentications' => $this->prepareAuthentications($virtualHostNode), |
270
|
|
|
'accesses' => $this->prepareAccesses($virtualHostNode), |
271
|
|
|
'analytics' => $this->prepareAnalytics($virtualHostNode) |
272
|
|
|
); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
return $virutalHosts; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* Prepares the rewrite maps based on a simple xml element node |
281
|
|
|
* |
282
|
|
|
* @param \SimpleXMLElement $node The xml node |
283
|
|
|
* |
284
|
|
|
* @return array |
285
|
|
|
*/ |
286
|
|
View Code Duplication |
public function prepareRewriteMaps(\SimpleXMLElement $node) |
|
|
|
|
287
|
|
|
{ |
288
|
|
|
$rewriteMaps = array(); |
289
|
|
|
if ($node->rewriteMaps) { |
290
|
|
|
foreach ($node->rewriteMaps->rewriteMap as $rewriteMapNode) { |
291
|
|
|
$rewriteMapType = (string)$rewriteMapNode->attributes()->type; |
292
|
|
|
$params = array(); |
293
|
|
|
foreach ($rewriteMapNode->params->param as $paramNode) { |
294
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
295
|
|
|
$params[$paramName] = (string)array_shift($rewriteMapNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
296
|
|
|
} |
297
|
|
|
$rewriteMaps[$rewriteMapType] = $params; |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
return $rewriteMaps; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Prepares the rewrites array based on a simple xml element node |
305
|
|
|
* |
306
|
|
|
* @param \SimpleXMLElement $node The xml node |
307
|
|
|
* |
308
|
|
|
* @return array |
309
|
|
|
*/ |
310
|
|
|
public function prepareRewrites(\SimpleXMLElement $node) |
311
|
|
|
{ |
312
|
|
|
$rewrites = array(); |
313
|
|
|
if ($node->rewrites) { |
314
|
|
|
foreach ($node->rewrites->rewrite as $rewriteNode) { |
315
|
|
|
// Cut of the SimpleXML attributes wrapper and attach it to our rewrites |
316
|
|
|
$rewrite = (array)$rewriteNode; |
317
|
|
|
$rewrites[] = array_shift($rewrite); |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
return $rewrites; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Prepares the certificates array based on a simple xml element node |
325
|
|
|
* |
326
|
|
|
* @param \SimpleXMLElement $node The xml node |
327
|
|
|
* |
328
|
|
|
* @return array |
329
|
|
|
*/ |
330
|
|
|
public function prepareCertificates(\SimpleXMLElement $node) |
331
|
|
|
{ |
332
|
|
|
$certificates = array(); |
333
|
|
|
if ($node->certificates) { |
334
|
|
|
foreach ($node->certificates->certificate as $certificateNode) { |
335
|
|
|
// Cut of the SimpleXML attributes wrapper and attach it to our locations |
336
|
|
|
$certificate = array( |
337
|
|
|
'domain' => (string) $certificateNode->attributes()->domain, |
338
|
|
|
'certPath' => (string) $certificateNode->attributes()->certPath |
339
|
|
|
); |
340
|
|
|
$certificates[] = $certificate; |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
return $certificates; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Prepares the locations array based on a simple xml element node |
348
|
|
|
* |
349
|
|
|
* @param \SimpleXMLElement $node The xml node |
350
|
|
|
* |
351
|
|
|
* @return array |
352
|
|
|
*/ |
353
|
|
|
public function prepareLocations(\SimpleXMLElement $node) |
354
|
|
|
{ |
355
|
|
|
$locations = array(); |
356
|
|
|
if ($node->locations) { |
357
|
|
|
foreach ($node->locations->location as $locationNode) { |
358
|
|
|
// Cut of the SimpleXML attributes wrapper and attach it to our locations |
359
|
|
|
$location = array( |
360
|
|
|
'condition' => (string) $locationNode->attributes()->condition, |
361
|
|
|
'handlers' => $this->prepareHandlers($locationNode), |
362
|
|
|
'headers' => $this->prepareHeaders($locationNode), |
363
|
|
|
); |
364
|
|
|
$locations[] = $location; |
365
|
|
|
} |
366
|
|
|
} |
367
|
|
|
return $locations; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Prepares the environmentVariables array based on a simple xml element node |
372
|
|
|
* |
373
|
|
|
* @param \SimpleXMLElement $node The xml node |
374
|
|
|
* |
375
|
|
|
* @return array |
376
|
|
|
*/ |
377
|
|
|
public function prepareEnvironmentVariables(\SimpleXMLElement $node) |
378
|
|
|
{ |
379
|
|
|
$environmentVariables = array(); |
380
|
|
|
if ($node->environmentVariables) { |
381
|
|
|
foreach ($node->environmentVariables->environmentVariable as $environmentVariableNode) { |
382
|
|
|
// Cut of the SimpleXML attributes wrapper and attach it to our environment variable |
383
|
|
|
$environmentVariable = (array)$environmentVariableNode; |
384
|
|
|
$environmentVariables[] = array_shift($environmentVariable); |
385
|
|
|
} |
386
|
|
|
} |
387
|
|
|
return $environmentVariables; |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
/** |
391
|
|
|
* Prepares the authentications array based on a simple xml element node |
392
|
|
|
* |
393
|
|
|
* @param \SimpleXMLElement $node The xml node |
394
|
|
|
* |
395
|
|
|
* @return array |
396
|
|
|
*/ |
397
|
|
View Code Duplication |
public function prepareAuthentications(\SimpleXMLElement $node) |
|
|
|
|
398
|
|
|
{ |
399
|
|
|
$authentications = array(); |
400
|
|
|
if ($node->authentications) { |
401
|
|
|
foreach ($node->authentications->authentication as $authenticationNode) { |
402
|
|
|
$params = array(); |
403
|
|
|
foreach ($authenticationNode->params->param as $paramNode) { |
404
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
405
|
|
|
$params[$paramName] = (string)array_shift($authenticationNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
406
|
|
|
} |
407
|
|
|
$authentications[(string)$authenticationNode->attributes()->uri] = $params; |
408
|
|
|
} |
409
|
|
|
} |
410
|
|
|
return $authentications; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* Prepares the access array based on a simple xml element node |
415
|
|
|
* |
416
|
|
|
* @param \SimpleXMLElement $node The xml node |
417
|
|
|
* |
418
|
|
|
* @return array |
419
|
|
|
*/ |
420
|
|
View Code Duplication |
public function prepareAccesses(\SimpleXMLElement $node) |
|
|
|
|
421
|
|
|
{ |
422
|
|
|
// init accesses |
423
|
|
|
$accesses = array(); |
424
|
|
|
if ($node->accesses) { |
425
|
|
|
foreach ($node->accesses->access as $accessNode) { |
426
|
|
|
$params = array(); |
427
|
|
|
foreach ($accessNode->params->param as $paramNode) { |
428
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
429
|
|
|
$params[$paramName] = (string)array_shift($accessNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
430
|
|
|
} |
431
|
|
|
$accesses[(string)$accessNode->attributes()->type][] = $params; |
432
|
|
|
} |
433
|
|
|
} |
434
|
|
|
return $accesses; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* Prepares the analytics array based on a simple XML element node |
439
|
|
|
* |
440
|
|
|
* @param \SimpleXMLElement $node The XML node |
441
|
|
|
* |
442
|
|
|
* @return array |
443
|
|
|
*/ |
444
|
|
|
public function prepareAnalytics(\SimpleXMLElement $node) |
445
|
|
|
{ |
446
|
|
|
$analytics = array(); |
447
|
|
|
if ($node->analytics) { |
448
|
|
|
foreach ($node->analytics->analytic as $analyticNode) { |
449
|
|
|
$connectors = array(); |
450
|
|
View Code Duplication |
foreach ($analyticNode->connectors->connector as $connectorNode) { |
|
|
|
|
451
|
|
|
// connectors might have params |
452
|
|
|
$params = array(); |
453
|
|
|
if ($connectorNode->params) { |
454
|
|
|
foreach ($connectorNode->params->param as $paramNode) { |
455
|
|
|
$paramName = (string)$paramNode->attributes()->name; |
456
|
|
|
$params[$paramName] = (string)array_shift($connectorNode->xpath(".//param[@name='$paramName']")); |
|
|
|
|
457
|
|
|
} |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
// build up the connectors entry |
461
|
|
|
$connectors[] = array( |
462
|
|
|
'name' => (string)$connectorNode->attributes()->name, |
463
|
|
|
'type' => (string)$connectorNode->attributes()->type, |
464
|
|
|
'params' => $params |
465
|
|
|
); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
// build up the analytics entry |
469
|
|
|
$analytics[] = array( |
470
|
|
|
'uri' => (string)$analyticNode->attributes()->uri, |
471
|
|
|
'connectors' => $connectors |
472
|
|
|
); |
473
|
|
|
} |
474
|
|
|
} |
475
|
|
|
return $analytics; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Return's name |
480
|
|
|
* |
481
|
|
|
* @return string |
482
|
|
|
*/ |
483
|
|
|
public function getName() |
484
|
|
|
{ |
485
|
|
|
return $this->name; |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Return's type |
490
|
|
|
* |
491
|
|
|
* @return string |
492
|
|
|
*/ |
493
|
|
|
public function getType() |
494
|
|
|
{ |
495
|
|
|
return $this->type; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* Return's logger name |
500
|
|
|
* |
501
|
|
|
* @return string |
502
|
|
|
*/ |
503
|
|
|
public function getLoggerName() |
504
|
|
|
{ |
505
|
|
|
return $this->loggerName; |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* Return's transport |
510
|
|
|
* |
511
|
|
|
* @return string |
512
|
|
|
*/ |
513
|
|
|
public function getTransport() |
514
|
|
|
{ |
515
|
|
|
return $this->transport; |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
/** |
519
|
|
|
* Returns rewrites |
520
|
|
|
* |
521
|
|
|
* @return array |
522
|
|
|
*/ |
523
|
|
|
public function getRewrites() |
524
|
|
|
{ |
525
|
|
|
return $this->rewrites; |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* Return's address |
530
|
|
|
* |
531
|
|
|
* @return string |
532
|
|
|
*/ |
533
|
|
|
public function getAddress() |
534
|
|
|
{ |
535
|
|
|
return $this->address; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Return's port |
540
|
|
|
* |
541
|
|
|
* @return int |
542
|
|
|
*/ |
543
|
|
|
public function getPort() |
544
|
|
|
{ |
545
|
|
|
return (int)$this->port; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Return's flags |
550
|
|
|
* |
551
|
|
|
* @return string |
552
|
|
|
*/ |
553
|
|
|
public function getFlags() |
554
|
|
|
{ |
555
|
|
|
return $this->flags; |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Return's software |
560
|
|
|
* |
561
|
|
|
* @return string |
562
|
|
|
*/ |
563
|
|
|
public function getSoftware() |
564
|
|
|
{ |
565
|
|
|
return $this->software; |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* Return's admin |
570
|
|
|
* |
571
|
|
|
* @return string |
572
|
|
|
*/ |
573
|
|
|
public function getAdmin() |
574
|
|
|
{ |
575
|
|
|
return $this->admin; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
/** |
579
|
|
|
* Return's analytics |
580
|
|
|
* |
581
|
|
|
* @return string |
582
|
|
|
*/ |
583
|
|
|
public function getAnalytics() |
584
|
|
|
{ |
585
|
|
|
return $this->analytics; |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
/** |
589
|
|
|
* Return's keep-alive max connection |
590
|
|
|
* |
591
|
|
|
* @return int |
592
|
|
|
*/ |
593
|
|
|
public function getKeepAliveMax() |
594
|
|
|
{ |
595
|
|
|
return (int)$this->keepAliveMax; |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* Return's keep-alive timeout |
600
|
|
|
* |
601
|
|
|
* @return int |
602
|
|
|
*/ |
603
|
|
|
public function getKeepAliveTimeout() |
604
|
|
|
{ |
605
|
|
|
return (int)$this->keepAliveTimeout; |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Return's template path for errors page |
610
|
|
|
* |
611
|
|
|
* @return string |
612
|
|
|
*/ |
613
|
|
|
public function getErrorsPageTemplatePath() |
614
|
|
|
{ |
615
|
|
|
return $this->errorsPageTemplatePath; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Returns template path for possible configured welcome page |
620
|
|
|
* |
621
|
|
|
* @return string |
622
|
|
|
*/ |
623
|
|
|
public function getWelcomePageTemplatePath() |
624
|
|
|
{ |
625
|
|
|
return $this->welcomePageTemplatePath; |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Returns template path for possible configured auto index page |
630
|
|
|
* |
631
|
|
|
* @return string |
632
|
|
|
*/ |
633
|
|
|
public function getAutoIndexTemplatePath() |
634
|
|
|
{ |
635
|
|
|
return $this->autoIndexTemplatePath; |
|
|
|
|
636
|
|
|
} |
637
|
|
|
|
638
|
|
|
/** |
639
|
|
|
* Return's worker number |
640
|
|
|
* |
641
|
|
|
* @return int |
642
|
|
|
*/ |
643
|
|
|
public function getWorkerNumber() |
644
|
|
|
{ |
645
|
|
|
return (int)$this->workerNumber; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* Return's worker's accept min count |
650
|
|
|
* |
651
|
|
|
* @return int |
652
|
|
|
*/ |
653
|
|
|
public function getWorkerAcceptMin() |
654
|
|
|
{ |
655
|
|
|
return (int)$this->workerAcceptMin; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* Return's worker's accept max count |
660
|
|
|
* |
661
|
|
|
* @return int |
662
|
|
|
*/ |
663
|
|
|
public function getWorkerAcceptMax() |
664
|
|
|
{ |
665
|
|
|
return (int)$this->workerAcceptMax; |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* Return's the auto index configuration |
670
|
|
|
* |
671
|
|
|
* @return boolean |
672
|
|
|
*/ |
673
|
|
|
public function getAutoIndex() |
674
|
|
|
{ |
675
|
|
|
return (boolean)$this->autoIndex; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* Return's server context type |
680
|
|
|
* |
681
|
|
|
* @return string |
682
|
|
|
*/ |
683
|
|
|
public function getServerContextType() |
684
|
|
|
{ |
685
|
|
|
return $this->serverContextType; |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
/** |
689
|
|
|
* Returns stream context type |
690
|
|
|
* |
691
|
|
|
* @return string |
692
|
|
|
*/ |
693
|
|
|
public function getStreamContextType() |
694
|
|
|
{ |
695
|
|
|
return $this->streamContextType; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
/** |
699
|
|
|
* Return's server context type |
700
|
|
|
* |
701
|
|
|
* @return string |
702
|
|
|
*/ |
703
|
|
|
public function getRequestContextType() |
704
|
|
|
{ |
705
|
|
|
return $this->requestContextType; |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
/** |
709
|
|
|
* Return's socket type |
710
|
|
|
* |
711
|
|
|
* @return string |
712
|
|
|
*/ |
713
|
|
|
public function getSocketType() |
714
|
|
|
{ |
715
|
|
|
return $this->socketType; |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
/** |
719
|
|
|
* Return's worker type |
720
|
|
|
* |
721
|
|
|
* @return string |
722
|
|
|
*/ |
723
|
|
|
public function getWorkerType() |
724
|
|
|
{ |
725
|
|
|
return $this->workerType; |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
/** |
729
|
|
|
* Return's document root |
730
|
|
|
* |
731
|
|
|
* @return string |
732
|
|
|
*/ |
733
|
|
|
public function getDocumentRoot() |
734
|
|
|
{ |
735
|
|
|
return $this->documentRoot; |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
/** |
739
|
|
|
* Return's directory index definition |
740
|
|
|
* |
741
|
|
|
* @return string |
742
|
|
|
*/ |
743
|
|
|
public function getDirectoryIndex() |
744
|
|
|
{ |
745
|
|
|
return $this->directoryIndex; |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
/** |
749
|
|
|
* Return's the connection handlers |
750
|
|
|
* |
751
|
|
|
* @return array |
752
|
|
|
*/ |
753
|
|
|
public function getConnectionHandlers() |
754
|
|
|
{ |
755
|
|
|
return $this->connectionHandlers; |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
/** |
759
|
|
|
* Returns the headers used by the server |
760
|
|
|
* |
761
|
|
|
* @return array |
762
|
|
|
*/ |
763
|
|
|
public function getHeaders() |
764
|
|
|
{ |
765
|
|
|
return $this->headers; |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
/** |
769
|
|
|
* Returns the certificates used by the server |
770
|
|
|
* |
771
|
|
|
* @return array |
772
|
|
|
*/ |
773
|
|
|
public function getCertificates() |
774
|
|
|
{ |
775
|
|
|
return $this->certificates; |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
/** |
779
|
|
|
* Return's the virtual hosts |
780
|
|
|
* |
781
|
|
|
* @return array |
782
|
|
|
*/ |
783
|
|
|
public function getVirtualHosts() |
784
|
|
|
{ |
785
|
|
|
return $this->virtualHosts; |
786
|
|
|
} |
787
|
|
|
|
788
|
|
|
/** |
789
|
|
|
* Return's the authentication information's |
790
|
|
|
* |
791
|
|
|
* @return array |
792
|
|
|
*/ |
793
|
|
|
public function getAuthentications() |
794
|
|
|
{ |
795
|
|
|
return $this->authentications; |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
/** |
799
|
|
|
* Return's modules |
800
|
|
|
* |
801
|
|
|
* @return array |
802
|
|
|
*/ |
803
|
|
|
public function getModules() |
804
|
|
|
{ |
805
|
|
|
return $this->modules; |
806
|
|
|
} |
807
|
|
|
|
808
|
|
|
/** |
809
|
|
|
* Return's array |
810
|
|
|
* |
811
|
|
|
* @return array |
812
|
|
|
*/ |
813
|
|
|
public function getHandlers() |
814
|
|
|
{ |
815
|
|
|
return $this->handlers; |
|
|
|
|
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
/** |
819
|
|
|
* Return's cert path |
820
|
|
|
* |
821
|
|
|
* @return string |
822
|
|
|
*/ |
823
|
|
|
public function getCertPath() |
824
|
|
|
{ |
825
|
|
|
return $this->certPath; |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
/** |
829
|
|
|
* Return's passphrase |
830
|
|
|
* |
831
|
|
|
* @return string |
832
|
|
|
*/ |
833
|
|
|
public function getPassphrase() |
834
|
|
|
{ |
835
|
|
|
return $this->passphrase; |
836
|
|
|
} |
837
|
|
|
|
838
|
|
|
/** |
839
|
|
|
* Returns the environment variable configuration |
840
|
|
|
* |
841
|
|
|
* @return array |
842
|
|
|
*/ |
843
|
|
|
public function getEnvironmentVariables() |
844
|
|
|
{ |
845
|
|
|
return $this->environmentVariables; |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
/** |
849
|
|
|
* Returns the access configuration. |
850
|
|
|
* |
851
|
|
|
* @return array |
852
|
|
|
*/ |
853
|
|
|
public function getAccesses() |
854
|
|
|
{ |
855
|
|
|
return $this->accesses; |
856
|
|
|
} |
857
|
|
|
|
858
|
|
|
/** |
859
|
|
|
* Returns the locations. |
860
|
|
|
* |
861
|
|
|
* @return array |
862
|
|
|
*/ |
863
|
|
|
public function getLocations() |
864
|
|
|
{ |
865
|
|
|
return $this->locations; |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
/** |
869
|
|
|
* Returns the rewrite maps. |
870
|
|
|
* |
871
|
|
|
* @return array |
872
|
|
|
*/ |
873
|
|
|
public function getRewriteMaps() |
874
|
|
|
{ |
875
|
|
|
return $this->rewriteMaps; |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
/** |
879
|
|
|
* Return's DH param path |
880
|
|
|
* |
881
|
|
|
* @return string |
882
|
|
|
*/ |
883
|
|
|
public function getDhParamPath() |
884
|
|
|
{ |
885
|
|
|
return $this->dhParamPath; |
886
|
|
|
} |
887
|
|
|
|
888
|
|
|
/** |
889
|
|
|
* Return's private key path |
890
|
|
|
* |
891
|
|
|
* @return string |
892
|
|
|
*/ |
893
|
|
|
public function getPrivateKeyPath() |
894
|
|
|
{ |
895
|
|
|
return $this->privateKeyPath; |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
/** |
899
|
|
|
* Return's the crypto method to use |
900
|
|
|
* |
901
|
|
|
* @return string |
902
|
|
|
*/ |
903
|
|
|
public function getCryptoMethod() |
904
|
|
|
{ |
905
|
|
|
return $this->cryptoMethod; |
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
/** |
909
|
|
|
* Return's the peer name to be used, if this value is not set, then the name is guessed based on the hostname used when opening the stream |
910
|
|
|
* |
911
|
|
|
* @return string |
912
|
|
|
*/ |
913
|
|
|
public function getPeerName() |
914
|
|
|
{ |
915
|
|
|
return $this->peerName; |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
/** |
919
|
|
|
* Return's TRUE it the verification of use SSL certificate has to be required |
920
|
|
|
* |
921
|
|
|
* @return boolean |
922
|
|
|
*/ |
923
|
|
|
public function getVerifyPeer() |
924
|
|
|
{ |
925
|
|
|
return $this->verifyPeer; |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
/** |
929
|
|
|
* Return's TRUE it the peer name has to be verified |
930
|
|
|
* |
931
|
|
|
* @return boolean |
932
|
|
|
*/ |
933
|
|
|
public function getVerifyPeerName() |
934
|
|
|
{ |
935
|
|
|
return $this->verifyPeerName; |
|
|
|
|
936
|
|
|
} |
937
|
|
|
|
938
|
|
|
/** |
939
|
|
|
* Return's TRUE to disable TLS compression. This can help mitigate the CRIME attack vector |
940
|
|
|
* |
941
|
|
|
* @return boolean |
942
|
|
|
*/ |
943
|
|
|
public function getDisableCompression() |
944
|
|
|
{ |
945
|
|
|
return $this->disableCompression; |
946
|
|
|
} |
947
|
|
|
|
948
|
|
|
/** |
949
|
|
|
* Return's TRUE if self-signed certificates has to be allowed, but requires verify_peer to be FALSE |
950
|
|
|
* |
951
|
|
|
* @return boolean |
952
|
|
|
*/ |
953
|
|
|
public function getAllowSelfSigned() |
954
|
|
|
{ |
955
|
|
|
return $this->allowSelfSigned; |
956
|
|
|
} |
957
|
|
|
|
958
|
|
|
/** |
959
|
|
|
* Return's TRUE if control cipher ordering preferences during negotiation has to be allowed |
960
|
|
|
* |
961
|
|
|
* @return boolean |
962
|
|
|
*/ |
963
|
|
|
public function getHonorCipherOrder() |
964
|
|
|
{ |
965
|
|
|
return $this->honorCipherOrder; |
966
|
|
|
} |
967
|
|
|
|
968
|
|
|
/** |
969
|
|
|
* Return's the curve to use with ECDH ciphers, if not specified prime256v1 will be used |
970
|
|
|
* |
971
|
|
|
* @return string |
972
|
|
|
*/ |
973
|
|
|
public function getEcdhCurve() |
974
|
|
|
{ |
975
|
|
|
return $this->ecdhCurve; |
976
|
|
|
} |
977
|
|
|
|
978
|
|
|
/** |
979
|
|
|
* Return's TRUE if a new key pair has to be created in scenarios where ECDH cipher suites are negotiated (instead of the preferred ECDHE ciphers) |
980
|
|
|
* |
981
|
|
|
* @return boolean |
982
|
|
|
*/ |
983
|
|
|
public function getSingleEcdhUse() |
984
|
|
|
{ |
985
|
|
|
return $this->singleEcdhUse; |
986
|
|
|
} |
987
|
|
|
|
988
|
|
|
/** |
989
|
|
|
* Return's TRUE if new key pair has to be created created when using DH parameters (improves forward secrecy) |
990
|
|
|
* |
991
|
|
|
* @return boolean |
992
|
|
|
*/ |
993
|
|
|
public function getSingleDhUse() |
994
|
|
|
{ |
995
|
|
|
return $this->singleDhUse; |
996
|
|
|
} |
997
|
|
|
} |
998
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: