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 PresentationPage extends Page |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | private static $splash_image_location = '/assets/splasimages'; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
9 | 'Website' => "Varchar(100)", |
||
10 | 'StartSlogan' => "Varchar(100)" |
||
11 | ); |
||
12 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
13 | 'BackgroundImage' => "Image" |
||
14 | ); |
||
15 | |||
16 | private static $icon = "mysite/images/treeicons/Presentation"; |
||
0 ignored issues
–
show
|
|||
17 | |||
18 | 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 ![]() |
|||
19 | { |
||
20 | $fields = parent::getCMSFields(); |
||
21 | $fields->addFieldToTab("Root.Splash", TextField::create('Website')); |
||
22 | $fields->addFieldToTab("Root.Splash", TextField::create('StartSlogan')); |
||
23 | $fields->addFieldToTab("Root.Splash", UploadField::create('BackgroundImage','Background Image')); |
||
24 | $fields->addFieldToTab("Root.Splash", HtmlEditorField::create('Content')); |
||
25 | return $fields; |
||
26 | } |
||
27 | |||
28 | } |
||
29 | |||
30 | class PresentationPage_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. ![]() |
|||
31 | { |
||
32 | |||
33 | |||
34 | function init() |
||
0 ignored issues
–
show
|
|||
35 | { |
||
36 | ContentController::init(); |
||
37 | } |
||
38 | |||
39 | |||
40 | public function index() |
||
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 ![]() |
|||
41 | { |
||
42 | return $this->renderWith('PresentationPage_Splash'); |
||
43 | } |
||
44 | |||
45 | |||
46 | /** |
||
47 | * Private variables to locally cache the selected image index and |
||
48 | * shuffled array with the images URLs |
||
49 | */ |
||
50 | private $_selectedImage = null; |
||
51 | |||
52 | private $_shuffledImages = array(); |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Returns the URL of the first image to be shown on the Splash |
||
57 | * @return String |
||
58 | */ |
||
59 | public function getRandomSplashImage() |
||
60 | { |
||
61 | |||
62 | if ($this->_selectedImage === null) { |
||
63 | if($this->BackgroundImageID) { |
||
64 | if($image = $this->BackgroundImage()) { |
||
65 | $this->_selectedImage = $image->Link(); |
||
66 | } |
||
67 | } |
||
68 | if ($this->_selectedImage === null) { |
||
69 | $this->_shuffledImages = Config::inst()->get('PresentationPage', 'splash_images'); |
||
70 | shuffle($this->_shuffledImages); |
||
71 | $randomIndex = array_rand($this->_shuffledImages); |
||
72 | $this->_selectedImage = Config::inst()->get('PresentationPage', 'splash_image_location'). |
||
73 | '/'. |
||
74 | $this->_shuffledImages[$randomIndex]; |
||
75 | } |
||
76 | } |
||
77 | return $this->_selectedImage; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Returns the index of the first image to be shown on the Presentation Page Splash. |
||
82 | * @return Integer |
||
0 ignored issues
–
show
|
|||
83 | */ |
||
84 | public function getRandomSplashImageIndex() |
||
85 | { |
||
86 | return $this->_selectedImage; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Generates a Javascript Array command from the list of Shuffled images. |
||
91 | * @return String |
||
92 | */ |
||
93 | public function getJavaImageArray() |
||
94 | { |
||
95 | $imageArray = $this->_shuffledImages; //Config::inst()->get('Presentation Page', 'splash_images'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
96 | return "new Array('/images/".implode("', '/images/", $imageArray)."'),"; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Returns an html message with tags other tahn <a><span> removed. |
||
101 | * @return String |
||
102 | */ |
||
103 | public function getSplashMessageClean() |
||
104 | { |
||
105 | $strippedHMTL = str_replace('>', '>', $this->Content); |
||
106 | $strippedHMTL = strip_tags($strippedHMTL, '<a><span>'); |
||
107 | $strippedHMTL = str_replace(' ', ' ', $strippedHMTL); |
||
108 | $obj = DBField::create_field('Varchar', $strippedHMTL); |
||
109 | $value = $obj->raw(); |
||
110 | $value = str_replace("'", '’', $value); |
||
111 | $value = str_replace("\r", ' ', $value); |
||
112 | $value = str_replace("\n", ' ', $value); |
||
113 | $value = str_replace("\t", ' ', $value); |
||
114 | $value = preg_replace("/\s{1,}/", " ", $value);; |
||
0 ignored issues
–
show
|
|||
115 | if(strlen($value) < 10) { |
||
116 | return 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.'; |
||
117 | } |
||
118 | |||
119 | return $value; |
||
120 | } |
||
121 | |||
122 | View Code Duplication | function PreviousPage() |
|
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 ![]() This method seems to be duplicated in 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. ![]() |
|||
123 | { |
||
124 | return PresentationPage::get() |
||
125 | ->sort(array('Sort' => 'DESC')) |
||
126 | ->where('Sort < '.$this->Sort.' AND ShowInSearch = 1') |
||
127 | ->First(); |
||
128 | } |
||
129 | |||
130 | View Code Duplication | function NextPage() |
|
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 ![]() This method seems to be duplicated in 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. ![]() |
|||
131 | { |
||
132 | return PresentationPage::get() |
||
133 | ->where('Sort >= '.$this->Sort.' AND ShowInSearch = 1') |
||
134 | ->sort(array('Sort' => 'ASC')) |
||
135 | ->exclude(array('ID' => $this->ID)) |
||
136 | ->First(); |
||
137 | } |
||
138 | |||
139 | } |
||
140 |
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.