Completed
Push — master ( 8eeafe...eaa09a )
by Terrence
14:19
created

index-site.php (5 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
// error_reporting(E_ALL); ini_set('display_errors',1);
4
5
require_once __DIR__ . '/vendor/autoload.php';
6
require_once __DIR__ . '/index-functions.php';
7
8
use CILogon\Service\Util;
9
use CILogon\Service\Content;
10
use CILogon\Service\ShibError;
11
use CILogon\Service\Loggit;
12
13
Util::startPHPSession();
14
15
// Util::startTiming();
16
// Util::$timeit->printTime('MAIN Program START...');
17
18
// Check for a Shibboleth error and handle it
19
$shiberror = new ShibError();
20
21
// Check the csrf cookie against either a hidden <form> element or a
22
// PHP session variable, and get the value of the 'submit' element.
23
// Note: replace CR/LF with space for 'Show/Hide Help' buttons.
24
$retchars = array("\r\n","\n","\r");
25
$submit = str_replace(
26
    $retchars,
27
    " ",
28
    Util::getCsrf()->verifyCookieAndGetSubmit()
29
);
30
Util::unsetSessionVar('submit');
31
32
$log = new Loggit();
33
$log->info('submit="' . $submit . '"');
34
35
// Depending on the value of the clicked 'submit' button or the
36
// equivalent PHP session variable, take action or print out HTML.
37
switch ($submit) {
38
    case 'Log On': // Check for OpenID or InCommon usage.
39
    case 'Continue': // For OOI
40
        Content::handleLogOnButtonClicked();
41
        break; // End case 'Log On'
42
43
    case 'Log Off':   // Click the 'Log Off' button
44
        printLogonPage(true);
45
        break; // End case 'Log Off'
46
47
    case 'gotuser': // Return from the getuser script
48
        Content::handleGotUser();
49
        break; // End case 'gotuser'
50
51
    case 'Go Back': // Return to the Main page
52
    case 'Proceed': // Proceed after 'User Changed' or Error page
53
    case 'Done with Two-Factor':
54
        Util::verifySessionAndCall('printMainPage');
55
        break; // End case 'Go Back' / 'Proceed'
56
57
    case 'Cancel': // Cancel button on WAYF page - go to Google
58
        header('Location: https://www.google.com/');
59
        exit; // No further processing necessary
60
        break;
61
62
    case 'Get New Certificate':
63
        if (Util::verifySessionAndCall('CILogon\\Service\\Content::generateP12')) {
64
            printMainPage();
65
        }
66
        break; // End case 'Get New Certificate'
67
68
    case 'Manage Two-Factor':
69
        Util::verifySessionAndCall(
70
            'CILogon\\Service\\Content::printTwoFactorPage'
0 ignored issues
show
'CILogon\\Service\\Content::printTwoFactorPage' is of type string, but the function expects a object<CILogon\Service\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
71
        );
72
        break; // End case 'Manage Two-Factor'
73
74
    case 'Enable':   // Enable / Disable two-factor authentication
75
    case 'Disable':
76
    case 'Verify':   // Log in with Google Authenticator
77
    case 'Disable Two-Factor':
78
        $enable = !preg_match('/^Disable/', $submit);
79
        Util::verifySessionAndCall(
80
            'CILogon\\Service\\Content::handleEnableDisableTwoFactor',
0 ignored issues
show
'CILogon\\Service\\Conte...EnableDisableTwoFactor' is of type string, but the function expects a object<CILogon\Service\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
81
            array($enable)
82
        );
83
        break; // End case 'Enable' / 'Disable'
84
85
    case 'I Lost My Phone':
86
        Util::verifySessionAndCall(
87
            'CILogon\\Service\\Content::handleILostMyPhone'
0 ignored issues
show
'CILogon\\Service\\Content::handleILostMyPhone' is of type string, but the function expects a object<CILogon\Service\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
88
        );
89
        break; // End case 'I Lost My Phone'
90
91
    case 'Enter': // Verify Google Authenticator one time password
92
        Util::verifySessionAndCall(
93
            'CILogon\\Service\\Content::handleGoogleAuthenticatorLogin'
0 ignored issues
show
'CILogon\\Service\\Conte...ogleAuthenticatorLogin' is of type string, but the function expects a object<CILogon\Service\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
94
        );
95
        break; // End case 'Enter'
96
97
    case 'EnterDuo': // Verify Duo Security login
98
        Util::verifySessionAndCall(
99
            'CILogon\\Service\\Content::handleDuoSecurityLogin'
0 ignored issues
show
'CILogon\\Service\\Conte...handleDuoSecurityLogin' is of type string, but the function expects a object<CILogon\Service\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
100
        );
101
        break; // End case 'EnterDuo'
102
103
    case 'Show  Help ': // Toggle showing of help text on and off
104
    case 'Hide  Help ':
105
        Content::handleHelpButtonClicked();
106
        break; // End case 'Show Help' / 'Hide Help'
107
108
    default: // No submit button clicked nor PHP session submit variable set
109
        Content::handleNoSubmitButtonClicked();
110
        break; // End default case
111
} // End switch($submit)
112
113
// Util::$timeit->printTime('MAIN Program END...  ');
114