sunnysideup /
silverstripe-presentation
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'; |
||
| 7 | |||
| 8 | private static $db = array( |
||
| 9 | 'Website' => "Varchar(100)", |
||
| 10 | 'StartSlogan' => "Varchar(100)" |
||
| 11 | ); |
||
| 12 | private static $has_one = array( |
||
| 13 | 'BackgroundImage' => "Image" |
||
| 14 | ); |
||
| 15 | |||
| 16 | private static $icon = "mysite/images/treeicons/Presentation"; |
||
| 17 | |||
| 18 | public function getCMSFields() |
||
| 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. Loading history...
|
|||
| 31 | { |
||
| 32 | |||
| 33 | |||
| 34 | function init() |
||
| 35 | { |
||
| 36 | ContentController::init(); |
||
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | public function index() |
||
| 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 |
||
| 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'); |
||
| 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() |
|
| 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() |
|
| 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.