Completed
Push — master ( b41a6b...ee7378 )
by Terrence
13:54
created

index-site.php (3 issues)

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__ . '/config.php';
7
include_once __DIR__ . '/config.secrets.php';
8
require_once __DIR__ . '/index-functions.php';
9
10
use CILogon\Service\Util;
11
use CILogon\Service\Content;
12
use CILogon\Service\ShibError;
13
use CILogon\Service\Loggit;
14
15
Util::startPHPSession();
16
17
// Util::startTiming();
18
// Util::$timeit->printTime('MAIN Program START...');
19
20
// Check for a Shibboleth error and handle it
21
$shiberror = new ShibError();
22
23
// Check the csrf cookie against either a hidden <form> element or a
24
// PHP session variable, and get the value of the 'submit' element.
25
// Note: replace CR/LF with space for 'Show/Hide Help' buttons.
26
$retchars = array("\r\n","\n","\r");
27
$submit = str_replace(
28
    $retchars,
29
    " ",
30
    Util::getCsrf()->verifyCookieAndGetSubmit()
31
);
32
Util::unsetSessionVar('submit');
33
34
$log = new Loggit();
35
$log->info('submit="' . $submit . '"');
36
37
// Depending on the value of the clicked 'submit' button or the
38
// equivalent PHP session variable, take action or print out HTML.
39
switch ($submit) {
40
    case 'Log On': // Check for OpenID or InCommon usage.
41
    case 'Continue': // For OOI
42
        Content::handleLogOnButtonClicked();
43
        break; // End case 'Log On'
44
45
    case 'Log Off':   // Click the 'Log Off' button
46
        printLogonPage(true);
0 ignored issues
show
The call to printLogonPage() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
47
        break; // End case 'Log Off'
48
49
    case 'gotuser': // Return from the getuser script
50
        Content::handleGotUser();
51
        break; // End case 'gotuser'
52
53
    case 'Go Back': // Return to the Main page
54
    case 'Proceed': // Proceed after Error page
55
        Util::verifySessionAndCall('printMainPage');
0 ignored issues
show
'printMainPage' 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...
56
        break; // End case 'Go Back' / 'Proceed'
57
58
    case 'Cancel': // Cancel button on WAYF page - go to Google
59
        header('Location: https://www.google.com/');
60
        exit; // No further processing necessary
61
        break;
62
63
    case 'Get New Certificate':
64
        if (Util::verifySessionAndCall('CILogon\\Service\\Content::generateP12')) {
0 ignored issues
show
'CILogon\\Service\\Content::generateP12' 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...
65
            printMainPage();
66
        }
67
        break; // End case 'Get New Certificate'
68
69
    case 'Show  Help ': // Toggle showing of help text on and off
70
    case 'Hide  Help ':
71
        Content::handleHelpButtonClicked();
72
        break; // End case 'Show Help' / 'Hide Help'
73
74
    default: // No submit button clicked nor PHP session submit variable set
75
        Content::handleNoSubmitButtonClicked();
76
        break; // End default case
77
} // End switch($submit)
78
79
// Util::$timeit->printTime('MAIN Program END...  ');
80