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/groups.php'); |
||
33 | require_once('../dbo/projects.php'); |
||
34 | require_once('../dbo/templates.php'); |
||
35 | require_once('../dbo/events.php'); |
||
36 | /**#@-*/ |
||
37 | |||
38 | init_page(LOAD_TAB); |
||
39 | |||
40 | if (get_user_level() != USER_LEVEL_ADMIN) |
||
41 | { |
||
42 | debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
||
43 | exit; |
||
44 | } |
||
45 | |||
46 | // check that requested project exists |
||
47 | |||
48 | $pid = ustr2int(try_request('pid')); |
||
49 | $project = project_find($pid); |
||
50 | |||
51 | if (!$project) |
||
0 ignored issues
–
show
|
|||
52 | { |
||
53 | debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
||
54 | exit; |
||
55 | } |
||
56 | |||
57 | // check that requested group exists |
||
58 | |||
59 | $id = ustr2int(try_request('id')); |
||
60 | $group = group_find($id); |
||
61 | |||
62 | if (!$group) |
||
0 ignored issues
–
show
The expression
$group 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...
|
|||
63 | { |
||
64 | debug_write_log(DEBUG_NOTICE, 'Group cannot be found.'); |
||
65 | exit; |
||
66 | } |
||
67 | |||
68 | // permissions data |
||
69 | |||
70 | define('GPERMS_CONTROL', 0); |
||
71 | define('GPERMS_PERMISSION', 1); |
||
72 | define('GPERMS_RESOURCE', 2); |
||
73 | |||
74 | $gperms = array |
||
75 | ( |
||
76 | array('perm_view', PERMIT_VIEW_RECORD, RES_PERMIT_VIEW_RECORDS_ONLY_ID), |
||
77 | array('perm_create', PERMIT_CREATE_RECORD, RES_PERMIT_CREATE_RECORD_ID), |
||
78 | array('perm_modify', PERMIT_MODIFY_RECORD, RES_PERMIT_MODIFY_RECORD_ID), |
||
79 | array('perm_postpone', PERMIT_POSTPONE_RECORD, RES_PERMIT_POSTPONE_RECORD_ID), |
||
80 | array('perm_resume', PERMIT_RESUME_RECORD, RES_PERMIT_RESUME_RECORD_ID), |
||
81 | array('perm_reassign', PERMIT_REASSIGN_RECORD, RES_PERMIT_REASSIGN_RECORD_ID), |
||
82 | array('perm_reopen', PERMIT_REOPEN_RECORD, RES_PERMIT_REOPEN_RECORD_ID), |
||
83 | array('perm_comment', PERMIT_ADD_COMMENTS, RES_PERMIT_ADD_COMMENTS_ID), |
||
84 | array('perm_confidential', PERMIT_CONFIDENTIAL_COMMENTS, RES_PERMIT_CONFIDENTIAL_COMMENTS_ID), |
||
85 | array('perm_attach', PERMIT_ATTACH_FILES, RES_PERMIT_ATTACH_FILES_ID), |
||
86 | array('perm_remove', PERMIT_REMOVE_FILES, RES_PERMIT_REMOVE_FILES_ID), |
||
87 | array('perm_remind', PERMIT_SEND_REMINDERS, RES_PERMIT_SEND_REMINDERS_ID), |
||
88 | array('perm_delete', PERMIT_DELETE_RECORD, RES_PERMIT_DELETE_RECORD_ID), |
||
89 | array('perm_addsub', PERMIT_ADD_SUBRECORDS, RES_PERMIT_ADD_SUBRECORDS_ID), |
||
90 | array('perm_remsub', PERMIT_REMOVE_SUBRECORDS, RES_PERMIT_REMOVE_SUBRECORDS_ID), |
||
91 | ); |
||
92 | |||
93 | // save changed permissions |
||
94 | |||
95 | if (try_request('submitted') == 'permsform') |
||
96 | { |
||
97 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
98 | |||
99 | $tid = ustr2int(try_request('template')); |
||
100 | $template = template_find($tid); |
||
101 | |||
102 | if ($template) |
||
0 ignored issues
–
show
The expression
$template 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...
|
|||
103 | { |
||
104 | $permissions = 0; |
||
105 | |||
106 | View Code Duplication | foreach ($gperms as $gperm) |
|
107 | { |
||
108 | if (isset($_REQUEST[$gperm[GPERMS_CONTROL]])) |
||
109 | { |
||
110 | $permissions |= $gperm[GPERMS_PERMISSION]; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | group_set_permissions($id, $tid, $permissions); |
||
115 | } |
||
116 | else |
||
117 | { |
||
118 | debug_write_log(DEBUG_NOTICE, 'Template cannot be found.'); |
||
119 | } |
||
120 | |||
121 | exit; |
||
122 | } |
||
123 | else |
||
124 | { |
||
125 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
126 | } |
||
127 | |||
128 | // JS arrays with permissions |
||
129 | |||
130 | $xml = <<<JQUERY |
||
131 | <script> |
||
132 | |||
133 | var perm_view = new Array(); |
||
134 | var perm_create = new Array(); |
||
135 | var perm_modify = new Array(); |
||
136 | var perm_postpone = new Array(); |
||
137 | var perm_resume = new Array(); |
||
138 | var perm_reassign = new Array(); |
||
139 | var perm_reopen = new Array(); |
||
140 | var perm_comment = new Array(); |
||
141 | var perm_confidential = new Array(); |
||
142 | var perm_attach = new Array(); |
||
143 | var perm_remove = new Array(); |
||
144 | var perm_remind = new Array(); |
||
145 | var perm_delete = new Array(); |
||
146 | var perm_addsub = new Array(); |
||
147 | var perm_remsub = new Array(); |
||
148 | |||
149 | JQUERY; |
||
150 | |||
151 | $rs = dal_query('templates/list.sql', $pid, 'template_name'); |
||
152 | |||
153 | View Code Duplication | while (($row = $rs->fetch())) |
|
154 | { |
||
155 | $permissions = group_get_permissions($id, $row['template_id']); |
||
156 | |||
157 | foreach ($gperms as $gperm) |
||
158 | { |
||
159 | $xml .= sprintf('%s["t%d"] = %s;', |
||
160 | $gperm[GPERMS_CONTROL], |
||
161 | $row['template_id'], |
||
162 | (($permissions & $gperm[GPERMS_PERMISSION]) == 0 ? 'false' : 'true')); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | // local JS functions |
||
167 | |||
168 | $resTitle = get_js_resource(RES_PERMISSIONS_ID); |
||
169 | $resMessage = get_js_resource(RES_ALERT_SUCCESSFULLY_SAVED_ID); |
||
170 | $resOK = get_js_resource(RES_OK_ID); |
||
171 | |||
172 | $xml .= <<<JQUERY |
||
173 | |||
174 | function permissionsSuccess () |
||
175 | { |
||
176 | var id = $("#template").val(); |
||
177 | |||
178 | perm_view["t"+id] = $("#perm_view").prop("checked"); |
||
179 | perm_create["t"+id] = $("#perm_create").prop("checked"); |
||
180 | perm_modify["t"+id] = $("#perm_modify").prop("checked"); |
||
181 | perm_postpone["t"+id] = $("#perm_postpone").prop("checked"); |
||
182 | perm_resume["t"+id] = $("#perm_resume").prop("checked"); |
||
183 | perm_reassign["t"+id] = $("#perm_reassign").prop("checked"); |
||
184 | perm_reopen["t"+id] = $("#perm_reopen").prop("checked"); |
||
185 | perm_comment["t"+id] = $("#perm_comment").prop("checked"); |
||
186 | perm_confidential["t"+id] = $("#perm_confidential").prop("checked"); |
||
187 | perm_attach["t"+id] = $("#perm_attach").prop("checked"); |
||
188 | perm_remove["t"+id] = $("#perm_remove").prop("checked"); |
||
189 | perm_remind["t"+id] = $("#perm_remind").prop("checked"); |
||
190 | perm_delete["t"+id] = $("#perm_delete").prop("checked"); |
||
191 | perm_addsub["t"+id] = $("#perm_addsub").prop("checked"); |
||
192 | perm_remsub["t"+id] = $("#perm_remsub").prop("checked"); |
||
193 | |||
194 | jqAlert("{$resTitle}", "{$resMessage}", "{$resOK}"); |
||
195 | } |
||
196 | |||
197 | function selectAll () |
||
198 | { |
||
199 | $("#permsform input:checkbox").prop("checked", true); |
||
200 | } |
||
201 | |||
202 | function updatePerms () |
||
203 | { |
||
204 | var id = $("#template").val(); |
||
205 | |||
206 | $("#perm_view").prop("checked", perm_view["t"+id]); |
||
207 | $("#perm_create").prop("checked", perm_create["t"+id]); |
||
208 | $("#perm_modify").prop("checked", perm_modify["t"+id]); |
||
209 | $("#perm_postpone").prop("checked", perm_postpone["t"+id]); |
||
210 | $("#perm_resume").prop("checked", perm_resume["t"+id]); |
||
211 | $("#perm_reassign").prop("checked", perm_reassign["t"+id]); |
||
212 | $("#perm_reopen").prop("checked", perm_reopen["t"+id]); |
||
213 | $("#perm_comment").prop("checked", perm_comment["t"+id]); |
||
214 | $("#perm_confidential").prop("checked", perm_confidential["t"+id]); |
||
215 | $("#perm_attach").prop("checked", perm_attach["t"+id]); |
||
216 | $("#perm_remove").prop("checked", perm_remove["t"+id]); |
||
217 | $("#perm_remind").prop("checked", perm_remind["t"+id]); |
||
218 | $("#perm_delete").prop("checked", perm_delete["t"+id]); |
||
219 | $("#perm_addsub").prop("checked", perm_addsub["t"+id]); |
||
220 | $("#perm_remsub").prop("checked", perm_remsub["t"+id]); |
||
221 | } |
||
222 | |||
223 | </script> |
||
224 | JQUERY; |
||
225 | |||
226 | // generate left side |
||
227 | |||
228 | $xml .= '<form name="permsform" action="gperms.php?pid=' . $pid . '&id=' . $id . '" success="permissionsSuccess">' |
||
229 | . '<dual>' |
||
230 | . '<dualleft>' |
||
231 | . '<group title="' . get_html_resource(RES_TEMPLATES_ID) . '">' |
||
232 | . '<control name="template">' |
||
233 | . '<listbox size="10" action="updatePerms()">'; |
||
234 | |||
235 | $rs->seek(); |
||
236 | |||
237 | while (($row = $rs->fetch())) |
||
238 | { |
||
239 | $xml .= '<listitem value="' . $row['template_id'] . '">' |
||
240 | . ustr2html($row['template_name']) |
||
241 | . '</listitem>'; |
||
242 | } |
||
243 | |||
244 | $xml .= '</listbox>' |
||
245 | . '</control>' |
||
246 | . '</group>' |
||
247 | . '</dualleft>'; |
||
248 | |||
249 | // generate right side |
||
250 | |||
251 | $xml .= '<dualright>' |
||
252 | . '<group title="' . get_html_resource(RES_PERMISSIONS_ID) . '">'; |
||
253 | |||
254 | View Code Duplication | foreach ($gperms as $gperm) |
|
255 | { |
||
256 | $xml .= '<control name="' . $gperm[GPERMS_CONTROL] . '">' |
||
257 | . '<checkbox>' . get_html_resource($gperm[GPERMS_RESOURCE]) . '</checkbox>' |
||
258 | . '</control>'; |
||
259 | } |
||
260 | |||
261 | $xml .= '</group>' |
||
262 | . '<button default="true">' . get_html_resource(RES_SAVE_ID) . '</button>' |
||
263 | . '<button action="selectAll()">' . get_html_resource(RES_SELECT_ALL_ID) . '</button>' |
||
264 | . '</dualright>' |
||
265 | . '</dual>' |
||
266 | . '</form>'; |
||
267 | |||
268 | $xml .= '<onready>' |
||
269 | . '$("#template :first-child").prop("selected", true);' |
||
270 | . 'updatePerms();' |
||
271 | . '</onready>'; |
||
272 | |||
273 | echo(xml2html($xml)); |
||
274 | |||
275 | ?> |
||
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...
|
|||
276 |
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.