Issues (3885)

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.

core/src/Legacy/TemplateParser.php (1 issue)

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 namespace EvolutionCMS\Legacy;
2
3
Class TemplateParser
4
{
5
6
    /**
7
     * @param array $config [action, tabs, toArray]
8
     * @param array $data
9
     * @return string
0 ignored issues
show
Should the return type not be array|string? Also, consider making the array more specific, something like array<String>, or 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.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
10
     */
11
    public function output($config = array(), $data = array()) {
12
        $modx = evolutionCMS();
13
14
        $output = '';
15
        $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : '');
16
        $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
17
18
        if($action) {
19
            $sql = $modx->getDatabase()->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
20
			FROM ' . $modx->getDatabase()->getFullTableName('system_templates') . ' AS t1
21
			INNER JOIN ' . $modx->getDatabase()->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
22
			WHERE t1.action IN(' . $action . ') ' . $tab . '
23
			ORDER BY t1.tab ASC, t1.rank ASC');
24
25
            if($modx->getDatabase()->getRecordCount($sql)) {
26
                $tabs = array();
27
                while($row = $modx->getDatabase()->getRow($sql)) {
28
                    if(!$row['value'] && !empty($data[$row['name']])) {
29
                        $row['value'] = $data[$row['name']];
30
                    }
31
                    $tabs[$row['tab']]['category_name'] = $row['category_name'];
32
                    $tabs[$row['tab']][$row['name']] = $this->render($row);
33
                }
34
35
                if(!empty($config['toArray'])) {
36
                    $output = $tabs;
37
                } else {
38
                    $output .= '<div class="tab-pane" id="pane_' . $action . '">';
39
                    $output .= '
40
					<script type="text/javascript">
41
						var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->getConfig('remember_last_tab') == 1 ? 'true' : 'false') . ');
42
					</script>';
43
44
                    foreach($tabs as $idTab => $tab) {
45
                        $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">';
46
                        $output .= '
47
						<h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2>
48
						<script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
49
                        unset($tab['category_name']);
50
                        foreach($tab as $item) {
51
                            $output .= $item;
52
                        }
53
                        $output .= '</div>';
54
                    }
55
                    $output .= '</div>';
56
                }
57
            }
58
        }
59
60
        return $output;
61
    }
62
63
    /**
64
     * @param array $data
65
     * @return string
66
     */
67
    private function render($data) {
68
        $modx = evolutionCMS(); global $_lang, $_country_lang;
69
70
        $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']);
71
        $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->getPhpCompat()->htmlspecialchars($data['value']) : ''));
72
        $data['readonly'] = ($data['readonly'] ? ' readonly' : '');
73
74
        $output = '';
75
        $output .= '<div class="form-group row">';
76
77
        switch($data['type']) {
78
79
            case 'text':
80
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
81
					<div class="col-sm-7">
82
					<input type="text" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
83
                $output .= $data['content'];
84
                $output .= '</div>';
85
86
                break;
87
88
            case 'textarea':
89
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
90
					<div class="col-sm-7">
91
					<textarea name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;"[+readonly+]>[+value+]</textarea>';
92
                $output .= $data['content'];
93
                $output .= '</div>';
94
95
                break;
96
97
            case 'date':
98
                $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : ''));
99
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>
100
					<div class="col-sm-7">
101
					<input type="text" name="[+name+]" class="form-control DatePicker" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
102
                $output .= $data['content'];
103
                $output .= '</div>';
104
105
                break;
106
107
            case 'select':
108
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
109
                $output .= '<div class="col-sm-7">';
110
                $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">';
111
                if($data['name'] == 'country' && isset($_country_lang)) {
112
                    $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country'];
113
                    $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '>&nbsp;</option>';
114
                    foreach($_country_lang as $key => $value) {
115
                        $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>';
116
                    }
117 View Code Duplication
                } else {
118
                    if($data['elements']) {
119
                        $elements = explode('||', $data['elements']);
120
                        foreach($elements as $key => $value) {
121
                            $value = explode('==', $value);
122
                            $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>';
123
                        }
124
                    }
125
                }
126
                $output .= '</select>';
127
                $output .= $data['content'];
128
                $output .= '</div>';
129
130
                break;
131
132
            case 'checkbox':
133
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
134
                $output .= '<div class="col-sm-7">';
135
                $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
136
                if($data['elements']) {
137
                    $elements = explode('||', $data['elements']);
138
                    foreach($elements as $key => $value) {
139
                        $value = explode('==', $value);
140
                        $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
141
                    }
142
                }
143
                $output .= $data['content'];
144
                $output .= '</div>';
145
146
                break;
147
148
            case 'radio':
149
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
150
                $output .= '<div class="col-sm-7">';
151
                $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />';
152 View Code Duplication
                if($data['elements']) {
153
                    $elements = explode('||', $data['elements']);
154
                    foreach($elements as $key => $value) {
155
                        $value = explode('==', $value);
156
                        $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]);
157
                    }
158
                }
159
                $output .= $data['content'];
160
                $output .= '</div>';
161
162
                break;
163
164
            case 'custom':
165
                $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>';
166
                $output .= '<div class="col-sm-7">';
167
                $output .= $data['content'];
168
                $output .= '</div>';
169
170
                break;
171
        }
172
173
        $output .= '</div>';
174
175
        $output = $modx->parseText($output, $data);
176
177
        return $output;
178
    }
179
180
}
181