Issues (172)

Security Analysis    13 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting (3)
Response Splitting can be used to send arbitrary responses.
  File Manipulation (6)
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting (1)
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

web/admin/overview_sp.php (3 issues)

1
<?php
2
3
/*
4
 * *****************************************************************************
5
 * Contributions to this work were made on behalf of the GÉANT project, a 
6
 * project that has received funding from the European Union’s Framework 
7
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
8
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
9
 * 691567 (GN4-1) and No. 731122 (GN4-2).
10
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
11
 * of the copyright in all material which was developed by a member of the GÉANT
12
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
13
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
14
 * UK as a branch of GÉANT Vereniging.
15
 * 
16
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
17
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
18
 *
19
 * License: see the web/copyright.inc.php file in the file structure or
20
 *          <base_url>/copyright.php after deploying the software
21
 * */
22
 
23
 /**
24
 * This file is used to display a deployment.
25
 * 
26
 * @author Maja Gorecka-Wolniewicz <[email protected]>
27
 */
28
?>
29
<?php
30
31
$error_message = [
32
    'WRONGCSR' => _('The uploaded file does not contain a valid CSR!'),
33
    'NOCSR' => _('The provided file can not be uploaded.'),
34
];
35
36
$langInstance = new \core\common\Language();
37
$start = $langInstance->rtl ? "right" : "left";
38
$end = $langInstance->rtl ? "left" : "right";
39
$errormsg = [];
40
if (isset($_GET['errormsg'])) {
41
    $msg = explode('_', trim($_GET['errormsg']));
42
    if (count($msg) == 2) {
43
        $errormsg[$msg[1]] = $error_message[$msg[0]];
44
    }
45
}
46
?>
47
<style>
48
    .deployments td:first-child {
49
        padding-right: 15px;
50
    }
51
    img.copy_link {
52
        position: relative;
53
        top: 3px;
54
        <?php echo $start ?>: 3px;
55
        height: 16px;
56
    }
57
</style>
58
<script>
59
function getFile() {
60
    if (confirm('<?php printf(_("Do you really want to replace TLS credentials for this deployment? The current TLS credentials will be revoked in 4 hours.")); ?>')) {
61
    document.getElementById("upfile").click();   
62
    }
63
    event.preventDefault(); 
64
}
65
66
function sendcsr(obj) {
67
    //alert(obj.value);
68
    var file = obj.value;
69
    var fileName = file.split("\\");
70
    //alert(fileName[fileName.length - 1]);
71
    document.getElementById("submitbuttoncsr").value = '<?php echo web\lib\common\FormElements::BUTTON_USECSR; ?>';
72
    document.csrupload.submit();
73
    event.preventDefault();
74
}
75
76
$(function() {
77
    $(".copy_link").tooltip();
78
    
79
    $(".copy_link").on("click", function() {
80
        $(".copy_link").tooltip({
81
            content: "<?php echo _("Copy to clipboard") ?>"
82
        });
83
        var field = $(this).attr("id").replace('_icon', '_data');
84
        var toCopy = $("#"+field).html();        
85
        navigator.clipboard.writeText(toCopy);
86
        $(this).tooltip({
87
            content: "<strong><?php echo _("Copied!") ?></strong>"
88
        });
89
        $(this).fadeOut(150).fadeIn(150);
90
    });
91
});
92
93
94
</script>
95
96
<?php
97
function copyIcon($target) {
98
    return '<img class="copy_link" id="'.$target.'" src="../resources/images/icons/Tabler/copy.svg" title="'. _("Copy to clipboard").'" >';
99
}
100
101
/**
102
 * displays an infocard about a Managed SP deployment
103
 * 
104
 * @param \core\DeploymentManaged $deploymentObject the deployment to work with
105
 * @throws Exception
106
 */
107
function displayDeploymentPropertyWidget(&$deploymentObject, $errormsg=[]) {
108
    // RADIUS status icons
109
    $depId = $deploymentObject->identifier;
110
    $radiusMessages = [
111
        \core\AbstractDeployment::RADIUS_OK => ['icon' => '../resources/images/icons/Tabler/square-rounded-check-filled-green.svg', 'text' => _("Successfully set profile")],
112
        \core\AbstractDeployment::RADIUS_FAILURE => ['icon' => '../resources/images/icons/Tabler/square-rounded-x-filled-red.svg', 'text' => _("Some problem occurred during profile update")],
113
    ];
114
    $radius_status = array();
115
    $radius_status[0] = $deploymentObject->radius_status_1;
116
    $radius_status[1] = $deploymentObject->radius_status_2;
117
    $cacert = file_get_contents(ROOT .  "/config/ManagedSPCerts/eduroamSP-CA.pem");
118
    $retry = $deploymentObject->checkRADIUSHostandConfigDaemon();
119
    $isradiusready = radius_ready($deploymentObject);
120
    if (is_array($retry)) {
121
        foreach ($retry as $id => $stat) {
122
            if ($stat) {
123
                $response = $deploymentObject->setRADIUSconfig($id, 1);
0 ignored issues
show
The assignment to $response is dead and can be removed.
Loading history...
124
            }
125
        }
126
    }
127
    ?>
128
    <div style='display: table-row_id;'>
129
        <div class='profilebox' id="profilebox_<?php echo $depId;?>" style='display: table-cell;'>
130
            <h2><?php
131
                switch ($deploymentObject->consortium) {
132
                    case "eduroam":
133
                        $displayname = config\ConfAssistant::CONSORTIUM['name'] . " " . core\DeploymentManaged::PRODUCTNAME. ": SP$depId-".$deploymentObject->institution;
134
                        break;
135
                    case "OpenRoaming":
136
                        $displayname = "OpenRoaming ANP";
137
                        break;
138
                    default:
139
                        throw new Exception("We are supposed to operate on a roaming consortium we don't know.");
140
                }
141
                echo $displayname . " (<span style='color:" . ( $deploymentObject->status == \core\AbstractDeployment::INACTIVE ? "red;'>" . _("inactive") : "green;'>" . _("active") ) . "</span>)";
142
                ?></h2>
143
            <table class="deployments">
144
                <caption><?php echo _("Deployment Details"); ?></caption>
145
                <form action="?inst_id=<?php echo $deploymentObject->institution; ?>" method="post">
146
                <tr>
147
                    <th colspan="2"><?php echo("RADIUS over UDP"); ?></th>
148
                </tr>
149
                <tr style="vertical-align:top">
150
                    <td>
151
                        <?php echo _("Your primary RADIUS server") ?>
152
                    </td>
153
                    <td>
154
                        <?php
155
                        if ($deploymentObject->host1_v4 !== NULL) {
156
                            printf(_("IPv4: %s"), "<span id='host1_v4_data_$depId'>".$deploymentObject->host1_v4."</span>");
157
                            echo copyIcon("host1_v4_icon_$depId");
158
                        }
159
                        if ($deploymentObject->host1_v4 !== NULL && $deploymentObject->host1_v6 !== NULL) {
160
                            echo "<br/>";
161
                        }
162
                        if ($deploymentObject->host1_v6 !== NULL) {
163
                            printf(_("IPv6: %s"), "<span id='host1_v6_data_$depId'>".$deploymentObject->host1_v6."</span>");
164
                            echo copyIcon("host1_v6_icon_$depId");                            
165
                        }
166
                        echo "<br/>";
167
                        printf(_("port: %s"), "<span id='port1_data_$depId'>".$deploymentObject->port1."</span>");
168
                        echo copyIcon("port1_icon_$depId");                            
169
                        ?>                        
170
                    </td>
171
                    <td>
172
                        <?php
173
                        if ($deploymentObject->status) {
174
                            echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_1]['icon'] .
175
                                "' alt='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] .
176
                                "' title='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . "' class='cat-icon'>";
177
                        }
178
                        ?>
179
                    </td>
180
                </tr>
181
                <tr style="vertical-align:top">
182
                    <td>
183
                        <?php echo _("Your secondary RADIUS server") ?>
184
                    </td>
185
                    <td>            
186
                        <?php
187
                        if ($deploymentObject->host2_v4 !== NULL) {
188
                            printf(_("IPv4: %s"), "<span id='host2_v4_data_$depId'>".$deploymentObject->host2_v4."</span>");
189
                            echo copyIcon("host2_v4_icon_$depId");
190
                        }
191
                        if ($deploymentObject->host2_v4 !== NULL && $deploymentObject->host2_v6 !== NULL) {
192
                            echo "<br/>";
193
                        }
194
                        if ($deploymentObject->host2_v6 !== NULL) {
195
                            printf(_("IPv6: %s"), "<span id='host2_v6_data_$depId'>".$deploymentObject->host2_v6."</span>");
196
                            echo copyIcon("host2_v6_icon_$depId");                            
197
                        }
198
                        echo "<br/>";
199
                        printf(_("port: %s"), "<span id='port2_data_$depId'>".$deploymentObject->port2."</span>");
200
                        echo copyIcon("port2_icon_$depId");                            
201
                        ?>
202
                    </td>
203
                    <td>
204
                        <?php
205
                        if ($deploymentObject->status) {
206
                            echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_2]['icon'] .
207
                                "' alt='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] .
208
                            "' title='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . "' class='cat-icon'>";
209
                        }
210
                        ?>
211
                    </td>
212
                </tr>
213
                <tr style="vertical-align:bottom">
214
                    <td><?php echo _("RADIUS shared secret for both servers"); ?></td>
215
                    <td>
216
                        <span id="shared_data_<?php echo $deploymentObject->identifier;?>"><?php echo $deploymentObject->secret;?></span>
217
                        <?php echo copyIcon("shared_icon_".$deploymentObject->identifier) ?>
218
                    </td>
219
                    <td></td>
220
                </tr>
221
                <tr></tr>
222
                <tr><td colspan="3" style="background-color: #1d4a74; height: 1px"></tr>
223
224
                <tr>
225
                    <th colspan="2"><?php echo("RADIUS over TLS or TLS-PSK"); ?></th>
226
                </tr>
227
                <tr style="vertical-align:top">
228
                    <td>
229
                        <?php echo _("Your primary RADIUS server") ?>
230
                    </td>
231
                    <td>
232
                        <?php
233
                        if ($deploymentObject->host1_v4 !== NULL) {
234
                            printf(_("IPv4: %s"), "<span id='host1_v4_t_data_$depId'>".$deploymentObject->host1_v4."</span>");
235
                            echo copyIcon("host1_v4_t_icon_$depId");                             
236
                        }
237
                        if ($deploymentObject->host1_v4 !== NULL && $deploymentObject->host1_v6 !== NULL) {
238
                            echo "<br/>";
239
                        }
240
                        if ($deploymentObject->host1_v6 !== NULL) {
241
                            printf(_("IPv6: %s"), "<span id='host1_v6_t_data_$depId'>".$deploymentObject->host1_v6."</span>");
242
                            echo copyIcon("host1_v6_t_icon_$depId");  
243
                        }
244
                        echo "<br/>";
245
                        printf(_("port: %s"), "<span id='port1_t_data_$depId'>2083</span>");
246
                        echo copyIcon("port1_t_icon_$depId");                          
247
                        ?>
248
                    </td>
249
                    <td>
250
                        <?php
251
                        if ($deploymentObject->status) {
252
                            echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_1]['icon'] .
253
                                "' alt='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] .
254
                                "' title='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . "' class='cat-icon'>";
255
                        }
256
                        ?>
257
                    </td>
258
                </tr>
259
                <tr style="vertical-align:top">
260
                    <td>
261
                        <?php echo _("Your secondary RADIUS server") ?>
262
                    </td>
263
                    <td>
264
                        <?php
265
                        if ($deploymentObject->host2_v4 !== NULL) {
266
                            printf(_("IPv4: %s"), "<span id='host2_v4_t_data_$depId'>".$deploymentObject->host2_v4."</span>");
267
                            echo copyIcon("host2_v4_t_icon_$depId");                            
268
                        }
269
                        if ($deploymentObject->host2_v4 !== NULL && $deploymentObject->host2_v6 !== NULL) {
270
                            echo "<br/>";
271
                        }
272
                        if ($deploymentObject->host2_v6 !== NULL) {
273
                            printf(_("IPv6: %s"), "<span id='host2_v6_t_data_$depId'>".$deploymentObject->host2_v6."</span>");
274
                            echo copyIcon("host2_v6_t_icon_$depId");                            
275
                        }
276
                        echo "<br/>";
277
                        printf(_("port: %s"), "<span id='port2_t_data_$depId'>2083</span>");
278
                        echo copyIcon("port2_t_icon_$depId");                          
279
                        ?>
280
                    </td>
281
                    <td>
282
                        <?php
283
                        if ($deploymentObject->status) {
284
                            echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_2]['icon'] .
285
                                "' alt='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] .
286
                            "' title='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . "' class='cat-icon'>";
287
                        }
288
                        ?>
289
                    </td>
290
                </tr>
291
                
292
293
                
294
                <?php if ($deploymentObject->radsec_cert != '') { 
295
                    $data = openssl_x509_parse($deploymentObject->radsec_cert);
296
                    ?>
297
                <tr style="vertical-align:top">
298
                    <td><?php echo _("RADIUS over TLS credentials"); ?></td>
299
                    <td>
300
                    <?php
301
                    if ($deploymentObject->radsec_priv == '') {
302
                        echo _('The client certificate was created using an uploaded CSR, the private key is not available') . '<br><br>';
303
                    }
304
                    echo _('Subject:') . ' ' . $data['name'] . '<br>';
305
                    echo _('Serial number:') . ' ' . $data['serialNumberHex'] . '<br>';
306
                    $dleft = floor(($data['validTo_time_t']-time())/(24*60*60));
307
                    if ($dleft < 30) {
308
                        echo '<font color="red">';
309
                    }
310
                    echo _('Not valid after:') . ' '. date_create_from_format('ymdGis', substr($data['validTo'], 0, -1))->format('Y-m-d H:i:s') . ' UTC';
311
                    if ($dleft > 2) {
312
                        echo '<br>' . _('Number of days to expiry:') . ' ' . $dleft;
313
                    } else {
314
                        echo '<br>' . _('If you are using RADIUS over TLS you should urgently renew your credentials') . '!';
315
                    }
316
                    if ($dleft < 30) { echo '</font>'; }
317
                    ?></td>
318
                </tr><tr><td></td>
319
320
                    <td>
321
                        <span style="display: none;" id="cert_data_<?php echo $depId;?>"><?php echo $deploymentObject->radsec_cert;?></span>
322
                        <span style="display: none;" id="ca_cert_data_<?php echo $depId;?>"><?php echo $cacert;?></span>
323
                        <?php if ($deploymentObject->radsec_priv != '') {
324
                            echo _("private key").copyIcon("priv_key_icon_$depId")."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
325
                            echo '<span style="display: none;" id="priv_key_data_'.$depId.'">'.$deploymentObject->radsec_priv.'</span>';
326
                            echo '&nbsp;&nbsp;';
327
                        }
328
                            echo _("certificate").copyIcon("cert_icon_$depId")."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
329
                            echo '&nbsp;&nbsp;';
330
                            echo _("CA certificate").copyIcon("ca_cert_icon_$depId");
331
                        ?>
332
                        <br/>
333
                        <button name="sendzip" onclick="location.href='inc/sendZip.inc.php?inst_id=<?php echo $deploymentObject->institution;?>&dep_id=<?php echo $depId?>'" type="button"><?php echo _('download ZIP-file with full data');?></button>
334
335
                    </td>
336
                    <td></td>
337
                </tr>
338
                <tr> 
339
                <td></td>
340
                <td>
341
                    <?php
342
                        if ($deploymentObject->radsec_cert != NULL) {
343
                            echo "<i>";
344
                            echo _('If your certificate is close to expiry or you need to create new RADIUS over TLS credentials') . '<br>' .
345
                                 _('click on "Renew RADIUS over TLS credentials" button') . '<br>';
346
                        
347
                            echo '<br/>' . _('You can upload your own CSR to replace default TLS credentials.') . '<br>' . 
348
                                _('Click on "Upload CSR to sign my own TLS credentials"');
349
                            echo "</i>";
350
                    }
351
                    ?>    
352
                </td>
353
                <td></td>
354
                </tr>
355
                <?php         
356
                  
357
                }
358
                if ($deploymentObject->pskkey != '') {?>
359
                <tr style="vertical-align:top">
360
                        <td><?php echo _("RADIUS over TLS-PSK credentials"); ?></td>
361
                        <td>
362
                            <?php printf(_("PSK Identity: %s"), "<span id='pskid_data_$depId'>SP".$depId.'-'.$deploymentObject->institution.'</span>');
363
                            echo copyIcon("pskid_icon_$depId");
364
                           ?>
365
                            <br>
366
                            <?php printf(_("PSK hexphrase: %s"), "<span id='pskkey_data_$depId'>".$deploymentObject->pskkey."</span>");
367
                            echo copyIcon("pskkey_icon_$depId");
368
                            ?>
369
                        </td>
370
                        <td></td>
371
                </tr>
372
                
373
                
374
                <?php } 
375
                $allRealms = array_values(array_unique(array_column($deploymentObject->getAttributes("managedsp:realmforvlan"), "value")));
376
                $opname = $deploymentObject->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL;
377
                $vlan = $deploymentObject->getAttributes("managedsp:vlan")[0]['value'] ?? NULL;
378
                $guest_vlan = $deploymentObject->getAttributes("managedsp:guest_vlan")[0]['value'] ?? NULL;
379
                
380
                ?>
381
                <tr></tr>
382
                <tr><th colspan="2"><?php echo _('Additional deployment settings');?></th></tr>
383
                    <tr>
384
                        <td>
385
                            <?php
386
                                if ($opname) {
387
                                    echo _("Custom Operator-Name");
388
                                } else {
389
                                    echo _("Default Operator-Name");
390
                                }
391
                            ?>
392
                        </td>
393
                        <td>
394
                        <?php
395
                                if ($opname) { 
396
                                    echo $opname; 
397
                                } else {
398
                                    echo '1sp.'.$depId.'-'.$deploymentObject->institution.'.hosted.eduroam.org';
399
                                }
400
                        ?>
401
                        </td>
402
                    </tr>
403
                <?php
404
                if ($guest_vlan) {
405
                    ?>
406
                    <tr>
407
                        <td><?php echo _("VLAN tag for guests"); ?></td>
408
                        <td>
409
                            <?php 
410
                                if ($guest_vlan) {
411
                                    echo $guest_vlan;
412
                                }
413
                            ?>
414
                        </td>
415
                    </tr>
416
                <?php
417
                }
418
                if (!empty($allRealms) || $vlan) {
419
                    ?>
420
                    <tr>
421
                        <td><?php echo _("VLAN tag for own users"); ?></td>
422
                        <td>
423
                            <?php 
424
                                if ($vlan) {
425
                                    echo $vlan;
426
                                } else {
427
                                    echo _('not set, be aware that realm setting is not used until a VLAN tag is added');
428
                                }
429
                            ?>
430
                        </td>
431
                    </tr>
432
                    <tr>
433
                        <td><?php echo _("Realm to be considered own users"); ?></td>
434
                        <td>
435
                            <?php
436
                                if (!empty($allRealms)) {
437
                                    echo implode(', ', $allRealms);
438
                                } else {
439
                                    echo _('not set, be aware that VLAN setting is not used until a realm is added');
440
                                }
441
                } 
442
                ?>
443
                </td></tr>
444
                </form>
445
            </table>
446
            <div class='buttongroupprofilebox' style='clear:both;'>
447
                <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
448
                    <br/>
449
                    <button type='submit' name='profile_action' value='edit'><?php echo _("Advanced Configuration"); ?></button>
450
                </form>
451
                <?php if ($isradiusready && $deploymentObject->status == \core\AbstractDeployment::ACTIVE) { ?>
452
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
453
                        <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); ?>')">
454
                            <?php echo _("Deactivate"); ?>
455
                        </button>
456
                        <?php
457
                        if (isset($_GET['res']) && is_array($_GET['res'])) {
458
                            $res = array_count_values($_GET['res']);
459
                            if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) {
460
                                echo '<br>';
461
                                if ($res['FAILURE'] == 2) {
462
                                    echo ' <span style="color: red;">' . _("Activation failure.") . '</span>';
463
                                } else {
464
                                    if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
465
                                        echo ' <span style="color: red;">' . _("Activation failure for your primary RADIUS server.") . '</span>';
466
                                    } else {
467
                                        echo ' <span style="color: red;">' . _("Activation failure for your backup RADIUS server.") . '</span>';
468
                                    }
469
                                }
470
                            }
471
                        }
472
                        ?>
473
                    </form>
474
                    <?php
475
                } elseif (count($deploymentObject->getAttributes("hiddenmanagedsp:tou_accepted")) == 0) {
476
                    ?>
477
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
478
                        <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_TERMSOFUSE_NEEDACCEPTANCE; ?>'>
479
                            <?php echo _("Accept Terms of Use"); ?>
480
                        </button>
481
                    </form>
482
                <?php }
483
                    if ($isradiusready && $deploymentObject->status == \core\AbstractDeployment::INACTIVE && count($deploymentObject->getAttributes("hiddenmanagedsp:tou_accepted"))) { ?>
484
                        <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
485
                            <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_ACTIVATE; ?>'>
486
                                <?php echo _("Activate"); ?>
487
                            </button>
488
                            <?php
489
                            if (isset($_GET['res']) && is_array($_GET['res'])) {
490
                                $res = array_count_values($_GET['res']);
491
                                if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) {
492
                                    echo '<br>';
493
                                    if ($res['FAILURE'] == 2) {
494
                                        echo ' <span style="color: red;">' . _("Failure during deactivation, your request is queued for handling") . '</span>';
495
                                    } else {
496
                                        if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
497
                                            echo ' <span style="color: red;">' . _("Deactivation failure for your primary RADIUS server, your request is queued.") . '</span>';
498
                                        } else {
499
                                            echo ' <span style="color: red;">' . _("Deactivation failure for your backup RADIUS server, your request is queued.") . '</span>';
500
                                        }
501
                                    }
502
                                }
503
                            }
504
                            ?>
505
                        </form>
506
                <?php } 
507
                    if ($deploymentObject->status == \core\AbstractDeployment::INACTIVE) { ?>
508
                        <div align="right">
509
                        <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
510
                            <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_REMOVESP; ?>' onclick="return confirm('<?php printf(_("Do you really want to remove this %s deployment?"), core\DeploymentManaged::PRODUCTNAME); ?>')">
511
                                <?php echo _("Remove deployment"); ?>
512
                            </button>
513
                        </form>
514
                        </div>
515
                <?php } ?>
516
                    <div align="right">
517
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
518
                            <button class='renewtls' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_RENEWTLS; ?>' onclick="return confirm('<?php printf(_("Do you really want to replace TLS credentials for this %s deployment? The current TLS credentials will be revoked in 4 hours."), core\DeploymentManaged::PRODUCTNAME); ?>')">
519
                                <?php echo _("Renew RADIUS over TLS credentials"); ?>
520
                            </button>
521
                    </form>           
522
                    <form name="csrupload" enctype="multipart/form-data" action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
523
                           <button class='usecsr' type='submit' onclick="getFile();"); ?>                
524
                                <?php echo _("Upload CSR to sign my own TLS credentials"); ?>
525
                            </button>
526
                    <div style='height: 0px;width: 0px; overflow:hidden;'>
527
                        <input name='submitbutton' id='submitbuttoncsr' value=''>
528
                        <input id="upfile" name="upload" type="file" value="upload" onchange="sendcsr(this);" />
529
                    </div>
530
                    </form>
531
                        <!--
532
                    <label for="csr"><?php echo _("Upload CSR to sign my own TLS credentials"); ?></label>
533
                    <div align="right">
534
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
535
                    <!--<input type="file" id="csr" class='usecsr' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_USECSR; ?>' onclick="return confirm('<?php printf(_("Do you really want to replace TLS credentials for this %s deployment? The current TLS credentials will be revoked in 4 hours."), core\DeploymentManaged::PRODUCTNAME); ?>')">-->
536
                    
537
  <!-- this is your file input tag, so i hide it!-->
538
  <!-- i used the onchange event to fire the form submission-->
539
  
540
  <!-- here you can have file submit button or you can write a simple script to upload the file automatically-->
541
  <!-- <input type="submit" value='submit' > -->
542
                    
543
                    </div>
544
            </div>
545
            <?php 
546
            if (!$isradiusready) { 
547
                echo '<p>'. _("We are not able to handle a new configuration request requiring contact with RADIUS servers now.") . '<br>' . _("Check later.");
548
                
549
            } 
550
            if (count($errormsg) > 0 && array_key_exists($deploymentObject->identifier, $errormsg)) {
551
            ?>
552
            <div style='color: red'>
553
                <b>
554
                    <?php echo $errormsg[$deploymentObject->identifier]; ?>
555
                </b>
556
            </div>
557
            <?php
558
            }
559
            ?>
560
        </div>
561
        <div style='width:20px;'></div> <!-- QR code space, reserved -->
562
        <div style='display: table-cell; min-width:200px;'>
563
            <?php $tablecaption = _("Hotspot Usage Statistics");?>
564
            <h1><?php echo $tablecaption; ?></h1>
565
            <h2><?php echo _("5 most recent authentications");?></h2>
566
            <p><?php echo _("<b>AP Identifier</b> is a /-separated tuple of NAS-Identifier/NAS-IP-Address/NAS-IPv6-Address/Called-Station-Id") .'<br>';
567
                     echo _("<b>Protocol</b> is a protocol used between a client and RADIUS server, for TLS it is a /-separated tuple TLS/<i>TLS-Client-Cert-Serial</i>"); ?></p>
568
            <table class='authrecord'>
569
    <caption><?php echo $tablecaption;?></caption>
570
    <tr style='text-align: left;'>
571
        <th scope="col"><strong><?php echo _("Timestamp (UTC)");?></strong></th>
572
        <th scope="col"><strong><?php echo _("Outer-Identity");?></strong></th>
573
        <th scope="col"><strong><?php echo _("Result");?></strong></th>
574
        <th scope="col"><strong><?php echo _("MAC Address");?></strong></th>
575
        <th scope="col"><strong><?php echo _("Chargeable-User-Identity");?></strong></th> 
576
        <th scope="col"><strong><?php echo _("AP Identifier");?></strong></th>
577
        <th scope="col"><strong><?php echo _("Protocol");?></strong></th>
578
    </tr>
579
    <?php
580
    $userAuthData = $deploymentObject->retrieveStatistics(0,5);
581
    $i = 0;	   
582
    foreach ($userAuthData as $oneRecord) {
583
        echo "<tr class='".($oneRecord['result'] == "OK" ? "auth-success" : "auth-fail" )."'>"
584
                . "<td>".$oneRecord['activity_time']."</td>"
585
                . "<td>".$oneRecord['outer_user']."</td>"
586
                . "<td>".($oneRecord['result'] == "OK" ? _("Success") : _("Failure"))."</td>"
587
                . "<td>".$oneRecord['mac']."</td>"
588
		. "<td>".substr($oneRecord['cui'], 0, 18)
589
		. ($oneRecord['cui']=='' ? "" : "... " . copyIcon("cui_icon_".$deploymentObject->identifier."_$i") 
590
	        . "<span style='display: none;' id='cui_data_".$deploymentObject->identifier."_$i'>".$oneRecord['cui'].'</span>')."</td>"
591
                . "<td>".$oneRecord['ap_id']."</td>"
592
                . "<td>".$oneRecord['prot']."</td>"
593
                . "</tr>";
594
        if ($oneRecord['cui']!='') {
595
            $i++;
596
        }
597
    }
598
    ?>
599
</table>
600
            <div style='display: ruby;'>
601
            <form style="display: inline;" action="inc/deploymentStats.inc.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>" onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8' method='post'>
602
                <button type='submit' id='stats-hour' name='stats' value='HOUR'><?php echo _("Last hour"); ?></button>
603
            </form>
604
            <form style="display: inline;" action="inc/deploymentStats.inc.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>" onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8' method='post'>
605
                <button type='submit' id='stats-month' name='stats' value='MONTH'><?php echo _("Last 30 days"); ?></button>
606
            </form>
607
            <form style="display: inline;" action="inc/deploymentStats.inc.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>" onsubmit='popupRedirectWindow(this); return false;' accept-charset='UTF-8' method='post'>
608
                <button type='submit' id='stats-full' name='stats' value='FULL'><?php echo _("Last 6 months"); ?></button>
609
            </form>
610
            </div>
611
            </br>
612
            <?php 
613
            echo _('Get statistics as CSV file:').' '; 
614
            $query = 'inc/deploymentStats.inc.php?inst_id='.$deploymentObject->institution."&deployment_id=$depId&as=csv&backlog=";
615
            ?>
616
	    <button name="sendcsv" type="button" onclick="location.href='<?php echo $query;?>WEEK';"><?php echo _('Last week');?>
617
            </button>
618
	    <button name="sendcsv" type="button" onclick="location.href='<?php echo $query;?>MONTH';"><?php echo _('Last 30 days');?>
619
            </button>
620
	    <button name="sendcsv" type="button" onclick="location.href='<?php echo $query;?>FULL';"><?php echo _('Last 6 months');?>
621
            </button>
622
        </div><!-- statistics space -->
623
        <div style='height:5px'></div>
624
        <div style='display: table-cell; min-width:200px;'>
625
            <h1><?php echo _("Hotspot Debug Logs"); ?></h1>
626
            <h2><?php echo _('To get detailed logs from RADIUS sites click a button below.'); 
627
            $query = 'inc/deploymentLogs.inc.php?inst_id='.$deploymentObject->institution."&deployment_id=$depId&backlog=";
628
            ?></h2>
629
            <?php echo _('You will receive zip file with logs from both RADIUS servers: primary (folder named radius-1) and secondary (folder named radius-2).') . '<br>' .
630
                  _('If no logs are available an empty zip file is provided.');?>
631
            <div style='height:3px'></div>
632
            <button name="logs" type="button" onclick="location.href='<?php echo $query;?>1';"><?php echo _('Today');?>
633
            </button>
634
            <button name="logs" type="button" onclick="location.href='<?php echo $query;?>7';"><?php echo _('Last 7 days');?>
635
            </button>
636
        </div>
637
    </div> 
638
    <!-- dummy div to keep a little distance-->
639
    <div style='height:20px'></div>
640
    
641
    <?php
642
}
643
644
/**
645
 * displays a eduroam DB entry for SPs. Not implemented yet.
646
 * 
647
 * @param \core\DeploymentClassic $deploymentObject the deployment to work with
648
 */
649
function displayClassicHotspotPropertyWidget($deploymentObject) {
0 ignored issues
show
The parameter $deploymentObject is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

649
function displayClassicHotspotPropertyWidget(/** @scrutinizer ignore-unused */ $deploymentObject) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
650
    
651
}
652
653
/**
654
 * checks if both RADIUS servers are ready to accept reconfiguration requests
655
 * 
656
 * 
657
 */
658
function radius_ready($dsp) {
659
    foreach (array($dsp->host1_v4, $dsp->host2_v4) as $host) {
660
        $connection = @fsockopen($host, \config\Master::MANAGEDSP['radiusconfigport']);
0 ignored issues
show
The constant config\Master::MANAGEDSP was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
661
        if (is_resource($connection)) {
662
           fclose($connection);
663
        } else {
664
           return false;
665
        }
666
    }
667
    return true;
668
}
669
670
?>
671
<h2 style='display: flex;'><?php printf(_("%s: %s Deployment Details"), $uiElements->nomenclatureParticipant, $uiElements->nomenclatureHotspot); ?>&nbsp;
672
            <?php
673
            if ($readonly === FALSE && $editMode === 'fullaccess') {
674
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0) {
675
                    // the button is greyed out if there's no support email address configured...
676
                    $hasMail = count($my_inst->getAttributes("support:email"));
677
                    ?>
678
                    <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
679
                        <div>
680
                            <input type="hidden" name="consortium" value="eduroam"/>
681
                            <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
682
                                <?php echo sprintf(_("Add %s deployment ..."), \config\ConfAssistant::CONSORTIUM['name'] . " " . \core\DeploymentManaged::PRODUCTNAME); ?>
683
                            </button>
684
                            <span style='color: red;'>
685
                            <?php if ($hasMail == 0) { 
686
                              echo _("Helpdesk mail address is required but missing!");  
687
                            }
688
                            ?>
689
                            </span>
690
                        </div>
691
                    </form>
692
                    
693
                    <?php 
694
                    /*
695
                    if (count($myfed->getAttributes("fed:openroaming")) > 0) {
696
                        ?>
697
                        &nbsp;
698
                        <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
699
                            <div>
700
                                <input type="hidden" name="consortium" value="OpenRoaming"/>
701
                                <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
702
                                    <?php echo sprintf(_("Add %s deployment ..."), "OpenRoaming ANP"); ?>
703
                                </button>
704
705
                            </div>
706
                        </form>
707
                        <?php
708
                    }
709
                    */
710
                }
711
            }
712
            ?>
713
        </h2>
714
<?php
715
        $hotspotProfiles = $my_inst->listDeployments();
716
        if (count($hotspotProfiles) == 0) { // no profiles yet.
717
            echo sprintf(_("There are not yet any known deployments for your %s."), $uiElements->nomenclatureHotspot);
718
        }
719
720
        foreach ($hotspotProfiles as $counter => $deploymentObject) {
721
            switch (get_class($deploymentObject)) {
722
                case "core\DeploymentManaged":
723
                    displayDeploymentPropertyWidget($deploymentObject, $errormsg);
724
                    break;
725
                case "core\DeploymentClassic":
726
                    displayClassicHotspotPropertyWidget($deploymentObject);
727
                    break;
728
                default:
729
                    throw new Exception("We were asked to operate on something that is neither a classic nor a Managed hotspot deployment!");
730
            }
731
        }
732
?>
733