Issues (165)

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.

src/View/THelpers.php (1 issue)

Labels
Severity

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
namespace Anax\View;
4
5
/**
6
 * Trait with view helpers, provided by the ThemeEngine to the views.
7
 *
8
 */
9
trait THelpers
10
{
11
    /**
12
     * Render a view with an optional data set of variables.
13
     *
14
     * @param string $template the template file, or array
15
     * @param array  $data     variables to make available to the
16
     *                         view, default is empty
17
     *
18
     * @return void
19
     */
20
    public function renderView($template, $data = [])
21
    {
22
        $template = $this->di->get("views")->getTemplateFile($template);
0 ignored issues
show
The property di does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
        $view = $this->di->get("view");
24
        $view->setDI($this->di);
25
        $view->set($template, $data);
26
        $view->render();
27
    }
28
29
30
31
    /**
32
     * Create a class attribute from a string or array.
33
     *
34
     * @param string|array $args variable amount of classlists.
35
     *
36
     * @return string as complete class attribute
37
     */
38 5
    public function classList(...$args)
39
    {
40 5
        $classes = [];
41
42 5
        foreach ($args as $arg) {
43 5
            if (empty($arg)) {
44 2
                continue;
45 4
            } elseif (is_string($arg)) {
46 4
                $arg = explode(" ", $arg);
47 4
            }
48 4
            $classes = array_merge($classes, $arg);
49 5
        }
50
51 5
        return "class=\"" . implode(" ", $classes) . "\"";
52
    }
53
54
55
56
    /**
57
     * Create an url for a static asset.
58
     *
59
     * @param string $uri part of uri to use when creating an url.
60
     *
61
     * @return string as resulting url.
62
     */
63
    public function asset($uri = null)
64
    {
65
        return $this->di->get("url")->asset($uri);
66
    }
67
68
69
70
    /**
71
     * Create an url and prepending the baseUrl.
72
     *
73
     * @param string $uri part of uri to use when creating an url. "" or null
74
     *                    means baseurl to current frontcontroller.
75
     *
76
     * @return string as resulting url.
77
     */
78
    public function url($uri = null)
79
    {
80
        return $this->di->get("url")->create($uri);
81
    }
82
83
84
85
    /**
86
     * Get current url, without querystring.
87
     *
88
     * @return string as resulting url.
89
     */
90
    public function currentUrl()
91
    {
92
        return $this->di->get("request")->getCurrentUrl(false);
93
    }
94
95
96
97
    /**
98
     * Check if the region in the view container has views to render.
99
     *
100
     * @param string $region to check
101
     *
102
     * @return boolean true or false
103
     */
104
    public function regionHasContent($region)
105
    {
106
        return $this->di->get("views")->hasContent($region);
107
    }
108
109
110
111
    /**
112
     * Render views, from the view container, in the region.
113
     *
114
     * @param string $region to render in
115
     *
116
     * @return boolean true or false
117
     */
118
    public function renderRegion($region)
119
    {
120
        $this->di->get("views")->render($region);
121
    }
122
123
124
125
    /**
126
     * Load content from a route and return details to view.
127
     *
128
     * @param string $route to load content from.
129
     *
130
     * @return array with values to extract in view.
131
     */
132
    public function getContentForRoute($route)
133
    {
134
        $content = $this->di->get("content")->contentForInternalRoute($route);
135
        return $content->views["main"]["data"];
136
    }
137
138
139
140
    /**
141
     * Wrap a HTML element with start and end.
142
     *
143
     * @param string  $text  with content
144
     * @param string  $tag   HTML tag to search for
145
     * @param string  $start wrap start part
146
     * @param string  $end   wrap end part
147
     * @param number  $count hits to search for
148
     *
149
     * @return array with values to extract in view.
150
     */
151
    public function wrapElementWithStartEnd($text, $tag, $start, $end, $count)
152
    {
153
        return $this->di->get("textFilter")->wrapElementWithStartEnd($text, $tag, $start, $end, $count);
154
    }
155
156
157
158
    /**
159
     * Wrap content of a HTML element with start and end.
160
     *
161
     * @param string  $text  with content
162
     * @param string  $tag   HTML tag to search for
163
     * @param string  $start wrap start part
164
     * @param string  $end   wrap end part
165
     * @param number  $count hits to search for
166
     *
167
     * @return array with values to extract in view.
168
     */
169
    public function wrapElementContentWithStartEnd($text, $tag, $start, $end, $count)
170
    {
171
        return $this->di->get("textFilter")->wrapElementContentWithStartEnd($text, $tag, $start, $end, $count);
172
    }
173
174
175
176
    /**
177
     * Extrat the publish or update date for the article.
178
     *
179
     * @param array $dates a collection of possible date values.
180
     *
181
     * @return array with values for showing the date.
182
     */
183
    public function getPublishedDate($dates)
184
    {
185
        $defaults = [
186
            "revision" => [],
187
            "published" => null,
188
            "updated" => null,
189
            "created" => null,
190
        ];
191
        $dates = array_merge($defaults, $dates);
192
        
193
        if ($dates["revision"]) {
194
            return [t("Latest revision"), key($dates["revision"])];
195
        } elseif ($dates["published"]) {
196
            return [t("Published"), $dates["published"]];
197
        } elseif ($dates["updated"]) {
198
            return [t("Updated"), $dates["updated"]];
199
        } elseif ($dates["created"]) {
200
            return [t("Created"), $dates["created"]];
201
        }
202
203
        return [t("Missing pubdate."), null];
204
    }
205
}
206