Passed
Push — master ( 24c82b...10ea3d )
by Stefan
10:56 queued 34s
created

print_test_results()   B

Complexity

Conditions 7
Paths 13

Size

Total Lines 26
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 22
nc 13
nop 1
dl 0
loc 26
rs 8.6346
c 0
b 0
f 0
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
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
23
24
$Tests = [
25
    'CatBaseUrl',
26
    'Ssp',
27
    'Security',
28
    'Php',
29
    'PhpModules',
30
    'Openssl',
31
    'Zip',
32
    'Directories',
33
    'Logdir',
34
    'Locales',
35
    'Defaults',
36
    'Databases',
37
    'DeviceCache',
38
    'Mailer',
39
    'Geoip',
40
    'RADIUSProbes',
41
];
42
43
$uiElements = new \web\lib\admin\UIElements();
44
45
if (\config\Master::CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL" || \config\Master::CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL" ) {
46
    $Tests[] = 'Makensis';
47
    $Tests[] = 'Makensis=>NSISmodules';
48
}
49
50
if (\config\Master::CONFIG['FUNCTIONALITY_LOCATIONS']['DIAGNOSTICS'] == "LOCAL") {
51
    $Tests[] = 'Eapoltest';
52
}
53
54
ini_set('display_errors', '0');
55
56
if (!in_array("I do not care about security!", \config\Master::CONFIG['SUPERADMINS'])) {
57
    $auth = new \web\lib\admin\Authentication();
58
    $auth->authenticate();
59
    $user = new \core\User($_SESSION['user']);
60
    if (!$user->isSuperadmin()) {
61
        throw new Exception("Not Superadmin");
62
    }
63
}
64
$test = new \core\SanityTests();
65
$test->runTests($Tests);
66
$format = empty($_REQUEST['format']) ? 'include' : $_REQUEST['format'];
67
switch ($format) {
68
    case 'include':
69
        $o = $uiElements->sanityTestResultHTML($test);
70
        print "<table>$o</table>";
71
        break;
72
    case 'html':
73
        header("Content-Type:text/html;charset=utf-8");
74
        echo "<!DOCTYPE html>
75
          <html xmlns='http://www.w3.org/1999/xhtml' lang='$ourlocale'>
76
          <head lang='$ourlocale'>
77
          <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head>";
78
79
        $o = $uiElements->sanityTestResultHTML($test);
80
        print "<body><table>$o</table></body></html>";
81
        break;
82
    case 'json':
83
        header('Content-type: application/json; utf-8');
84
        print json_encode(['global' => $test->test_result, 'details' => $test->out]);
85
        break;
86
    case 'print_r':
87
        echo "<!DOCTYPE html>
88
          <html xmlns='http://www.w3.org/1999/xhtml' lang='$ourlocale'>
89
          <head lang='$ourlocale'>
90
          <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head>";
91
        print "<body><pre>";
92
        print_r(['global' => $test->test_result, 'details' => $test->out]);
93
        print "</pre><body>";
94
        break;
95
    default:
96
        break;
97
}
98