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 | * Defines the StaffPage page type. |
||
4 | */ |
||
5 | class SlidePage extends Page |
||
0 ignored issues
–
show
|
|||
6 | { |
||
7 | public static $db = array( |
||
8 | 'Caption' => 'Text', |
||
9 | ); |
||
10 | |||
11 | public static $has_one = array( |
||
12 | 'Photo' => 'Image', |
||
13 | 'InternalPage' => 'SiteTree', |
||
14 | ); |
||
15 | |||
16 | public static $allowed_children = 'none'; |
||
17 | |||
18 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
19 | 'ShowInMenus' => false, |
||
20 | 'ShowInSearch' => false, |
||
21 | ); |
||
22 | |||
23 | public function getThumbnail2() |
||
24 | { |
||
25 | return $this->InternalPage()->getPortletImage()->CMSThumbnail()->Tag; |
||
26 | } |
||
27 | |||
28 | public function getCMSFields() |
||
29 | { |
||
30 | Requirements::javascript('slider/javascript/slideredit.js'); |
||
31 | |||
32 | $fields = parent::getCMSFields(); |
||
33 | $existing_photo = null; |
||
34 | $photo_field = null; |
||
0 ignored issues
–
show
$photo_field 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 ![]() |
|||
35 | $internal_page = $this->InternalPage(); |
||
36 | |||
37 | if ($internal_page instanceof RenderableAsPortlet) { |
||
0 ignored issues
–
show
The class
RenderableAsPortlet does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
38 | error_log('Class implements renderable as a portlet'); |
||
39 | $existing_photo = $this->InternalPage()->getPortletImage(); |
||
40 | } else { |
||
41 | // check parents recursively |
||
42 | $parents = class_parents($internal_page); |
||
43 | error_log(print_r($parents, 1)); |
||
44 | } |
||
45 | |||
46 | $fields->addFieldToTab('Root.Main', |
||
47 | new TreeDropdownField('InternalPageID', _t('SlidePage.CHOOSE_INTERNAL_LINK', 'Select a page on the website to link to'), 'SiteTree')); |
||
48 | |||
49 | $composite_photoField = null; |
||
0 ignored issues
–
show
$composite_photoField 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 ![]() |
|||
50 | |||
51 | if (!$existing_photo) { |
||
52 | $photo_field = new UploadField('Photo', _t('SlidePage.PHOTO', 'Photo')); |
||
53 | $photo_info = new LiteralField('PhotoInfo', _t('Slide.PHOTO_INFO', 'If the page you choose to link to has an image already it will appear here'), 'Photo'); |
||
0 ignored issues
–
show
The call to
LiteralField::__construct() has too many arguments starting with 'Photo' .
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 ![]() |
|||
54 | $composite_photoField = CompositeField::create($photo_field, $photo_info); |
||
55 | } else { |
||
56 | // FIXME, find a cleaner way of doing this |
||
57 | $composite_photoField = new LiteralField('Thumbnail2', '<div id="Thumbnail2" class="field readonly"> |
||
58 | <label class="left" for="Form_EditForm_Thumbnail2">Photo</label> |
||
59 | <div class="middleColumn"> |
||
60 | <span id="Form_EditForm_Thumbnail2" class="readonly"> |
||
61 | <img src="'.$existing_photo->SetWidth(400)->URL.'" alt="'.$existing_photo->Title.'" /> |
||
62 | </span> |
||
63 | </div> |
||
64 | </div>'); |
||
65 | } |
||
66 | |||
67 | $composite_photoField->setTitle('Photo'); |
||
68 | $fields->addFieldToTab('Root.Main', $composite_photoField); |
||
69 | $fields->addFieldToTab('Root.Main', new TextField('Caption', _t('SlidePage.CAPTION', 'Caption'))); |
||
70 | $fields->renameField('Title', 'Slide Title'); |
||
71 | |||
72 | $fields->removeFieldFromTab('Root.Main', 'Content'); |
||
73 | |||
74 | return $fields; |
||
75 | } |
||
76 | |||
77 | /* |
||
78 | Accessible from templates as $PortletImage |
||
79 | */ |
||
80 | public function getPortletImage() |
||
81 | { |
||
82 | $image = null; |
||
0 ignored issues
–
show
$image 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 ![]() |
|||
83 | if ($this->InternalPage() instanceof RenderableAsPortlet) { |
||
0 ignored issues
–
show
The class
RenderableAsPortlet does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
84 | $image = $this->InternalPage()->getPortletImage(); |
||
85 | } else { |
||
86 | $image = $this->Photo(); |
||
87 | } |
||
88 | |||
89 | return $image; |
||
90 | } |
||
91 | |||
92 | public function getThumbnail() |
||
93 | { |
||
94 | if ($Image = $this->Photo()) { |
||
95 | return $Image->CMSThumbnail(); |
||
96 | } else { |
||
97 | return '(No Image)'; |
||
98 | } |
||
99 | } |
||
100 | |||
101 | public function getWebsiteAddress() |
||
102 | { |
||
103 | $result = '#"'; |
||
104 | |||
105 | if ($this->InternalPageID) { |
||
106 | $targetPage = DataObject::get_by_id('Page', $this->InternalPageID); |
||
107 | if ($targetPage) { |
||
108 | $result = $targetPage->Link(); |
||
109 | } else { |
||
110 | $result = '#'; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | return $result; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | class SlidePage_Controller extends Page_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. ![]() This class is not in CamelCase format.
Classes in PHP are usually named in CamelCase. In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well. Thus the name database provider becomes ![]() |
|||
119 | { |
||
120 | private static $allowed_actions = array('newpageselected' => true); |
||
0 ignored issues
–
show
|
|||
121 | |||
122 | /* |
||
123 | When a new item is selected return JSON containing the title and image |
||
124 | */ |
||
125 | public function newpageselected(SS_HTTPRequest $request) |
||
126 | { |
||
127 | $sitetree_id = $request->param('ID'); |
||
128 | $page = SiteTree::get_by_id($sitetree_id); |
||
129 | $result = array(); |
||
130 | if ($page) { |
||
131 | $result['Title'] = $page->Title; |
||
132 | } |
||
133 | return json_encode($result); |
||
134 | } |
||
135 | } |
||
136 |
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.