Issues (24)

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/model/EcommerceVote.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 EcommerceVote extends DataObject
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
    public static $db = array(
6
        "SessionID" => "Varchar(64)"
7
    );
8
9
    public static $has_one = array(
10
        "Page" => "SiteTree"
11
    );
12
13
    protected static $array_of_classes_used = array();
14
    public static function set_array_of_classes_used($v)
15
    {
16
        self::$array_of_classes_used = $v;
17
    }
18
    public static function get_array_of_classes_used()
19
    {
20
        return self::$array_of_classes_used;
21
    }
22
23
    protected static $create_defaults = false;
24
    public static function set_create_defaults($v)
25
    {
26
        self::$create_defaults = $v;
27
    }
28
    public static function get_create_defaults()
29
    {
30
        return self::$create_defaults;
31
    }
32
33
    protected static $default_votes = 100;
34
    public static function set_default_votes($v)
35
    {
36
        self::$default_votes = $v;
37
    }
38
    public static function get_default_votes()
39
    {
40
        return self::$default_votes;
41
    }
42
43
    protected static $random_size_to_add_to_default = 10;
44
    public static function set_random_size_to_add_to_default($v)
45
    {
46
        self::$random_size_to_add_to_default = $v;
47
    }
48
    public static function get_random_size_to_add_to_default()
49
    {
50
        return self::$random_size_to_add_to_default;
51
    }
52
53
    public static $has_many = array();
54
55
    public static $many_many = array();
56
57
    public static $belongs_many_many = array();
58
59
    public static $many_many_extraFields = array();
60
61
    //database related settings
62
    public static $indexes = array(
63
        "SessionID" => true,
64
    );
65
66
    public function onBeforeWrite()
67
    {
68
        parent::onBeforeWrite();
69
        if (!$this->SessionID) {
0 ignored issues
show
The property SessionID does not exist on object<EcommerceVote>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
70
            $this->SessionID = Session_ID();
0 ignored issues
show
The property SessionID does not exist on object<EcommerceVote>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
71
        }
72
    }
73
74
    public function onAfterWrite()
75
    {
76
        parent::onAfterWrite();
77
        if (DataObject::get_one("EcommerceVote", "SessionID = '".Session_ID()."' AND PageID =".$this->PageID." AND ID <> ".$this->ID)) {
0 ignored issues
show
The property PageID does not exist on object<EcommerceVote>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property ID does not exist on object<EcommerceVote>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
78
            $this->delete();
79
        }
80
    }
81
82
83
    public function requireDefaultRecords()
84
    {
85
        parent::requireDefaultRecords();
86
        $objects = DataObject::get("EcommerceVote", $filter = "", $sort = "Created DESC", $join = "", $limit = "0, 1000");
87
        $array = array();
88
        if ($objects) {
89
            foreach ($objects as $obj) {
90
                if (isset($array[$obj->PageID])) {
91
                    if ($array[$obj->PageID] == $obj->SessionID) {
92
                        $obj->delete();
93
                        DB::alteration_message("deleting double vote", "deleted");
94
                    }
95
                } else {
96
                    $array[$obj->PageID] = $obj->SessionID;
97
                }
98
            }
99
        }
100
        unset($array);
101
        $array = null;
0 ignored issues
show
$array is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
102
        if (self::get_create_defaults()) {
103
            $array = self::get_array_of_classes_used();
104
            if (!is_array($array)|| !count($array)) {
105
                $array = array("SiteTree");
106
            }
107
            if (count($array)) {
108
                foreach ($array as $className) {
109
                    $pages = DataObject::get($className, "EcommerceVote.ID IS NULL", $sort = "", $join = "LEFT JOIN EcommerceVote on EcommerceVote.PageID = SiteTree.ID");
110
                    if ($pages) {
111
                        foreach ($pages as $page) {
112
                            $number = intval(self::get_default_votes() + rand(0, self::get_random_size_to_add_to_default()));
113
                            $i = 0;
114
                            while ($i < $number) {
115
                                $obj = new EcommerceVote();
116
                                $obj->PageID = $page->ID;
0 ignored issues
show
The property PageID does not exist on object<EcommerceVote>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
117
                                $obj->SessionID = "default_votes_".$i;
0 ignored issues
show
The property SessionID does not exist on object<EcommerceVote>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
118
                                $obj->write();
119
                                DB::alteration_message("creating vote $i for ".$page->Title, "created");
120
                                $i++;
121
                            }
122
                        }
123
                    } else {
124
                        DB::alteration_message("no pages for $className", "deleted");
125
                    }
126
                }
127
            } else {
128
                DB::alteration_message("classname array is empty", "deleted");
129
            }
130
        } else {
131
            DB::alteration_message("not creating defaults in EcommerceVote", "deleted");
132
        }
133
    }
134
135
    public static $searchable_fields = array("PageID");
136
137
    public static $field_labels = array("PageID" => "Page");
138
139
    public static $summary_fields = array("Page.Title");
140
141
    public static $singular_name = "Vote";
142
    public function i18n_single_name()
143
    {
144
        return _t("EcommerceVote.ECOMMERCEVOTE", "Vote");
145
    }
146
147
    public static $plural_name = "Votes";
148
    public function i18n_plural_name()
149
    {
150
        return _t("EcommerceVote.ECOMMERCEVOTES", "Votes");
151
    }
152
}
153
154
155
class EcommerceVote_ModelAdmin extends ModelAdmin
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
156
{
157
    public static $managed_models = array("EcommerceVote");
158
    public static $url_segment = 'votes';
159
    public static $menu_title = 'Votes';
160
}
161