|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ****************************************************************************** |
|
5
|
|
|
* Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 |
|
6
|
|
|
* and GN4-2 consortia |
|
7
|
|
|
* |
|
8
|
|
|
* License: see the web/copyright.php file in the file structure |
|
9
|
|
|
* ****************************************************************************** |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
require_once ("autoloader.php"); |
|
13
|
|
|
require_once(__DIR__ . "/../packageRoot.php"); |
|
14
|
|
|
|
|
15
|
|
|
/* This code block compares the template config against the actual one to find |
|
16
|
|
|
* out which of the values are MISSING, which are still at DEFAULT and which |
|
17
|
|
|
* have been CHANGED. |
|
18
|
|
|
|
|
19
|
|
|
function recursiveConfCheck($template, $real, $level = 0) { |
|
20
|
|
|
$result = []; |
|
21
|
|
|
|
|
22
|
|
|
$stateMissingSet = 0; |
|
23
|
|
|
$stateDefaultSet = 0; |
|
24
|
|
|
$stateChangedSet = 0; |
|
25
|
|
|
$stateSubLevelsDiffer = 0; |
|
26
|
|
|
|
|
27
|
|
|
foreach ($template as $key => $value) { |
|
28
|
|
|
if (!isset($real[$key])) { |
|
29
|
|
|
$result[$key] = "MISSING"; |
|
30
|
|
|
$stateMissingSet = 1; |
|
31
|
|
|
} elseif (is_array($value)) { |
|
32
|
|
|
$result[$key] = recursiveConfCheck($value, $real[$key], $level + 1); |
|
33
|
|
|
switch ($result[$key]) { |
|
34
|
|
|
case "MISSING": |
|
35
|
|
|
$stateMissingSet = 1; |
|
36
|
|
|
break; |
|
37
|
|
|
case "DEFAULT": |
|
38
|
|
|
$stateDefaultSet = 1; |
|
39
|
|
|
break; |
|
40
|
|
|
case "CHANGED": |
|
41
|
|
|
$stateChangedSet = 1; |
|
42
|
|
|
break; |
|
43
|
|
|
default: |
|
44
|
|
|
$stateSubLevelsDiffer = 1; |
|
45
|
|
|
} |
|
46
|
|
|
} elseif ($value === $real[$key]) { |
|
47
|
|
|
$result[$key] = "DEFAULT"; |
|
48
|
|
|
$stateDefaultSet = 1; |
|
49
|
|
|
} else { |
|
50
|
|
|
$result[$key] = "CHANGED"; |
|
51
|
|
|
$stateChangedSet = 1; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
// group together a config layer if all settings are same |
|
55
|
|
|
if ($stateChangedSet + $stateDefaultSet + $stateMissingSet + $stateSubLevelsDiffer > 1) { |
|
56
|
|
|
return $result; |
|
57
|
|
|
} |
|
58
|
|
|
if ($stateMissingSet == 1) { |
|
59
|
|
|
return "MISSING"; |
|
60
|
|
|
} |
|
61
|
|
|
if ($stateChangedSet == 1) { |
|
62
|
|
|
return "CHANGED"; |
|
63
|
|
|
} |
|
64
|
|
|
if ($stateDefaultSet == 1) { |
|
65
|
|
|
return "DEFAULT"; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
// first, fetch and store the /template/ config so that we can find missing |
|
70
|
|
|
// bits in the actual config. Since this is a const, we need to first load |
|
71
|
|
|
// the template, alter the const name, save it, and include it |
|
72
|
|
|
|
|
73
|
|
|
$templateConfig = file_get_contents(ROOT . "/config/config-master-template.php"); |
|
74
|
|
|
$newTemplateConfig = preg_replace("/const CONFIG/", "const TEMPLATE_CONFIG", $templateConfig); |
|
75
|
|
|
file_put_contents(ROOT . "/var/tmp/temp-master.php", $newTemplateConfig); |
|
76
|
|
|
include(ROOT . "/var/tmp/temp-master.php"); |
|
77
|
|
|
unlink(ROOT . "/var/tmp/temp-master.php"); |
|
78
|
|
|
*/ |
|
79
|
|
|
// this is the actual config |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
include(ROOT . "/config/config-master.php"); |
|
83
|
|
|
|
|
84
|
|
|
/* as a test for the config comparison, run this, display in browser and exit |
|
85
|
|
|
|
|
86
|
|
|
echo "<pre>"; |
|
87
|
|
|
print_r(TEMPLATE_CONFIG); |
|
88
|
|
|
print_r(CONFIG); |
|
89
|
|
|
print_r(recursiveConfCheck(TEMPLATE_CONFIG, CONFIG)); |
|
90
|
|
|
echo "</pre>"; |
|
91
|
|
|
exit; |
|
92
|
|
|
|
|
93
|
|
|
*/ |
|
94
|
|
|
|
|
95
|
|
|
/* load sub-configs if we are dealing with those in this installation */ |
|
96
|
|
|
|
|
97
|
|
|
if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == 'LOCAL' || CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == 'LOCAL') { |
|
98
|
|
|
include(ROOT . "/config/config-confassistant.php"); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
if (CONFIG['FUNCTIONALITY_LOCATIONS']['DIAGNOSTICS'] == 'LOCAL') { |
|
102
|
|
|
include(ROOT . "/config/config-diagnostics.php"); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
function CAT_session_start() { |
|
106
|
|
|
if (session_status() != PHP_SESSION_ACTIVE) { |
|
107
|
|
|
session_set_cookie_params(0, "/", $_SERVER['SERVER_NAME'], (isset($_SERVER['HTTPS']) ? TRUE : FALSE )); |
|
108
|
|
|
session_start(); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|