1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/* |
3
|
|
|
* ***************************************************************************** |
4
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
5
|
|
|
* project that has received funding from the European Union’s Framework |
6
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
7
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
8
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
9
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
10
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
11
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
12
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
13
|
|
|
* UK as a branch of GÉANT Vereniging. |
14
|
|
|
* |
15
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
16
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
17
|
|
|
* |
18
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
19
|
|
|
* <base_url>/copyright.php after deploying the software |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* This page displays the dashboard overview of an entire IdP. |
24
|
|
|
* |
25
|
|
|
* @author Stefan Winter <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
?> |
28
|
|
|
<?php |
29
|
|
|
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
30
|
|
|
|
31
|
|
|
$deco = new \web\lib\admin\PageDecoration(); |
32
|
|
|
$validator = new \web\lib\common\InputValidation(); |
33
|
|
|
$uiElements = new web\lib\admin\UIElements(); |
34
|
|
|
|
35
|
|
|
// our own location, to give to diag URLs |
36
|
|
|
if (isset($_SERVER['HTTPS'])) { |
37
|
|
|
$link = 'https://'; |
38
|
|
|
} else { |
39
|
|
|
$link = 'http://'; |
40
|
|
|
} |
41
|
|
|
$link .= $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
42
|
|
|
$link = htmlspecialchars($link); |
43
|
|
|
|
44
|
|
|
echo $deco->defaultPagePrelude(sprintf(_("%s: %s Dashboard"), \config\Master::APPEARANCE['productname'], $uiElements->nomenclatureHotspot)); |
45
|
|
|
require_once "inc/click_button_js.php"; |
46
|
|
|
|
47
|
|
|
// RADIUS status icons |
48
|
|
|
$radiusMessages = [ |
49
|
|
|
\core\AbstractDeployment::RADIUS_OK => ['icon' => '../resources/images/icons/Quetto/check-icon.png', 'text' => _("Successfully set profile")], |
50
|
|
|
\core\AbstractDeployment::RADIUS_FAILURE => ['icon' => '../resources/images/icons/Quetto/no-icon.png', 'text' => _("Some problem occured during profile update")], |
51
|
|
|
]; |
52
|
|
|
// let's check if the inst handle actually exists in the DB |
53
|
|
|
$my_inst = $validator->existingIdP($_GET['inst_id'], $_SESSION['user']); |
54
|
|
|
|
55
|
|
|
// delete stored realm |
56
|
|
|
|
57
|
|
|
if (isset($_SESSION['check_realm'])) { |
58
|
|
|
unset($_SESSION['check_realm']); |
59
|
|
|
} |
60
|
|
|
$mapCode = web\lib\admin\AbstractMap::instance($my_inst, TRUE); |
61
|
|
|
echo $mapCode->htmlHeadCode(); |
62
|
|
|
?> |
63
|
|
|
<script> |
64
|
|
|
/*var ajax_call = function() { |
65
|
|
|
//your jQuery ajax code |
66
|
|
|
};*/ |
67
|
|
|
|
68
|
|
|
/*var interval = 1000 * 60 * X; // where X is your every X minutes*/ |
69
|
|
|
|
70
|
|
|
/* setInterval(ajax_call, interval); */ |
71
|
|
|
/* setInterval(function(){ alert("Hello"); }, 10000); */ |
72
|
|
|
</script> |
73
|
|
|
</head> |
74
|
|
|
<body |
75
|
|
|
<?php echo $mapCode->bodyTagCode(); ?>> |
76
|
|
|
<?php |
77
|
|
|
echo $deco->productheader("ADMIN-SP"); |
78
|
|
|
function check_url ($host) { |
|
|
|
|
79
|
|
|
$ch = curl_init(); |
80
|
|
|
$timeout = 10; |
81
|
|
|
if ($ch === FALSE) { |
82
|
|
|
return NULL; |
83
|
|
|
} |
84
|
|
|
curl_setopt ( $ch, CURLOPT_URL, 'http://'.$host ); |
85
|
|
|
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
86
|
|
|
curl_setopt ( $ch, CURLOPT_TIMEOUT, $timeout ); |
87
|
|
|
$http_respond = curl_exec($ch); |
88
|
|
|
$http_respond = trim( strip_tags( $http_respond ) ); |
89
|
|
|
$http_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); |
90
|
|
|
if ($http_code == 200) { |
91
|
|
|
return 1; |
92
|
|
|
} |
93
|
|
|
return 0; |
94
|
|
|
} |
95
|
|
|
function radius_config_site($dobject) { |
|
|
|
|
96
|
|
|
$timeout = 10; |
97
|
|
|
$res = array(); |
98
|
|
|
if ($dobject->radius_status_1 == \core\AbstractDeployment::RADIUS_FAILURE) { |
99
|
|
|
$res[1] = check_url($dobject->radius_hostname_1); |
100
|
|
|
} |
101
|
|
|
if ($dobject->radius_status_2 == \core\AbstractDeployment::RADIUS_FAILURE) { |
102
|
|
|
$res[2] = check_url($dobject->radius_hostname_2); |
103
|
|
|
} |
104
|
|
|
return $res; |
105
|
|
|
} |
106
|
|
|
// Sanity check complete. Show what we know about this IdP. |
107
|
|
|
$idpoptions = $my_inst->getAttributes(); |
108
|
|
|
?> |
109
|
|
|
<h1><?php echo sprintf(_("%s Overview"), $uiElements->nomenclatureHotspot); ?></h1> |
110
|
|
|
<div> |
111
|
|
|
<h2><?php echo sprintf(_("%s general settings"), $uiElements->nomenclatureHotspot); ?></h2> |
112
|
|
|
<?php |
113
|
|
|
echo $uiElements->instLevelInfoBoxes($my_inst); |
114
|
|
|
?> |
115
|
|
|
<?php |
116
|
|
|
foreach ($idpoptions as $optionname => $optionvalue) { |
117
|
|
|
if ($optionvalue['name'] == "general:geo_coordinates") { |
118
|
|
|
echo '<div class="infobox">'; |
119
|
|
|
echo $mapCode->htmlShowtime(); |
120
|
|
|
echo '</div>'; |
121
|
|
|
break; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
?> |
125
|
|
|
</div> |
126
|
|
|
<?php |
127
|
|
|
$readonly = \config\Master::DB['INST']['readonly']; |
128
|
|
|
?> |
129
|
|
|
<hr><h2><?php echo _("Available Support actions"); ?></h2> |
130
|
|
|
<table> |
131
|
|
|
<?php |
132
|
|
|
if (\config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] !== NULL) { |
133
|
|
|
echo "<tr> |
134
|
|
|
<td>" . _("Check another realm's reachability") . "</td> |
135
|
|
|
<td><form method='post' action='../diag/action_realmcheck.php?inst_id=$my_inst->identifier' accept-charset='UTF-8'> |
136
|
|
|
<input type='text' name='realm' id='realm'> |
137
|
|
|
<input type='hidden' name='comefrom' id='comefrom' value='$link'/> |
138
|
|
|
<button type='submit'>" . _("Go!") . "</button> |
139
|
|
|
</form> |
140
|
|
|
</td> |
141
|
|
|
</tr>"; |
142
|
|
|
} |
143
|
|
|
if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam") { // SW: APPROVED |
144
|
|
|
echo "<tr> |
145
|
|
|
<td>" . sprintf(_("Check %s server status"), $uiElements->nomenclatureFed) . "</td> |
146
|
|
|
<td> |
147
|
|
|
<form action='https://monitor.eduroam.org/mon_direct.php' accept-charset='UTF-8'> |
148
|
|
|
<button type='submit'>" . _("Go!") . "</button> |
149
|
|
|
</form> |
150
|
|
|
</td> |
151
|
|
|
</tr>"; |
152
|
|
|
} |
153
|
|
|
?> |
154
|
|
|
</table> |
155
|
|
|
<hr/> |
156
|
|
|
<?php |
157
|
|
|
$hotspotProfiles = $my_inst->listDeployments(); |
158
|
|
|
if (count($hotspotProfiles) == 0) { // no profiles yet. |
159
|
|
|
echo "<h2>" . sprintf(_("There are not yet any known deployments for your %s."), $uiElements->nomenclatureHotspot) . "</h2>"; |
160
|
|
|
} |
161
|
|
|
if (count($hotspotProfiles) > 0) { // no profiles yet. |
162
|
|
|
echo "<h2>" . sprintf(_("Deployments for this %s"), $uiElements->nomenclatureHotspot) . "</h2>"; |
163
|
|
|
// display an info box with the connection data |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
foreach ($hotspotProfiles as $counter => $deploymentObject) { |
167
|
|
|
$radius_status = array(); |
168
|
|
|
$radius_status[0] = $deploymentObject->radius_status_1; |
169
|
|
|
$radius_status[1] = $deploymentObject->radius_status_2; |
170
|
|
|
$retry = radius_config_site($deploymentObject); |
171
|
|
|
?> |
172
|
|
|
<div style='display: table-row; margin-bottom: 20px;'> |
173
|
|
|
<div class='profilebox' style='display: table-cell;'> |
174
|
|
|
<h2><?php echo core\DeploymentManaged::PRODUCTNAME . " (<span style='color:" . ( $deploymentObject->status == \core\AbstractDeployment::INACTIVE ? "red;'>" . _("inactive") : "green;'>" . _("active") ) . "</span>)"; ?></h2> |
175
|
|
|
<table> |
176
|
|
|
<tr> |
177
|
|
|
<td><strong><?php echo _("Your primary RADIUS server") ?></strong><br/> |
178
|
|
|
<?php |
179
|
|
|
if ($deploymentObject->host1_v4 !== NULL) { |
180
|
|
|
echo _("IPv4") . ": " . $deploymentObject->host1_v4; |
181
|
|
|
} |
182
|
|
|
if ($deploymentObject->host1_v4 !== NULL && $deploymentObject->host1_v6 !== NULL) { |
183
|
|
|
echo "<br/>"; |
184
|
|
|
} |
185
|
|
|
if ($deploymentObject->host1_v6 !== NULL) { |
186
|
|
|
echo _("IPv6") . ": " . $deploymentObject->host1_v6; |
187
|
|
|
} |
188
|
|
|
?> |
189
|
|
|
</td> |
190
|
|
|
<td><?php echo _("RADIUS port number: ") ?></td> |
191
|
|
|
<td><?php echo $deploymentObject->port1; ?></td> |
192
|
|
|
<td> |
193
|
|
|
<?php |
194
|
|
|
echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_1]['icon'] . |
195
|
|
|
"' alt='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . |
196
|
|
|
"' title='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . "'>"; |
197
|
|
|
?> |
198
|
|
|
</td> |
199
|
|
|
</tr> |
200
|
|
|
<tr> |
201
|
|
|
<td><strong><?php echo _("Your backup RADIUS server") ?><br/></strong> |
202
|
|
|
<?php |
203
|
|
|
if ($deploymentObject->host2_v4 !== NULL) { |
204
|
|
|
echo _("IPv4") . ": " . $deploymentObject->host2_v4; |
205
|
|
|
} |
206
|
|
|
if ($deploymentObject->host2_v4 !== NULL && $deploymentObject->host2_v6 !== NULL) { |
207
|
|
|
echo "<br/>"; |
208
|
|
|
} |
209
|
|
|
if ($deploymentObject->host2_v6 !== NULL) { |
210
|
|
|
echo _("IPv6") . ": " . $deploymentObject->host2_v6; |
211
|
|
|
} |
212
|
|
|
?></td> |
213
|
|
|
<td><?php echo _("RADIUS port number: ") ?></td> |
214
|
|
|
<td><?php echo $deploymentObject->port2; ?></td> |
215
|
|
|
<td> |
216
|
|
|
<?php |
217
|
|
|
echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_2]['icon'] . |
218
|
|
|
"' alt='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . |
219
|
|
|
"' title='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . "'>"; |
220
|
|
|
?> |
221
|
|
|
</td> |
222
|
|
|
</tr> |
223
|
|
|
|
224
|
|
|
<tr> |
225
|
|
|
<td><strong><?php echo _("RADIUS shared secret"); ?></strong></td> |
226
|
|
|
<td><?php echo $deploymentObject->secret; ?></td> |
227
|
|
|
</tr> |
228
|
|
|
|
229
|
|
|
<?php if ($opname = $deploymentObject->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { ?> |
230
|
|
|
<tr> |
231
|
|
|
<td><strong><?php echo _("Custom Operator-Name"); ?></strong></td> |
232
|
|
|
<td><?php echo $opname; ?></td> |
233
|
|
|
</tr> |
234
|
|
|
<?php |
235
|
|
|
} |
236
|
|
|
if ($vlan = $deploymentObject->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { ?> |
237
|
|
|
<tr> |
238
|
|
|
<td><strong><?php echo _("VLAN tag for own users"); ?></strong></td> |
239
|
|
|
<td><?php echo $vlan; ?></td> |
240
|
|
|
</tr> |
241
|
|
|
<?php } ?> |
242
|
|
|
<?php |
243
|
|
|
$allRealms = array_values(array_unique(array_column($deploymentObject->getAttributes("managedsp:realmforvlan"), "value"))); |
244
|
|
|
if (!empty($allRealms)) { |
245
|
|
|
?> |
246
|
|
|
<tr> |
247
|
|
|
<td><strong><?php echo _("Realm to be considered own users"); ?></strong></td> |
248
|
|
|
<td><?php echo implode(', ', $allRealms); ?></td> |
249
|
|
|
</tr> |
250
|
|
|
<?php |
251
|
|
|
} |
252
|
|
|
?> |
253
|
|
|
</table> |
254
|
|
|
<div class='buttongroupprofilebox' style='clear:both;'> |
255
|
|
|
<form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
256
|
|
|
<hr/> |
257
|
|
|
<button type='submit' name='profile_action' value='edit'><?php echo _("Advanced Configuration"); ?></button> |
258
|
|
|
</form> |
259
|
|
|
<?php if ($deploymentObject->status == \core\AbstractDeployment::ACTIVE) { ?> |
260
|
|
|
<form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
261
|
|
|
<button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_DELETE; ?>' onclick="return confirm('<?php printf(_("Do you really want to deactivate the %s deployment?"), core\DeploymentManaged::PRODUCTNAME); ?>')"> |
262
|
|
|
<?php echo _("Deactivate"); ?> |
263
|
|
|
</button> |
264
|
|
|
<?php |
265
|
|
|
if (isset($_GET['res']) && is_array($_GET['res'])) { |
266
|
|
|
$res = array_count_values($_GET['res']); |
267
|
|
|
if (isset($res['FAILURE']) && $res[] > 0) { |
268
|
|
|
echo '<br>'; |
269
|
|
|
if ($res['FAILURE'] == 2) |
270
|
|
|
echo ' <span style="color: red;">' . _("Activation failure.") . '</span>'; |
271
|
|
|
} else { |
272
|
|
|
if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') { |
273
|
|
|
echo ' <span style="color: red;">' . _("Activation failure for your primary RADIUS server.") . '</span>'; |
274
|
|
|
} else { |
275
|
|
|
echo ' <span style="color: red;">' . _("Activation failure for your backup RADIUS server.") . '</span>'; |
276
|
|
|
} |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
?> |
281
|
|
|
</form> |
282
|
|
|
<?php |
283
|
|
|
} else { |
|
|
|
|
284
|
|
|
?> |
285
|
|
|
<form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
286
|
|
|
<button class='delete' style='background-color: green;' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_ACTIVATE; ?>'> |
287
|
|
|
<?php echo _("Activate"); ?> |
288
|
|
|
</button> |
289
|
|
|
<?php |
290
|
|
|
if (isset($_GET['res']) && is_array($_GET['res'])) { |
291
|
|
|
$res = array_count_values($_GET['res']); |
292
|
|
|
if ($res['FAILURE'] > 0) { |
293
|
|
|
echo '<br>'; |
294
|
|
|
if ($res['FAILURE'] == 2) { |
295
|
|
|
echo ' <span style="color: red;">' . _("Failure during deactivation, your request is queued for handling") . '</span>'; |
296
|
|
|
} else { |
297
|
|
|
if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') { |
298
|
|
|
echo ' <span style="color: red;">' . _("Deactivation failure for your primary RADIUS server, your request is queued.") . '</span>'; |
299
|
|
|
} else { |
300
|
|
|
echo ' <span style="color: red;">' . _("Deactivation failure for your backup RADIUS server, your request is queued.") . '</span>'; |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
?> |
306
|
|
|
</form> |
307
|
|
|
<?php |
308
|
|
|
} |
309
|
|
|
if (in_array(1, $retry)) { |
310
|
|
|
?> |
311
|
|
|
<form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
312
|
|
|
<button class='delete' style='background-color: green;' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_RETRY; ?>'> |
313
|
|
|
<?php echo _("Push missing configuration update"); ?> |
314
|
|
|
</button> |
315
|
|
|
<?php |
316
|
|
|
foreach ($retry as $key => $value) { |
317
|
|
|
if ($value == 1) { |
318
|
|
|
?> |
319
|
|
|
<input type="hidden" name='update[]' value='<?php echo $key;?>'> |
320
|
|
|
<?php |
321
|
|
|
} |
322
|
|
|
} |
323
|
|
|
?> |
324
|
|
|
</form> |
325
|
|
|
<?php |
326
|
|
|
} |
327
|
|
|
?> |
328
|
|
|
</div> |
329
|
|
|
</div> |
330
|
|
|
<div style='width:20px;'></div> <!-- QR code space, reserved --> |
331
|
|
|
<div style='display: table-cell; min-width:200px;'></div> <!-- statistics space, reserved --> |
332
|
|
|
</div> |
333
|
|
|
|
334
|
|
|
<?php |
335
|
|
|
} |
336
|
|
|
if ($readonly === FALSE) { |
337
|
|
|
// the opportunity to add a new silverbullet profile is only shown if |
338
|
|
|
// a) there is no SB profile yet |
339
|
|
|
// b) federation wants this to happen |
340
|
|
|
|
341
|
|
|
$myfed = new \core\Federation($my_inst->federation); |
342
|
|
|
if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0 && $my_inst->deploymentCount() == 0) { |
343
|
|
|
// the button is grayed out if there's no support email address configured... |
344
|
|
|
$hasMail = count($my_inst->getAttributes("support:email")); |
345
|
|
|
?> |
346
|
|
|
<form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'> |
347
|
|
|
<div> |
348
|
|
|
<button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'> |
349
|
|
|
<?php echo sprintf(_("Add %s deployment ..."), \core\DeploymentManaged::PRODUCTNAME); ?> |
350
|
|
|
</button> |
351
|
|
|
</div> |
352
|
|
|
</form> |
353
|
|
|
<?php |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
// adding a normal profile is always possible if we're configured for it |
357
|
|
|
} |
358
|
|
|
echo $deco->footer(); |
359
|
|
|
|
360
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.