GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (8)

Security Analysis    not enabled

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

  Cross-Site Scripting
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.
  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.
  File Manipulation
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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

view.php (2 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
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17
/**
18
 * Prints a particular instance of paypal
19
 *
20
 * You can have a rather longer description of the file as well,
21
 * if you like, and it can span multiple lines.
22
 *
23
 * @package    availability_paypal
24
 * @copyright  2015 Daniel Neis Araujo <[email protected]>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
28
require_once('../../../config.php');
29
30
$contextid = required_param('contextid', PARAM_INT);
31
32
$context = context::instance_by_id($contextid);
33
$instanceid = $context->instanceid;
34 View Code Duplication
if ($context instanceof context_module) {
0 ignored issues
show
The class context_module does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    $availability = $DB->get_field('course_modules', 'availability', array('id' => $instanceid), MUST_EXIST);
36
    $availability = json_decode($availability);
37
    foreach ($availability->c as $condition) {
38
        if ($condition->type == 'paypal') {
39
            // TODO: handle more than one paypal for this context.
40
            $paypal = $condition;
41
            break;
42
        } else {
43
            print_error('no paypal condition for this context.');
44
        }
45
    }
46
} else {
47
    // TODO: handle sections.
48
    print_error('support to sections not yet implemented.');
49
}
50
$coursecontext = $context->get_course_context();
51
$course = $DB->get_record('course', array('id' => $coursecontext->instanceid));
52
53
require_login($course);
54
55
if ($paymenttnx = $DB->get_record('availability_paypal_tnx', array('userid' => $USER->id, 'contextid' => $contextid))) {
56
57
    if ($paymenttnx->payment_status == 'Completed') {
58
        redirect($context->get_url(), get_string('paymentcompleted', 'availability_paypal'));
59
    }
60
}
61
62
$PAGE->set_url('/availability/condition/paypal/view.php', array('contextid' => $contextid));
63
$PAGE->set_title($course->fullname);
64
$PAGE->set_heading($course->fullname);
65
66
$PAGE->navbar->add($paypal->itemname);
67
68
echo $OUTPUT->header();
69
70
echo $OUTPUT->heading($paypal->itemname);
71
72
if ($paymenttnx && ($paymenttnx->payment_status == 'Pending')) {
73
    echo get_string('paymentpending', 'availability_paypal');
74
} else {
75
76
    // Calculate localised and "." cost, make sure we send PayPal the same value,
77
    // please note PayPal expects amount with 2 decimal places and "." separator.
78
    $localisedcost = format_float($paypal->cost, 2, true);
79
    $cost = format_float($paypal->cost, 2, false);
80
81
    if (isguestuser()) { // Force login only for guest user, not real users with guest role.
82
        if (empty($CFG->loginhttps)) {
83
            $wwwroot = $CFG->wwwroot;
84
        } else {
85
            // This actually is not so secure ;-), 'cause we're in unencrypted connection...
86
            $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
87
        }
88
        echo '<div class="mdl-align"><p>'.get_string('paymentrequired', 'availability_paypal').'</p>';
89
        echo '<div class="mdl-align"><p>'.get_string('paymentwaitremider', 'availability_paypal').'</p>';
90
        echo '<p><b>'.get_string('cost').": $instance->currency $localisedcost".'</b></p>';
91
        echo '<p><a href="'.$wwwroot.'/login/">'.get_string('loginsite').'</a></p>';
92
        echo '</div>';
93
    } else {
94
        // Sanitise some fields before building the PayPal form.
95
        $userfullname    = fullname($USER);
96
        $userfirstname   = $USER->firstname;
97
        $userlastname    = $USER->lastname;
98
        $useraddress     = $USER->address;
99
        $usercity        = $USER->city;
100
?>
101
        <p><?php print_string("paymentrequired", 'availability_paypal') ?></p>
102
        <p><b><?php echo get_string("cost").": {$paypal->currency} {$localisedcost}"; ?></b></p>
103
        <p><img alt="<?php print_string('paypalaccepted', 'availability_paypal') ?>"
104
        title="<?php print_string('paypalaccepted', 'availability_paypal') ?>"
105
        src="https://www.paypal.com/en_US/i/logo/PayPal_mark_60x38.gif" /></p>
106
        <p><?php print_string("paymentinstant", 'availability_paypal') ?></p>
107
        <?php
108
        if (empty($CFG->usepaypalsandbox)) {
109
            $paypalurl = 'https://www.paypal.com/cgi-bin/webscr';
110
        } else {
111
            $paypalurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
112
        }
113
        ?>
114
        <form action="<?php echo $paypalurl ?>" method="post">
115
116
            <input type="hidden" name="cmd" value="_xclick" />
117
            <input type="hidden" name="charset" value="utf-8" />
118
            <input type="hidden" name="business" value="<?php p($paypal->businessemail)?>" />
119
            <input type="hidden" name="item_name" value="<?php p($paypal->itemname) ?>" />
120
            <input type="hidden" name="item_number" value="<?php p($paypal->itemnumber) ?>" />
121
            <input type="hidden" name="quantity" value="1" />
122
            <input type="hidden" name="on0" value="<?php print_string("user") ?>" />
123
            <input type="hidden" name="os0" value="<?php p($userfullname) ?>" />
124
            <input type="hidden" name="custom" value="<?php echo "{$USER->id}-{$contextid}" ?>" />
125
126
            <input type="hidden" name="currency_code" value="<?php p($paypal->currency) ?>" />
127
            <input type="hidden" name="amount" value="<?php p($cost) ?>" />
128
129
            <input type="hidden" name="for_auction" value="false" />
130
            <input type="hidden" name="no_note" value="1" />
131
            <input type="hidden" name="no_shipping" value="1" />
132
            <input type="hidden" name="notify_url" value="<?php echo "{$CFG->wwwroot}/availability/condition/paypal/ipn.php" ?>" />
133
            <?php $returnurl = $CFG->wwwroot . '/availability/condition/paypal/view.php?contextid=' . $contextid; ?>
134
            <input type="hidden" name="return" value="<?php echo $returnurl; ?>" />
135
            <input type="hidden" name="cancel_return" value="<?php echo $returnurl; ?>" />
136
            <input type="hidden" name="rm" value="2" />
137
            <input type="hidden" name="cbt" value="<?php print_string("continue", 'availability_paypal') ?>" />
138
139
            <input type="hidden" name="first_name" value="<?php p($userfirstname) ?>" />
140
            <input type="hidden" name="last_name" value="<?php p($userlastname) ?>" />
141
            <input type="hidden" name="address" value="<?php p($useraddress) ?>" />
142
            <input type="hidden" name="city" value="<?php p($usercity) ?>" />
143
            <input type="hidden" name="email" value="<?php p($USER->email) ?>" />
144
            <input type="hidden" name="country" value="<?php p($USER->country) ?>" />
145
146
            <input type="submit" value="<?php print_string("sendpaymentbutton", "availability_paypal") ?>" />
147
        </form>
148
<?php
149
    }
150
}
151
// Finish the page.
152
echo $OUTPUT->footer();
153