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 BrowseContinentsPage extends BrowseAbstractPage |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | /** |
||
7 | * Standard SS static |
||
8 | **/ |
||
9 | public static $icon = "geobrowser/images/treeicons/BrowseContinentsPage"; |
||
10 | |||
11 | |||
12 | /** |
||
13 | * Standard SS static |
||
14 | **/ |
||
15 | public static $allowed_children = array("BrowseCountriesPage"); |
||
16 | |||
17 | /** |
||
18 | * Standard SS static |
||
19 | **/ |
||
20 | public static $default_child = "BrowseCountriesPage"; |
||
21 | |||
22 | /** |
||
23 | * Standard SS static |
||
24 | **/ |
||
25 | public static $default_parent = "BrowseWorldPage"; |
||
26 | |||
27 | /** |
||
28 | * Standard SS Static |
||
29 | **/ |
||
30 | public static $can_be_root = false; |
||
31 | |||
32 | /** |
||
33 | * Standard SS Static |
||
34 | **/ |
||
35 | public static $defaults = array( |
||
36 | "ShowInMenus" => true |
||
37 | ); |
||
38 | |||
39 | /** |
||
40 | * name of the level |
||
41 | **/ |
||
42 | public function GeoLevelName() |
||
43 | { |
||
44 | return "Continents"; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * number of the level |
||
49 | **/ |
||
50 | public function GeoLevelNumber() |
||
51 | { |
||
52 | return 0; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Standard SS Method |
||
57 | * setup records |
||
58 | **/ |
||
59 | 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);
}
}
![]() |
|||
60 | { |
||
61 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
62 | parent::requireDefaultRecords(); |
||
63 | $parents = DataObject::get("BrowseContinentsPage"); |
||
64 | if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
||
65 | View Code Duplication | foreach ($parents as $parent) { |
|
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. ![]() |
|||
66 | if ($parent->CreateChildren && $parent->HiddenDataID) { |
||
67 | echo "<li>creating countries for ".$parent->Title."<ul>"; |
||
68 | $countries = $this->getDataFromTable("countries", "ContinentID = ".$parent->HiddenDataID, "Country"); |
||
69 | foreach ($countries as $country) { |
||
70 | if (!DataObject::get_one("BrowseCountriesPage", "{$bt}HiddenDataID{$bt} = ".$country["CountryID"])) { |
||
71 | $page = new BrowseCountriesPage(); |
||
72 | $page->CreateCountry($country, $parent); |
||
73 | $page->destroy(); |
||
74 | } |
||
75 | } |
||
76 | echo "</ul></li>"; |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * create a continent |
||
84 | * @param array - $contentint, continent data |
||
85 | * @param Object - $parent, a BrowseWorldPage object that will be the parent page of the Continent. |
||
86 | **/ |
||
87 | public function CreateContinent(array $continent, BrowseWorldPage $parent) |
||
0 ignored issues
–
show
CreateContinent 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);
}
}
![]() |
|||
88 | { |
||
89 | $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
||
0 ignored issues
–
show
$bt 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 ![]() |
|||
90 | if ($parent && isset($continent["Continent"])) { |
||
91 | $name = htmlentities($continent["Continent"]); |
||
92 | if ($name) { |
||
93 | if (isset($_GET["geobuild"])) { |
||
94 | echo "<li>creating ".$name."</li>"; |
||
95 | } |
||
96 | $this->ParentID = $parent->ID; |
||
97 | $this->Title = $name; |
||
98 | $this->MetaTitle = $name; |
||
99 | $this->MenuTitle = $name; |
||
100 | $this->HiddenDataID = $continent["ContinentID"]; |
||
101 | $this->CreateChildren = $parent->CreateAllChildren; |
||
102 | $this->CreateAllChildren = $parent->CreateAllChildren; |
||
103 | $this->writeToStage('Stage'); |
||
104 | $this->publish('Stage', 'Live'); |
||
105 | $this->flushCache(); |
||
106 | } else { |
||
107 | if (isset($_GET["geobuild"])) { |
||
108 | debug::show("name does not exist"); |
||
109 | } |
||
110 | } |
||
111 | } else { |
||
112 | if (isset($_GET["geobuild"])) { |
||
113 | debug::show("Parent does not exist"); |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 | |||
119 | class BrowseContinentsPage_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. ![]() |
|||
120 | { |
||
121 | } |
||
122 |
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.