Issues (21)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

code/PresentationPage.php (4 issues)

Upgrade to new PHP Analysis Engine

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
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
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
0 ignored issues
show
Should the return type not be string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
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('&nbsp;', ' ', $strippedHMTL);
108
        $obj = DBField::create_field('Varchar', $strippedHMTL);
109
        $value = $obj->raw();
110
        $value = str_replace("'", '&rsquo;', $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
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
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
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.

Loading history...
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
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.

Loading history...
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