Issues (138)

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.

code/fields/PageRaterStarField.php (10 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
class PageRaterStarField extends FormField
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private static $extra_form_selector = '';
0 ignored issues
show
The property $extra_form_selector is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
7
    private static $allow_comments = false;
0 ignored issues
show
The property $allow_comments is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
8
9
    private static $allow_name = false;
0 ignored issues
show
The property $allow_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
11
    private static $allow_title = false;
0 ignored issues
show
The property $allow_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
13
    protected $rating = 0;
14
15
    protected $starOptions = 5;
16
17
    protected $moreFieldsArray = array();
18
19
    /**
20
     * Returns an input field, class="start field" and type="hidden" with an optional maxlength
21
     */
22
    public function __construct($name, $title = null, $value = "", $starOptions = null, $form = null)
23
    {
24
        if ($starOptions) {
25
            $this->starOptions = $starOptions;
26
        } else {
27
            $this->starOptions = PageRating::get_number_of_stars();
28
        }
29
30
        parent::__construct($name, $title, $value, $form);
0 ignored issues
show
The call to FormField::__construct() has too many arguments starting with $form.

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...
31
    }
32
33
    protected $_field_value = null;
34
35
    public function Field($properties = array())
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
36
    {
37
        if (! $this->_field_value) {
38
            Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
39
            Requirements::javascript(THIRDPARTY_DIR .'/jquery-form/jquery.form.js');
40
            Requirements::javascript('pagerater/javascript/jquery.rating.pack.js');
41
            Requirements::javascript('pagerater/javascript/PageRater.js');
42
            if ($this->Config()->get("extra_form_selector")) {
43
                Requirements::customScript("PageRater.set_extra_form_selector('".$this->Config()->get("extra_form_selector")."');");
44
            }
45
            Requirements::themedCSS('jquery.rating', "pagerater");
46
            $html = "";
47
48
            $name = $this->getName();
49
            $id = $this->id();
50
            for ($i = 1; $i < $this->starOptions + 1; $i++) {
51
                if ($i == $this->Value()) {
52
                    $html .= "<input name='$id' class='$id' type='radio' checked='checked' value='$i' />";
53
                } else {
54
                    $html .= "<input name='$id' class='$id' type='radio' value='$i' />";
55
                }
56
            }
57
            $html .= "<input name='$name' type='hidden' id='$id' />";
58
59 View Code Duplication
            if ($this->Config()->get("allow_name")) {
0 ignored issues
show
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...
60
                $fieldID = $id."_Name";
61
                $nameField = TextField::create($fieldID, _t("PageRaterStarField.NAME_LABEL", "Your Name"));
62
                $nameField->addExtraClass("additionalComments");
63
                $html .= $nameField->FieldHolder();
64
                $this->moreFieldsArray[] = $fieldID;
65
            }
66
67 View Code Duplication
            if ($this->Config()->get("allow_title")) {
0 ignored issues
show
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...
68
                $fieldID = $id."_Title";
69
                $titleField = TextField::create($fieldID, _t("PageRaterStarField.TITLE_LABEL", "Comment Header"));
70
                $titleField->addExtraClass("additionalComments");
71
                $html .= $titleField->FieldHolder();
72
                $this->moreFieldsArray[] = $fieldID;
73
            }
74
75 View Code Duplication
            if ($this->Config()->get("allow_comments")) {
0 ignored issues
show
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...
76
                $fieldID = $id."_Comment";
77
                $commentField = TextareaField::create($fieldID, _t("PageRaterStarField.COMMENTS_LABEL", "Any comments you may have"));
78
                $commentField->addExtraClass("additionalComments");
79
                $html .= $commentField->FieldHolder();
80
                $this->moreFieldsArray[] = $fieldID;
81
            }
82
            $moreFieldsAsString = implode("', '", $this->moreFieldsArray);
83
            Requirements::customScript('
84
            if(typeof PageRaterVariables === "undefined") {
85
                var PageRaterVariables = [];
86
            }
87
            PageRaterVariables.push(
88
                {
89
                    id: \''.$id.'\',
90
                    fields: [\''.$moreFieldsAsString.'\']
91
                }
92
            );
93
            ');
94
            $this->_field_value = $html;
95
        }
96
        return $this->_field_value;
97
    }
98
99
    public function getRequiredFields()
100
    {
101
        $this->Field();
102
        return $this->moreFieldsArray;
103
    }
104
}
105