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 | //------------------------------------------------------------------------------ |
||
4 | // |
||
5 | // eTraxis - Records tracking web-based system |
||
6 | // Copyright (C) 2005-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/records.php'); |
||
34 | require_once('../dbo/views.php'); |
||
35 | /**#@-*/ |
||
36 | |||
37 | global $column_type_align; |
||
38 | global $column_type_res; |
||
39 | |||
40 | init_page(LOAD_TAB, GUEST_IS_ALLOWED); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | // process search mode, if one is specified |
||
43 | |||
44 | View Code Duplication | if (isset($_REQUEST['search'])) |
|
45 | { |
||
46 | debug_write_log(DEBUG_NOTICE, 'REQUEST["search"] is set.'); |
||
47 | |||
48 | $search_text = ustrcut($_REQUEST['search'], MAX_SEARCH_TEXT); |
||
49 | |||
50 | if (ustrlen($search_text) == 0) |
||
51 | { |
||
52 | $_SESSION[VAR_SEARCH_MODE] = FALSE; |
||
53 | } |
||
54 | else |
||
55 | { |
||
56 | $_SESSION[VAR_SEARCH_MODE] = TRUE; |
||
57 | $_SESSION[VAR_SEARCH_TEXT] = $search_text; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | $tab = $_SESSION[VAR_SEARCH_MODE] ? 2 : 1; // ID of this tab |
||
62 | |||
63 | if (isset($_REQUEST['use_filters'])) |
||
64 | { |
||
65 | $_SESSION[VAR_USE_FILTERS] = (bool) $_REQUEST['use_filters']; |
||
66 | } |
||
67 | |||
68 | // records list is submitted |
||
69 | |||
70 | if (try_request('submitted') == 'read') |
||
71 | { |
||
72 | View Code Duplication | foreach ($_REQUEST as $request) |
|
73 | { |
||
74 | if (substr($request, 0, 3) == 'rec') |
||
75 | { |
||
76 | record_read(intval(substr($request, 3))); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | exit; |
||
81 | } |
||
82 | elseif (try_request('submitted') == 'unread') |
||
83 | { |
||
84 | View Code Duplication | foreach ($_REQUEST as $request) |
|
85 | { |
||
86 | if (substr($request, 0, 3) == 'rec') |
||
87 | { |
||
88 | record_unread(intval(substr($request, 3))); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | exit; |
||
93 | } |
||
94 | |||
95 | // get list of records |
||
96 | |||
97 | $columns = columns_list(); |
||
98 | |||
99 | $sort = $page = NULL; |
||
100 | $list = records_list($columns, $sort, $page, $_SESSION[VAR_SEARCH_MODE], $_SESSION[VAR_SEARCH_TEXT]); |
||
0 ignored issues
–
show
It seems like
$_SESSION[VAR_SEARCH_MODE] can also be of type string ; however, records_list() does only seem to accept boolean , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
It seems like
$_SESSION[VAR_SEARCH_TEXT] can also be of type boolean ; however, records_list() does only seem to accept string|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
101 | |||
102 | $rec_from = $rec_to = 0; |
||
103 | |||
104 | // local JS functions |
||
105 | $resTitle = get_js_resource(RES_NEW_RECORD_ID); |
||
106 | $resOK = get_js_resource(RES_OK_ID); |
||
107 | $resNext = get_js_resource(RES_NEXT_ID); |
||
108 | $resCancel = get_js_resource(RES_CANCEL_ID); |
||
109 | |||
110 | $resSearch = $_SESSION[VAR_SEARCH_MODE] |
||
111 | ? ustr2html($_SESSION[VAR_SEARCH_TEXT]) |
||
0 ignored issues
–
show
It seems like
$_SESSION[VAR_SEARCH_TEXT] can also be of type boolean ; however, ustr2html() does only seem to accept string , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
112 | : get_html_resource(RES_SEARCH_ID); |
||
113 | |||
114 | $xml = <<<JQUERY |
||
115 | <onready> |
||
116 | |||
117 | $("#view{$tab}").combobox(); |
||
118 | |||
119 | $("#view{$tab}").change(function() { |
||
120 | var id = $("#view{$tab}").val(); |
||
121 | |||
122 | $.post("setview.php?id=" + id, function() { |
||
123 | reloadTab(); |
||
124 | }); |
||
125 | }); |
||
126 | |||
127 | $(".search").val("{$resSearch}"); |
||
128 | |||
129 | </onready> |
||
130 | JQUERY; |
||
131 | |||
132 | if ($_SESSION[VAR_AUTO_REFRESH] != 0) |
||
133 | { |
||
134 | $xml .= sprintf('<onready>' . |
||
135 | 'setTimeout("reloadTab()", %d);' . |
||
136 | '</onready>', |
||
137 | $_SESSION[VAR_AUTO_REFRESH] * MSECS_IN_MINUTE); |
||
138 | } |
||
139 | |||
140 | $xml .= <<<JQUERY |
||
141 | <script> |
||
142 | |||
143 | function recordCreateForceToStep2 () |
||
144 | { |
||
145 | var items = $("#projectform #project").children().length; |
||
146 | |||
147 | if (items == 1) |
||
148 | { |
||
149 | recordCreateStep2(); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | function recordCreateForceToStep3 () |
||
154 | { |
||
155 | var items = $("#templateform #template").children().length; |
||
156 | |||
157 | if (items == 1) |
||
158 | { |
||
159 | recordCreateStep3(); |
||
160 | } |
||
161 | } |
||
162 | |||
163 | function recordCreateStep1 () |
||
164 | { |
||
165 | jqModal("{$resTitle}", "create.php", "{$resNext}", "{$resCancel}", "recordCreateStep2()", null, "recordCreateForceToStep2()"); |
||
166 | } |
||
167 | |||
168 | function recordCreateStep2 () |
||
169 | { |
||
170 | closeModal(); |
||
171 | jqModal("{$resTitle}", "create.php?" + $("#projectform").serialize(), "{$resNext}", "{$resCancel}", "recordCreateStep3()", null, "recordCreateForceToStep3()"); |
||
172 | } |
||
173 | |||
174 | function recordCreateStep3 () |
||
175 | { |
||
176 | closeModal(); |
||
177 | jqModal("{$resTitle}", "create.php?" + $("#templateform").serialize(), "{$resOK}", "{$resCancel}", "$('#mainform').submit()"); |
||
178 | } |
||
179 | |||
180 | function markAs (mark) |
||
181 | { |
||
182 | $("#records{$tab} :input[name=submitted]").val(mark); |
||
183 | $("#records{$tab}").submit(); |
||
184 | } |
||
185 | |||
186 | </script> |
||
187 | JQUERY; |
||
188 | |||
189 | // generate buttons |
||
190 | |||
191 | if (get_user_level() != USER_LEVEL_GUEST) |
||
192 | { |
||
193 | if (can_record_be_created()) |
||
194 | { |
||
195 | $xml .= '<button action="recordCreateStep1()">' . get_html_resource(RES_CREATE_ID) . '</button>'; |
||
196 | } |
||
197 | } |
||
198 | |||
199 | if ($list->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
200 | { |
||
201 | if (get_user_level() != USER_LEVEL_GUEST) |
||
202 | { |
||
203 | $xml .= '<buttonset>' |
||
204 | . '<button action="markAs(\'read\')">' . get_html_resource(RES_MARK_AS_READ_ID) . '</button>' |
||
205 | . '<button action="markAs(\'unread\')">' . get_html_resource(RES_MARK_AS_UNREAD_ID) . '</button>' |
||
206 | . '</buttonset>'; |
||
207 | } |
||
208 | |||
209 | $xml .= '<button url="export.php">' . get_html_resource(RES_EXPORT_ID) . '</button>'; |
||
210 | } |
||
211 | |||
212 | if ($_SESSION[VAR_SEARCH_MODE] && get_user_level() != USER_LEVEL_GUEST) |
||
213 | { |
||
214 | $xml .= '<button action="reloadTab(\'list.php?search=' . urlencode($_SESSION[VAR_SEARCH_TEXT]) . '&use_filters=' . (!$_SESSION[VAR_USE_FILTERS]) . '\')">' |
||
215 | . get_html_resource($_SESSION[VAR_USE_FILTERS] ? RES_DISABLE_FILTERS_ID : RES_ENABLE_FILTERS_ID) |
||
216 | . '</button>'; |
||
217 | } |
||
218 | |||
219 | // generate list of available views |
||
220 | |||
221 | if (get_user_level() != USER_LEVEL_GUEST) |
||
222 | { |
||
223 | $xml .= '<dropdown name="view' . $tab . '">' |
||
224 | . '<listitem value="0">' . get_html_resource(RES_NO_VIEW_ID) . '</listitem>'; |
||
225 | |||
226 | $views = dal_query('views/list.sql', $_SESSION[VAR_USERID], 'view_name'); |
||
227 | |||
228 | while (($view = $views->fetch())) |
||
229 | { |
||
230 | $xml .= ($view['view_id'] == $_SESSION[VAR_VIEW] |
||
231 | ? '<listitem value="' . $view['view_id'] . '" selected="true">' |
||
232 | : '<listitem value="' . $view['view_id'] . '">') |
||
233 | . ustr2html($view['view_name']) |
||
234 | . '</listitem>'; |
||
235 | } |
||
236 | |||
237 | $xml .= '</dropdown>'; |
||
238 | } |
||
239 | |||
240 | // generate list of records |
||
241 | |||
242 | if ($list->rows != 0) |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
243 | { |
||
244 | $bookmarks = gen_xml_bookmarks($page, $list->rows, $rec_from, $rec_to, 'list.php?'); |
||
0 ignored issues
–
show
The property
$rows is declared protected in CRecordset . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
245 | |||
246 | $xml .= '<form name="records' . $tab . '" action="list.php" success="reloadTab">' |
||
247 | . '<list>' |
||
248 | . '<hrow>' |
||
249 | . '<hcell checkboxes="true"/>'; |
||
250 | |||
251 | foreach ($columns as $i => $column) |
||
252 | { |
||
253 | $smode = (abs($sort) == ($i + 1) ? -$sort : $i + 1); |
||
254 | |||
255 | $xml .= "<hcell url=\"list.php?sort={$smode}\">"; |
||
256 | |||
257 | if ($column['column_type'] >= COLUMN_TYPE_MINIMUM && |
||
258 | $column['column_type'] <= COLUMN_TYPE_MAXIMUM) |
||
259 | { |
||
260 | $xml .= get_html_resource($column_type_res[$column['column_type']]); |
||
261 | } |
||
262 | else |
||
263 | { |
||
264 | $xml .= ustr2html($column['field_name']); |
||
265 | } |
||
266 | |||
267 | $xml .= '</hcell>'; |
||
268 | } |
||
269 | |||
270 | $xml .= '</hrow>'; |
||
271 | |||
272 | $mark_as_read = (isset($_REQUEST['read']) && $_REQUEST['read'] == 1); |
||
273 | $read_time = time(); |
||
274 | |||
275 | $list->seek($rec_from - 1); |
||
276 | |||
277 | for ($i = $rec_from; $i <= $rec_to; $i++) |
||
278 | { |
||
279 | $row = $list->fetch(); |
||
280 | |||
281 | if ($mark_as_read && get_user_level() != USER_LEVEL_GUEST) |
||
282 | { |
||
283 | dal_query('records/unread.sql', $row['record_id'], $_SESSION[VAR_USERID]); |
||
284 | dal_query('records/read.sql', $row['record_id'], $_SESSION[VAR_USERID], $read_time); |
||
285 | |||
286 | $row['read_time'] = $read_time; |
||
287 | } |
||
288 | |||
289 | if (is_record_closed($row)) |
||
290 | { |
||
291 | $color = 'grey'; |
||
292 | } |
||
293 | elseif (is_record_postponed($row)) |
||
294 | { |
||
295 | $color = 'blue'; |
||
296 | } |
||
297 | elseif (is_record_critical($row)) |
||
298 | { |
||
299 | $color = 'red'; |
||
300 | } |
||
301 | else |
||
302 | { |
||
303 | $color = NULL; |
||
304 | } |
||
305 | |||
306 | $bold = ((get_user_level() == USER_LEVEL_GUEST) || ($row['read_time'] >= $row['change_time']) |
||
307 | ? 'false' |
||
308 | : 'true'); |
||
309 | |||
310 | $xml .= "<row name=\"rec{$row['record_id']}\" url=\"view.php?id={$row['record_id']}\" color=\"{$color}\">"; |
||
311 | |||
312 | foreach ($columns as $column) |
||
313 | { |
||
314 | $value = NULL; |
||
315 | $nowrap = 'false'; |
||
316 | $align = 'left'; |
||
317 | |||
318 | switch ($column['column_type']) |
||
319 | { |
||
320 | case COLUMN_TYPE_ID: |
||
321 | $value = record_id($row['record_id'], $row['template_prefix']); |
||
322 | $nowrap = 'true'; |
||
323 | break; |
||
324 | |||
325 | case COLUMN_TYPE_STATE_ABBR: |
||
326 | $value = ustr2html($row['state_abbr']); |
||
327 | break; |
||
328 | |||
329 | case COLUMN_TYPE_PROJECT: |
||
330 | $value = ustr2html($row['project_name']); |
||
331 | break; |
||
332 | |||
333 | case COLUMN_TYPE_SUBJECT: |
||
334 | $value = update_references($row['subject'], BBCODE_SEARCH_ONLY); |
||
335 | break; |
||
336 | |||
337 | case COLUMN_TYPE_AUTHOR: |
||
338 | $value = ustr2html($row['author_fullname']); |
||
339 | break; |
||
340 | |||
341 | case COLUMN_TYPE_RESPONSIBLE: |
||
342 | $value = ustr2html($row['responsible_fullname']); |
||
343 | |||
344 | if (is_null($value)) |
||
345 | { |
||
346 | $value = '<i>' . get_html_resource(RES_NONE_ID) . '</i>'; |
||
347 | } |
||
348 | |||
349 | break; |
||
350 | |||
351 | case COLUMN_TYPE_LAST_EVENT: |
||
352 | $value = get_record_last_event($row); |
||
353 | $align = 'right'; |
||
354 | break; |
||
355 | |||
356 | case COLUMN_TYPE_AGE: |
||
357 | $value = get_record_age($row); |
||
358 | $align = 'right'; |
||
359 | break; |
||
360 | |||
361 | case COLUMN_TYPE_CREATION_DATE: |
||
362 | $value = get_date($row['creation_time']); |
||
363 | break; |
||
364 | |||
365 | case COLUMN_TYPE_TEMPLATE: |
||
366 | $value = ustr2html($row['template_name']); |
||
367 | break; |
||
368 | |||
369 | case COLUMN_TYPE_STATE_NAME: |
||
370 | $value = ustr2html($row['state_name']); |
||
371 | break; |
||
372 | |||
373 | case COLUMN_TYPE_LAST_STATE: |
||
374 | $value = get_record_last_state($row); |
||
375 | $align = 'right'; |
||
376 | break; |
||
377 | |||
378 | case COLUMN_TYPE_NUMBER: |
||
379 | case COLUMN_TYPE_FLOAT: |
||
380 | $value = $row['value' . $column['column_id']]; |
||
381 | $align = 'right'; |
||
382 | break; |
||
383 | |||
384 | View Code Duplication | case COLUMN_TYPE_STRING: |
|
385 | $value = update_references($row['value' . $column['column_id']], BBCODE_SEARCH_ONLY); |
||
386 | break; |
||
387 | |||
388 | case COLUMN_TYPE_MULTILINED: |
||
389 | $value = $row['value' . $column['column_id']]; |
||
390 | |||
391 | if (ustrlen($value) > MAX_FIELD_STRING + 3) |
||
392 | { |
||
393 | $value = usubstr($value, 0, MAX_FIELD_STRING) . '...'; |
||
394 | } |
||
395 | |||
396 | $value = update_references($value, BBCODE_SEARCH_ONLY); |
||
397 | break; |
||
398 | |||
399 | case COLUMN_TYPE_CHECKBOX: |
||
400 | |||
401 | if (!is_null($row['value' . $column['column_id']])) |
||
402 | { |
||
403 | $value = get_html_resource($row['value' . $column['column_id']] == 0 ? RES_NO_ID : RES_YES_ID); |
||
404 | } |
||
405 | |||
406 | break; |
||
407 | |||
408 | case COLUMN_TYPE_LIST_NUMBER: |
||
409 | $value = $row['value' . $column['column_id']]; |
||
410 | $align = 'center'; |
||
411 | break; |
||
412 | |||
413 | View Code Duplication | case COLUMN_TYPE_LIST_STRING: |
|
414 | $value = update_references($row['value' . $column['column_id']], BBCODE_SEARCH_ONLY); |
||
415 | break; |
||
416 | |||
417 | View Code Duplication | case COLUMN_TYPE_RECORD: |
|
418 | |||
419 | if (!is_null($row['value' . $column['column_id']])) |
||
420 | { |
||
421 | $value = record_id($row['value' . $column['column_id']]); |
||
422 | } |
||
423 | |||
424 | break; |
||
425 | |||
426 | View Code Duplication | case COLUMN_TYPE_DATE: |
|
427 | |||
428 | if (!is_null($row['value' . $column['column_id']])) |
||
429 | { |
||
430 | $value = get_date($row['value' . $column['column_id']]); |
||
431 | } |
||
432 | |||
433 | break; |
||
434 | |||
435 | case COLUMN_TYPE_DURATION: |
||
436 | |||
437 | if (!is_null($row['value' . $column['column_id']])) |
||
438 | { |
||
439 | $value = time2ustr($row['value' . $column['column_id']]); |
||
440 | } |
||
441 | |||
442 | $align = 'right'; |
||
443 | break; |
||
444 | |||
445 | default: |
||
446 | debug_write_log(DEBUG_WARNING, 'Unknown column type.'); |
||
447 | } |
||
448 | |||
449 | $xml .= "<cell align=\"{$align}\" bold=\"{$bold}\" nowrap=\"{$nowrap}\">{$value}</cell>"; |
||
450 | } |
||
451 | |||
452 | $xml .= '</row>'; |
||
453 | } |
||
454 | |||
455 | $xml .= '</list>' |
||
456 | . '</form>' |
||
457 | . $bookmarks; |
||
458 | } |
||
459 | |||
460 | echo(xml2html($xml)); |
||
461 | |||
462 | ?> |
||
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...
|
|||
463 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: