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) 2010-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/records.php'); |
||
33 | /**#@-*/ |
||
34 | |||
35 | init_page(LOAD_INLINE); |
||
36 | |||
37 | // check that requested record exists |
||
38 | |||
39 | $id = ustr2int(try_request('id')); |
||
40 | $record = record_find($id); |
||
41 | |||
42 | if (!$record) |
||
0 ignored issues
–
show
|
|||
43 | { |
||
44 | debug_write_log(DEBUG_NOTICE, 'Record cannot be found.'); |
||
45 | header('HTTP/1.1 307 index.php'); |
||
46 | exit; |
||
47 | } |
||
48 | |||
49 | // get current user's permissions and verify them |
||
50 | |||
51 | $permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
||
52 | |||
53 | View Code Duplication | if (!can_subrecord_be_added($record, $permissions)) |
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
54 | { |
||
55 | debug_write_log(DEBUG_NOTICE, 'Subrecord cannot be added.'); |
||
56 | header('HTTP/1.1 307 subrecords.php?id=' . $id); |
||
57 | exit; |
||
58 | } |
||
59 | |||
60 | // get current date |
||
61 | |||
62 | $today = date_floor(time()); |
||
63 | |||
64 | // subrecords form is submitted |
||
65 | |||
66 | if (try_request('submitted') == 'addsubrecform') |
||
67 | { |
||
68 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
69 | |||
70 | $subrecords = ustrcut(try_request('subrecords'), 100); |
||
71 | $subrecords = ustr_replace(',', ' ', $subrecords); |
||
72 | |||
73 | $is_dependency = isset($_REQUEST['is_dependency']); |
||
74 | |||
75 | mb_regex_encoding('UTF-8'); |
||
76 | $subrecords = mb_split(' ', $subrecords); |
||
77 | |||
78 | foreach ($subrecords as $subrecord) |
||
79 | { |
||
80 | $pos = strrpos($subrecord, '-'); |
||
81 | |||
82 | if ($pos !== FALSE) |
||
83 | { |
||
84 | $prefix = substr($subrecord, 0, $pos); |
||
85 | $subrecord = substr($subrecord, $pos + 1); |
||
86 | debug_write_log(DEBUG_DUMP, "prefix = {$subrecord}"); |
||
87 | } |
||
88 | |||
89 | if (is_intvalue($subrecord)) |
||
90 | { |
||
91 | $subrecord = ustr2int($subrecord); |
||
92 | $srec = record_find($subrecord); |
||
93 | |||
94 | if ($srec) |
||
0 ignored issues
–
show
The expression
$srec 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
Loading history...
|
|||
95 | { |
||
96 | if (!isset($prefix) || $srec['template_prefix'] == $prefix) |
||
97 | { |
||
98 | subrecord_add($id, $subrecord, $is_dependency); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | |||
104 | record_read($id); |
||
105 | |||
106 | $rs = dal_query('depends/list.sql', $record['record_id']); |
||
107 | echo(sprintf('%s (%u)', get_html_resource(RES_SUBRECORDS_ID), $rs->rows)); |
||
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...
|
|||
108 | exit; |
||
109 | } |
||
110 | else |
||
111 | { |
||
112 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
113 | } |
||
114 | |||
115 | // local JS functions |
||
116 | |||
117 | $xml = <<<JQUERY |
||
118 | <script> |
||
119 | |||
120 | function addSubrecordSuccess (data) |
||
121 | { |
||
122 | var index = $("#tabs").tabs("option", "selected") + 1; |
||
123 | $("[href=#ui-tabs-" + index + "]").html(data); |
||
124 | closeModal(); |
||
125 | reloadTab(); |
||
126 | } |
||
127 | |||
128 | </script> |
||
129 | JQUERY; |
||
130 | |||
131 | // generate subrecords form |
||
132 | |||
133 | $xml .= '<form name="addsubrecform" action="addsubrec.php?id=' . $id . '" success="addSubrecordSuccess">' |
||
134 | . '<group>' |
||
135 | . '<control name="subrecords">' |
||
136 | . '<label>' . get_html_resource(RES_ID_ID) . '</label>' |
||
137 | . '<editbox maxlen="100"/>' |
||
138 | . '</control>' |
||
139 | . '<control name="is_dependency">' |
||
140 | . '<label/>' |
||
141 | . '<checkbox checked="true">' |
||
142 | . get_html_resource(RES_DEPENDENCY_ID) |
||
143 | . '</checkbox>' |
||
144 | . '</control>' |
||
145 | . '</group>' |
||
146 | . '</form>'; |
||
147 | |||
148 | echo(xml2html($xml)); |
||
149 | |||
150 | ?> |
||
151 |
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.