Issues (1098)

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/views/columns.php (2 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
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2007-2011  Artem Rodygin
7
//
8
//  This program is free software: you can redistribute it and/or modify
9
//  it under the terms of the GNU General Public License as published by
10
//  the Free Software Foundation, either version 3 of the License, or
11
//  (at your option) any later version.
12
//
13
//  This program is distributed in the hope that it will be useful,
14
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
//  GNU General Public License for more details.
17
//
18
//  You should have received a copy of the GNU General Public License
19
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//------------------------------------------------------------------------------
22
23
/**
24
 * @package eTraxis
25
 * @ignore
26
 */
27
28
/**#@+
29
 * Dependency.
30
 */
31
require_once('../engine/engine.php');
32
require_once('../dbo/fields.php');
33
require_once('../dbo/views.php');
34
/**#@-*/
35
36
global $column_type_res;
37
38
init_page(LOAD_TAB);
39
40
$error = NO_ERROR;
41
42
// check that requested view exists
43
44
$id   = ustr2int(try_request('id'));
45
$view = view_find($id);
46
47
if (!$view)
0 ignored issues
show
Bug Best Practice introduced by Artem Rodygin
The expression $view of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
48
{
49
    debug_write_log(DEBUG_NOTICE, 'View cannot be found.');
50
    exit;
51
}
52
53
// add/remove selected columns
54
55
if (try_request('submitted') == 'cdisabledform')
56
{
57
    debug_write_log(DEBUG_NOTICE, 'Data are submitted (adding new columns).');
58
59
    if (isset($_REQUEST['lcolumns']))
60
    {
61
        $error = columns_add($id, $_REQUEST['lcolumns']);
62
63
        switch ($error)
64
        {
65
            case NO_ERROR:
66
                header('HTTP/1.0 200 OK');
67
                break;
68
69
            case ERROR_INTEGER_VALUE_OUT_OF_RANGE:
70
                send_http_error(ustrprocess(get_html_resource(RES_ALERT_VIEW_CANNOT_HAVE_MORE_COLUMNS), MAX_VIEW_SIZE));
71
                break;
72
73
            default:
74
                send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
75
        }
76
    }
77
    else
78
    {
79
        debug_write_log(DEBUG_NOTICE, 'No columns are selected.');
80
    }
81
82
    exit;
83
}
84
elseif (try_request('submitted') == 'cenabledform')
85
{
86
    debug_write_log(DEBUG_NOTICE, 'Data are submitted (removing selected columns).');
87
88
    if (isset($_REQUEST['rcolumns']))
89
    {
90
        columns_remove($id, $_REQUEST['rcolumns']);
91
    }
92
    else
93
    {
94
        debug_write_log(DEBUG_NOTICE, 'No columns are selected.');
95
    }
96
97
    exit;
98
}
99
else
100
{
101
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
102
}
103
104
// split all columns of the view into 2 arrays - standard columns, and custom ones
105
106
$standard = array();
107
$custom   = array();
108
109
$columns = columns_list($id);
110
111
foreach ($columns as $column)
112
{
113
    if ($column['column_type'] >= COLUMN_TYPE_MINIMUM &&
114
        $column['column_type'] <= COLUMN_TYPE_MAXIMUM)
115
    {
116
        array_push($standard, $column['column_type']);
117
    }
118
    else
119
    {
120
        array_push($custom, sprintf('%u:%s:%s',
121
                                    $column['column_type'],
122
                                    ustr2csv($column['state_name'], '\''),
123
                                    ustr2csv($column['field_name'], '\'')));
124
    }
125
}
126
127
// local JS functions
128
129
$resTitle = get_js_resource(RES_ERROR_ID);
130
$resOK    = get_js_resource(RES_OK_ID);
131
132
$xml = <<<JQUERY
133
<script>
134
135
function onError (XMLHttpRequest)
136
{
137
    jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}");
138
}
139
140
function moveCol (direction)
141
{
142
    var id = $("#rcolumns").val();
143
144
    $.post("move.php?offset=" + direction + "&amp;id=" + id, function(data){
145
        if (data.length != 0)
146
        {
147
            $("#rcolumns").html(data);
148
        }
149
    });
150
}
151
152
</script>
153
JQUERY;
154
155
// generate left side
156
157
$xml .= '<dual>'
158
      . '<dualleft>'
159
      . '<form name="cdisabledform" action="columns.php?id=' . $id . '" success="reloadTab" error="onError">'
160
      . '<group title="' . get_html_resource(RES_DISABLED2_ID) . '">'
161
      . '<control name="lcolumns[]">'
162
      . '<listbox size="10">';
163
164
// add all possible standard columns, which are not in the view yet
165
166
for ($i = COLUMN_TYPE_MINIMUM; $i <= COLUMN_TYPE_MAXIMUM; $i++)
167
{
168
    if (!in_array($i, $standard))
169
    {
170
        $xml .= '<listitem value="' . $i . '::">'
171
              . get_html_resource($column_type_res[$i])
172
              . '</listitem>';
173
    }
174
}
175
176
// add all possible custom columns, which are not in the view yet
177
178
$fields_to_columns = array
179
(
180
    FIELD_TYPE_NUMBER     => COLUMN_TYPE_NUMBER,
181
    FIELD_TYPE_FLOAT      => COLUMN_TYPE_FLOAT,
182
    FIELD_TYPE_STRING     => COLUMN_TYPE_STRING,
183
    FIELD_TYPE_MULTILINED => COLUMN_TYPE_MULTILINED,
184
    FIELD_TYPE_CHECKBOX   => COLUMN_TYPE_CHECKBOX,
185
    FIELD_TYPE_RECORD     => COLUMN_TYPE_RECORD,
186
    FIELD_TYPE_DATE       => COLUMN_TYPE_DATE,
187
    FIELD_TYPE_DURATION   => COLUMN_TYPE_DURATION,
188
);
189
190
$flist = dal_query('columns/flist.sql', $_SESSION[VAR_USERID]);
191
192
while (($item = $flist->fetch()))
193
{
194
    // field of "list" type brings 2 kinds of column
195
    if ($item['field_type'] == FIELD_TYPE_LIST)
196
    {
197
        // add numeric variant of the "list" field
198
        $value = sprintf('%u:%s:%s',
199
                         COLUMN_TYPE_LIST_NUMBER,
200
                         ustr2csv($item['state_name'], '\''),
201
                         ustr2csv($item['field_name'], '\''));
202
203 View Code Duplication
        if (!in_array($value, $custom))
204
        {
205
            $xml .= '<listitem value="' . ustr2html($value) . '">'
206
                  . ustr2html(sprintf('%s: %s (%s)',
207
                                      $item['state_name'],
208
                                      $item['field_name'],
209
                                      get_html_resource($column_type_res[COLUMN_TYPE_LIST_NUMBER])))
210
                  . '</listitem>';
211
        }
212
213
        // add string variant of the "list" field
214
        $value = sprintf('%u:%s:%s',
215
                         COLUMN_TYPE_LIST_STRING,
216
                         ustr2csv($item['state_name'], '\''),
217
                         ustr2csv($item['field_name'], '\''));
218
219 View Code Duplication
        if (!in_array($value, $custom))
220
        {
221
            $xml .= '<listitem value="' . ustr2html($value) . '">'
222
                  . ustr2html(sprintf('%s: %s (%s)',
223
                                      $item['state_name'],
224
                                      $item['field_name'],
225
                                      get_html_resource($column_type_res[COLUMN_TYPE_LIST_STRING])))
226
                  . '</listitem>';
227
        }
228
    }
229
    else
230
    {
231
        // add any other field
232
        $value = sprintf('%u:%s:%s',
233
                         $fields_to_columns[$item['field_type']],
234
                         ustr2csv($item['state_name'], '\''),
235
                         ustr2csv($item['field_name'], '\''));
236
237
        if (!in_array($value, $custom))
238
        {
239
            $xml .= '<listitem value="' . ustr2html($value) . '">'
240
                  . ustr2html(sprintf('%s: %s (%s)',
241
                                      $item['state_name'],
242
                                      $item['field_name'],
243
                                      get_html_resource($column_type_res[$fields_to_columns[$item['field_type']]])))
244
                  . '</listitem>';
245
        }
246
    }
247
}
248
249
$xml .= '</listbox>'
250
      . '</control>'
251
      . '</group>'
252
      . '</form>'
253
      . '</dualleft>';
254
255
// generate right side
256
257
$xml .= '<dualright>'
258
      . '<form name="cenabledform" action="columns.php?id=' . $id . '" success="reloadTab">'
259
      . '<group title="' . get_html_resource(RES_ENABLED2_ID) . '">'
260
      . '<control name="rcolumns[]">'
261
      . '<listbox id="rcolumns" size="10">';
262
263
foreach ($columns as $column)
264
{
265 View Code Duplication
    if ($column['column_type'] >= COLUMN_TYPE_MINIMUM &&
266
        $column['column_type'] <= COLUMN_TYPE_MAXIMUM)
267
    {
268
        $text = get_html_resource($column_type_res[$column['column_type']]);
269
    }
270
    else
271
    {
272
        $text = ustr2html(sprintf('%s: %s (%s)',
273
                                  $column['state_name'],
274
                                  $column['field_name'],
275
                                  get_html_resource($column_type_res[$column['column_type']])));
276
    }
277
278
    $xml .= '<listitem value="' . $column['column_id'] . '">' . $text . '</listitem>';
279
}
280
281
$xml .= '</listbox>'
282
      . '</control>'
283
      . '<button action="moveCol(-1)">%and;</button>'
284
      . '<button action="moveCol( 1)">%or;</button>'
285
      . '</group>'
286
      . '</form>'
287
      . '</dualright>';
288
289
// generate buttons
290
291
$xml .= '<button action="$(\'#cdisabledform\').submit()">%gt;%gt;</button>'
292
      . '<button action="$(\'#cenabledform\').submit()">%lt;%lt;</button>'
293
      . '</dual>';
294
295
echo(xml2html($xml));
296
297
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
298