Completed
Push — master ( 0db328...7ae14e )
by Terrence
21:23 queued 06:24
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
Util::unsetSessionVar('storeattributes'); // Used only by /testidp/
34
35
$log = new Loggit();
36
$log->info('submit="' . $submit . '"');
37
38
// Depending on the value of the clicked 'submit' button or the
39
// equivalent PHP session variable, take action or print out HTML.
40
switch ($submit) {
41
    case 'Log On': // Check for OpenID or InCommon usage.
42
    case 'Continue': // For OOI
43
        Content::handleLogOnButtonClicked();
44
        break; // End case 'Log On'
45
46
    case 'Log Off':   // Click the 'Log Off' button
47
        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...
48
        break; // End case 'Log Off'
49
50
    case 'gotuser': // Return from the getuser script
51
        Content::handleGotUser();
52
        break; // End case 'gotuser'
53
54
    case 'Go Back': // Return to the Main page
55
    case 'Proceed': // Proceed after Error page
56
        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...
57
        break; // End case 'Go Back' / 'Proceed'
58
59
    case 'Cancel': // Cancel button on WAYF page - go to CILogon Info Page
60
        header('Location: https://www.cilogon.org');
61
        exit; // No further processing necessary
62
        break;
63
64
    case 'Get New Certificate':
65
        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...
66
            printMainPage();
67
        }
68
        break; // End case 'Get New Certificate'
69
70
    default: // No submit button clicked nor PHP session submit variable set
71
        Content::handleNoSubmitButtonClicked();
72
        break; // End default case
73
} // End switch($submit)
74
75
// Util::$timeit->printTime('MAIN Program END...  ');
76