Issues (38)

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/api/DynamicGoogleMapSmarter.php (32 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
4
class DynamicGoogleMapSmarter extends Object
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...
5
{
6
7
    /**
8
     * points are formatted like this:
9
     *  - points:[
10
     *      - id: ...
11
     *      - title: ....
12
     *      - address: ...
13
     *      - lat: ...
14
     *      - lng: ....
15
     *    ]
16
     * address OR lat / lng are optional (set lat / lng to zero to )
17
     *
18
     * @param  array $points
19
     * @param  string $markerCallback (optional)
0 ignored issues
show
Should the type for parameter $markerCallback not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
20
     * @return this
0 ignored issues
show
Should the return type not be DynamicGoogleMapSmarter?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
21
     */
22
    public function createMap($points, $markerCallback = null)
0 ignored issues
show
The parameter $markerCallback is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        $googleJS =
25
            "//maps.googleapis.com/maps/api/js"
26
            ."?v=".Config::inst()->get('GoogleMapSmarter', "api_version")
27
            ."&libraries=places"
28
            ."&key=".Config::inst()->get('GoogleMapSmarter', "api_key");
29
        Requirements::javascript($googleJS);
30
        Requirements::javascript('google_map_smarter/javascript/GoogleMapSmarter.js');
31
        $fx = $this->getMapVariable('markerCallbackFX', 'marker_callback_fx');
32
        $dLat = $this->getMapVariable('defaultLocationLat', 'default_location_lat');
33
        $dLng = $this->getMapVariable('defaultLocationLng', 'default_location_lng');
34
        Requirements::customScript('
35
                if(typeof GoogleMapSmarterOptions === "undefined") {
36
                    var GoogleMapSmarterOptions = [];
37
                }
38
                GoogleMapSmarterOptions.push({
39
                    id: "'.$this->getMapVariable('mapID', 'map_id').'",
40
                    iconIsRetinaSize:  '.($this->getMapVariable('iconIsRetinaSize', 'icon_is_retina_size') ? 1 : 0).',
41
                    iconURL:  "'.$this->getMapVariable('iconURL', 'icon_url').'",
42
                    iconWidth:  '.$this->getMapVariable('iconWidth', 'icon_width').',
43
                    iconHeight: '.$this->getMapVariable('iconHeight', 'icon_height').',
44
                    defaultZoom: '.$this->getMapVariable('defaultZoom', 'default_zoom').',
45
                    defaultLocation: {
46
                        lat: '.($dLat ? $dLat : 0).',
47
                        lng: '.($dLng ? $dLng : 0).'
48
                    },
49
                    points: '.json_encode($points).',
50
                    markerCallbackFX: '.($fx ? $fx : 'null').'
51
                });
52
            ',
53
            'CustomScript'.$this->getMapVariable('mapID', 'map_id')
54
        );
55
56
        return $this;
57
    }
58
59
    private static $map_id = 'google-map';
0 ignored issues
show
The property $map_id 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...
60
61
    private static $icon_is_retina_size = true;
0 ignored issues
show
The property $icon_is_retina_size 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...
62
63
    private static $icon_url = 'http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/map-marker-icon.png';
0 ignored issues
show
The property $icon_url 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...
64
65
    private static $icon_width = 90;
0 ignored issues
show
The property $icon_width 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...
66
67
    private static $icon_height = 90;
0 ignored issues
show
The property $icon_height 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...
68
69
    private static $default_zoom = 7;
0 ignored issues
show
The property $default_zoom 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...
70
71
    private static $default_location_lat = -45;
0 ignored issues
show
The property $default_location_lat 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...
72
73
    private static $default_location_lng = 174;
0 ignored issues
show
The property $default_location_lng 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...
74
75
    private static $marker_callback_fx = null;
0 ignored issues
show
The property $marker_callback_fx 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...
76
77
    protected $mapID = null;
78
79
    protected $iconIsRetinaSize = null;
80
81
    protected $iconURL = null;
82
83
    protected $iconWidth = null;
84
85
    protected $iconHeight = null;
86
87
    protected $defaultZoom = null;
88
89
    protected $defaultLocationLat = null;
90
91
    protected $defaultLocationLng = null;
92
93
    protected $markerCallbackFx = null;
94
95
    public function setMapID($s)
96
    {
97
        return $this->setMapVariable('mapID', $s);
98
    }
99
100
    public function getMapID($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102
        return $this->getMapVariable('mapID', 'map_id');
103
    }
104
105
    public function setIconIsRetinaSize($s)
106
    {
107
        return $this->setMapVariable('iconIsRetinaSize',  $s);
108
    }
109
110
    public function getIconIsRetinaSize($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
111
    {
112
        return $this->getMapVariable('iconIsRetinaSize', 'icon_is_retina_size');
113
    }
114
115
116
    public function setIconURL($s)
117
    {
118
        return $this->setMapVariable('iconURL',  $s);
119
    }
120
121
    public function getIconURL($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
122
    {
123
        return $this->getMapVariable('iconURL', 'icon_url');
124
    }
125
126
    public function setIconWidth($s)
127
    {
128
        return $this->setMapVariable('iconWidth',  $s);
129
    }
130
131
    public function getIconWidth($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
132
    {
133
        return $this->getMapVariable('iconWidth', 'icon_width');
134
    }
135
136
    public function setIconHeight($s)
137
    {
138
        return $this->setMapVariable('iconHeight', $s);
139
    }
140
141
    public function getIconHeight($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
142
    {
143
        return $this->getMapVariable('iconHeight', 'icon_height');
144
    }
145
146
    public function setDefaultZOom($s)
147
    {
148
        return $this->setMapVariable('defaultZoom', $s);
149
    }
150
151
    public function getDefaultZoom($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
152
    {
153
        return $this->getMapVariable('defaultZoom', 'defaultZoom');
154
    }
155
156
    public function setDefaultLocationLat($s)
157
    {
158
        return $this->setMapVariable('defaultLocationLat', $s);
159
    }
160
161
    public function getDefaultLocationLat($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
162
    {
163
        return $this->getMapVariable('defaultLocationLat', 'defaultLocation_lat');
164
    }
165
166
    public function setDefaultLocationLng($s)
167
    {
168
        return $this->setMapVariable('defaultLocationLng', $s);
169
    }
170
171
    public function getDefaultLocationLng($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
172
    {
173
        return $this->getMapVariable('defaultLocationLng', 'defaultLocation_lng');
174
    }
175
176
    public function setMarkerCallbackFX($s)
177
    {
178
        return $this->setMapVariable('markerCallbackFX', $s);
179
    }
180
181
    public function getMarkerCallbackFX($s)
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...
The parameter $s is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
182
    {
183
        return $this->getMapVariable('markerCallbackFX', 'marker_callback_fx');
184
    }
185
186
    /**
187
     *
188
     *
189
     * @param string $internalVariableName the variable name
190
     * @param string $staticVariableName   the static variable name
191
     *
192
     * @param return this
193
     */
194
    protected function getMapVariable($internalVariableName, $staticVariableName)
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...
195
    {
196
        if ($this->$internalVariableName !== null) {
197
            return $this->$internalVariableName;
198
        } else {
199
            return $this->Config()->$staticVariableName;
200
        }
201
    }
202
203
    /**
204
     *
205
     *
206
     * @param string $internalVariableName the variable name
207
     * @param mixed $s                     the variable to set
208
     *
209
     * @param return this
210
     */
211
    protected function setMapVariable($internalVariableName, $s)
212
    {
213
        $this->$internalVariableName = $s;
214
        return $this;
215
    }
216
}
217