This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 BrowseCountriesPage extends BrowseAbstractPage |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | /** |
||
7 | * Standard SS static |
||
8 | **/ |
||
9 | public static $icon = "geobrowser/images/treeicons/BrowseCountriesPage"; |
||
10 | |||
11 | /** |
||
12 | * Standard SS static |
||
13 | **/ |
||
14 | public static $allowed_children = array("BrowseRegionsPage"); |
||
15 | |||
16 | /** |
||
17 | * Standard SS static |
||
18 | **/ |
||
19 | public static $default_child = "BrowseRegionsPage"; |
||
20 | |||
21 | /** |
||
22 | * Standard SS static |
||
23 | **/ |
||
24 | public static $default_parent = "BrowseContinentsPage"; |
||
25 | |||
26 | /** |
||
27 | * Standard SS static |
||
28 | **/ |
||
29 | public static $can_be_root = false; |
||
30 | |||
31 | /** |
||
32 | * Standard SS static |
||
33 | **/ |
||
34 | public static $db = array( |
||
35 | "Country" => "Varchar(50)" , |
||
36 | "ISO2" => "Varchar(2)" , |
||
37 | "Internet" => "Varchar(2)" , |
||
38 | "Capital" => "Varchar(25)" , |
||
39 | "NationalitySingular" => "Varchar(35)" , |
||
40 | "NationalityPlural" => "Varchar(35)" , |
||
41 | "Currency" => "Varchar(30)" , |
||
42 | "CurrencyCode" => "Varchar(3)" , |
||
43 | "Population" => "Int" , |
||
44 | "AdditionalTitle" => "Varchar(50)" |
||
45 | ); |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Standard SS Static |
||
50 | **/ |
||
51 | public static $defaults = array( |
||
52 | "ShowInMenus" => false |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * Standard SS Method |
||
57 | **/ |
||
58 | public function getCMSFields() |
||
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 ![]() |
|||
59 | { |
||
60 | $fields = parent::getCMSFields(); |
||
61 | return $fields; |
||
62 | } |
||
63 | |||
64 | public function GeoLevelName() |
||
65 | { |
||
66 | return "Countries"; |
||
67 | } |
||
68 | |||
69 | public function GeoLevelNumber() |
||
70 | { |
||
71 | return 1; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Standard SS Method |
||
76 | * Setup records |
||
77 | * |
||
78 | **/ |
||
79 | public function requireDefaultRecords() |
||
0 ignored issues
–
show
requireDefaultRecords uses the super-global variable $_GET which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
80 | { |
||
81 | parent::requireDefaultRecords(); |
||
82 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
83 | $parents = DataObject::get("BrowseCountriesPage"); |
||
84 | if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
||
85 | foreach ($parents as $parent) { |
||
86 | if ($parent->HiddenDataID) { |
||
87 | echo "<li>creating regions for ".$parent->Title."<ul>"; |
||
88 | $regions = $this->getDataFromTable("regions", "CountryID = ".$parent->HiddenDataID, "Region"); |
||
89 | foreach ($regions as $region) { |
||
90 | if (!DataObject::get("BrowseRegionsPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = ".$region["RegionID"])) { |
||
91 | $page = new BrowseRegionsPage(); |
||
92 | $page->CreateRegion($region, $parent); |
||
93 | $page->destroy(); |
||
94 | } |
||
95 | } |
||
96 | echo "</ul></li>"; |
||
97 | } else { |
||
98 | if (isset($_GET["geobuild"])) { |
||
99 | debug::show("Parent does not exist"); |
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | } |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Create a country based on an array and a Continent Parent |
||
108 | **/ |
||
109 | public function CreateCountry(array $country, BrowseContinentsPage $parent) |
||
0 ignored issues
–
show
CreateCountry uses the super-global variable $_GET which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
110 | { |
||
111 | if ($parent && isset($country["Country"])) { |
||
112 | $name = htmlentities($country["Country"]); |
||
113 | if ($name) { |
||
114 | if (isset($_GET["geobuild"])) { |
||
115 | echo "<li>creating ".$name."</li>"; |
||
116 | } |
||
117 | $this->ParentID = $parent->ID; |
||
118 | $this->Title = $name; |
||
119 | $this->MetaTitle = $name; |
||
120 | $this->MenuTitle = $name; |
||
121 | $this->HiddenDataID = $country["CountryID"]; |
||
122 | $this->ISO2 = $country["ISO2"]; |
||
123 | $this->Internet = $country["Internet"]; |
||
124 | $this->Capital = htmlentities($country["Capital"]); |
||
125 | $this->NationalitySingular = htmlentities($country["NationalitySingular"]); |
||
126 | $this->NationalityPlural = htmlentities($country["NationalityPlural"]); |
||
127 | $this->Currency = $country["Currency"]; |
||
128 | $this->CurrencyCode = $country["CurrencyCode"]; |
||
129 | $this->Population = $country["Population"]; |
||
130 | $this->AdditionalTitle = htmlentities($country["Title"]); |
||
131 | |||
132 | $this->CreateChildren = $parent->CreateAllChildren; |
||
133 | $this->CreateAllChildren = $parent->CreateAllChildren; |
||
134 | |||
135 | $this->writeToStage('Stage'); |
||
136 | $this->publish('Stage', 'Live'); |
||
137 | $this->flushCache(); |
||
138 | } else { |
||
139 | if (isset($_GET["geobuild"])) { |
||
140 | debug::show("name does not exist"); |
||
141 | } |
||
142 | } |
||
143 | } else { |
||
144 | if (isset($_GET["geobuild"])) { |
||
145 | debug::show("Parent does not exist"); |
||
146 | } |
||
147 | } |
||
148 | } |
||
149 | } |
||
150 | |||
151 | class BrowseCountriesPage_Controller extends BrowseAbstractPage_Controller |
||
0 ignored issues
–
show
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. ![]() |
|||
152 | { |
||
153 | } |
||
154 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.