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.
Check for implicit conversion of array to boolean.
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/projects.php'); |
||
33 | require_once('../dbo/templates.php'); |
||
34 | require_once('../dbo/filters.php'); |
||
35 | require_once('../dbo/values.php'); |
||
36 | /**#@-*/ |
||
37 | |||
38 | init_page(LOAD_TAB); |
||
39 | |||
40 | // check that requested filter exists |
||
41 | |||
42 | $id = ustr2int(try_request('id')); |
||
43 | $filter = filter_find($id); |
||
44 | |||
45 | if (!$filter) |
||
0 ignored issues
–
show
|
|||
46 | { |
||
47 | debug_write_log(DEBUG_NOTICE, 'Filter cannot be found.'); |
||
48 | exit; |
||
49 | } |
||
50 | |||
51 | // local JS functions |
||
52 | |||
53 | $resTitle = ustrprocess(get_js_resource(RES_FILTER_X_ID), ustr2js($filter['filter_name'])); |
||
54 | $resOK = get_js_resource(RES_OK_ID); |
||
55 | $resCancel = get_js_resource(RES_CANCEL_ID); |
||
56 | |||
57 | $xml = <<<JQUERY |
||
58 | <script> |
||
59 | |||
60 | function filterModify () |
||
61 | { |
||
62 | jqModal("{$resTitle}", "modify.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#modifyform').submit()"); |
||
63 | } |
||
64 | |||
65 | function filterToggle () |
||
66 | { |
||
67 | $.post("disable.php?id={$id}", function () { |
||
68 | reloadTab(); |
||
69 | }); |
||
70 | } |
||
71 | |||
72 | </script> |
||
73 | JQUERY; |
||
74 | |||
75 | // generate buttons |
||
76 | |||
77 | $xml .= '<button url="index.php">' . get_html_resource(RES_BACK_ID) . '</button>' |
||
78 | . '<buttonset>' |
||
79 | . '<button action="filterModify()">' . get_html_resource(RES_MODIFY_ID) . '</button>'; |
||
80 | |||
81 | $xml .= '<button url="delete.php?id=' . $id . '" prompt="' . get_html_resource(RES_CONFIRM_DELETE_FILTERS_ID) . '">' |
||
82 | . get_html_resource(RES_DELETE_ID) |
||
83 | . '</button>'; |
||
84 | |||
85 | $xml .= '<button action="filterToggle()">' |
||
86 | . get_html_resource(is_filter_activated($id) ? RES_DISABLE_ID : RES_ENABLE_ID) |
||
87 | . '</button>' |
||
88 | . '</buttonset>'; |
||
89 | |||
90 | // generate general information |
||
91 | |||
92 | $xml .= '<group title="' . get_html_resource(RES_GENERAL_INFO_ID) . '">'; |
||
93 | |||
94 | switch ($filter['filter_type']) |
||
95 | { |
||
96 | case FILTER_TYPE_ALL_PROJECTS: |
||
97 | |||
98 | $project_id = 0; |
||
99 | $template_id = 0; |
||
100 | |||
101 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . get_html_resource(RES_ALL_PROJECTS_ID) . '</text>'; |
||
102 | |||
103 | break; |
||
104 | |||
105 | case FILTER_TYPE_ALL_TEMPLATES: |
||
106 | |||
107 | $project = project_find($filter['filter_param']); |
||
108 | |||
109 | if ($project) |
||
0 ignored issues
–
show
The expression
$project 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...
|
|||
110 | { |
||
111 | $project_id = $project['project_id']; |
||
112 | $template_id = 0; |
||
113 | |||
114 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . ustr2html($project['project_name']) . '</text>'; |
||
115 | } |
||
116 | else |
||
117 | { |
||
118 | $project_id = 0; |
||
119 | $template_id = 0; |
||
120 | |||
121 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '"><i>' . get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID) . '</i></text>'; |
||
122 | } |
||
123 | |||
124 | $xml .= '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . get_html_resource(RES_ALL_TEMPLATES_ID) . '</text>'; |
||
125 | |||
126 | break; |
||
127 | |||
128 | case FILTER_TYPE_ALL_STATES: |
||
129 | |||
130 | $template = template_find($filter['filter_param']); |
||
131 | |||
132 | View Code Duplication | 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...
|
|||
133 | { |
||
134 | $project_id = $template['project_id']; |
||
135 | $template_id = $template['template_id']; |
||
136 | |||
137 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . ustr2html($template['project_name']) . '</text>' |
||
138 | . '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . ustr2html($template['template_name']) . '</text>'; |
||
139 | } |
||
140 | else |
||
141 | { |
||
142 | $project_id = 0; |
||
143 | $template_id = 0; |
||
144 | |||
145 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '"><i>' . get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID) . '</i></text>' |
||
146 | . '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '"><i>' . get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID) . '</i></text>'; |
||
147 | } |
||
148 | |||
149 | $xml .= '<text label="' . get_html_resource(RES_STATES_ID) . '">' . get_html_resource(RES_ALL_STATES_ID) . '</text>'; |
||
150 | |||
151 | break; |
||
152 | |||
153 | case FILTER_TYPE_SEL_STATES: |
||
154 | |||
155 | $template = template_find($filter['filter_param']); |
||
156 | |||
157 | View Code Duplication | 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...
|
|||
158 | { |
||
159 | $project_id = $template['project_id']; |
||
160 | $template_id = $template['template_id']; |
||
161 | |||
162 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . ustr2html($template['project_name']) . '</text>' |
||
163 | . '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . ustr2html($template['template_name']) . '</text>'; |
||
164 | } |
||
165 | else |
||
166 | { |
||
167 | $project_id = 0; |
||
168 | $template_id = 0; |
||
169 | |||
170 | $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '"><i>' . get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID) . '</i></text>' |
||
171 | . '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '"><i>' . get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID) . '</i></text>'; |
||
172 | } |
||
173 | |||
174 | $xml .= '<text label="' . get_html_resource(RES_STATES_ID) . '">'; |
||
175 | |||
176 | $states = filter_states_get($id, $template['template_id']); |
||
177 | |||
178 | $rs = dal_query('states/list.sql', $template['template_id'], 'state_name'); |
||
179 | |||
180 | while (($row = $rs->fetch())) |
||
181 | { |
||
182 | if (in_array($row['state_id'], $states)) |
||
183 | { |
||
184 | $xml .= ustr2html($row['state_name']) . '<br/>'; |
||
185 | } |
||
186 | } |
||
187 | |||
188 | $xml .= '</text>'; |
||
189 | |||
190 | break; |
||
191 | |||
192 | default: |
||
193 | |||
194 | $project_id = 0; |
||
195 | $template_id = 0; |
||
196 | |||
197 | debug_write_log(DEBUG_WARNING, 'Unknown filter type = ' . $filter['filter_type']); |
||
198 | } |
||
199 | |||
200 | $unclosed = ($filter['filter_flags'] & FILTER_FLAG_UNCLOSED) == 0 |
||
201 | ? RES_SHOW_ALL_ID |
||
202 | : RES_SHOW_UNCLOSED_ONLY_ID; |
||
203 | |||
204 | if (($filter['filter_flags'] & FILTER_FLAG_POSTPONED) != 0) |
||
205 | { |
||
206 | $postpone = RES_SHOW_POSTPONED_ONLY_ID; |
||
207 | } |
||
208 | elseif (($filter['filter_flags'] & FILTER_FLAG_ACTIVE) != 0) |
||
209 | { |
||
210 | $postpone = RES_SHOW_ACTIVE_ONLY_ID; |
||
211 | } |
||
212 | else |
||
213 | { |
||
214 | $postpone = RES_SHOW_ALL_ID; |
||
215 | } |
||
216 | |||
217 | $xml .= '<text label="' . get_html_resource(RES_FILTER_NAME_ID) . '">' . ustr2html($filter['filter_name']) . '</text>' |
||
218 | . '<text label="' . get_html_resource(RES_STATE_TYPE_ID) . '">' . get_html_resource($unclosed) . '</text>' |
||
219 | . '<text label="' . get_html_resource(RES_POSTPONE_STATUS_ID) . '">' . get_html_resource($postpone) . '</text>' |
||
220 | . '</group>'; |
||
221 | |||
222 | // generate "show only created by" list |
||
223 | |||
224 | $xml .= '<group title="' . get_html_resource(RES_SHOW_CREATED_BY_ONLY_ID) . '">'; |
||
225 | |||
226 | $flag = false; |
||
227 | |||
228 | $rs = ($project_id == 0) |
||
229 | ? dal_query('filters/membersx2.sql', $_SESSION[VAR_USERID], $id, FILTER_FLAG_CREATED_BY) |
||
230 | : dal_query('filters/membersx.sql', $project_id, $id, FILTER_FLAG_CREATED_BY); |
||
231 | |||
232 | View Code Duplication | while (($row = $rs->fetch())) |
|
233 | { |
||
234 | if ($row['is_selected']) |
||
235 | { |
||
236 | $flag = true; |
||
237 | $xml .= '<text>' . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username']))) . '</text>'; |
||
238 | } |
||
239 | } |
||
240 | |||
241 | if (!$flag) |
||
242 | { |
||
243 | $xml .= '<text>' . get_html_resource(RES_ANYONE_ID) . '</text>'; |
||
244 | } |
||
245 | |||
246 | $xml .= '</group>'; |
||
247 | |||
248 | // generate "show only assigned to" list |
||
249 | |||
250 | $xml .= '<group title="' . get_html_resource(RES_SHOW_ASSIGNED_TO_ONLY_ID) . '">'; |
||
251 | |||
252 | if (($filter['filter_flags'] & FILTER_FLAG_UNASSIGNED) != 0) |
||
253 | { |
||
254 | $flag = true; |
||
255 | $xml .= '<text>' . get_html_resource(RES_NONE2_ID) . '</text>'; |
||
256 | } |
||
257 | else |
||
258 | { |
||
259 | $flag = false; |
||
260 | } |
||
261 | |||
262 | $rs = ($project_id == 0) |
||
263 | ? dal_query('filters/membersx2.sql', $_SESSION[VAR_USERID], $id, FILTER_FLAG_ASSIGNED_TO) |
||
264 | : dal_query('filters/membersx.sql', $project_id, $id, FILTER_FLAG_ASSIGNED_TO); |
||
265 | |||
266 | View Code Duplication | while (($row = $rs->fetch())) |
|
267 | { |
||
268 | if ($row['is_selected']) |
||
269 | { |
||
270 | $flag = true; |
||
271 | $xml .= '<text>' . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username']))) . '</text>'; |
||
272 | } |
||
273 | } |
||
274 | |||
275 | if (!$flag) |
||
276 | { |
||
277 | $xml .= '<text>' . get_html_resource(RES_ANYONE_ID) . '</text>'; |
||
278 | } |
||
279 | |||
280 | $xml .= '</group>'; |
||
281 | |||
282 | // generate "show only moved to states" list |
||
283 | |||
284 | if ($template_id != 0) |
||
285 | { |
||
286 | $xml .= '<group title="' . get_html_resource(RES_SHOW_MOVED_TO_STATES_ONLY_ID) . '">'; |
||
287 | |||
288 | $rs = dal_query('states/list.sql', $template_id, 'state_type, state_name'); |
||
289 | |||
290 | while (($row = $rs->fetch())) |
||
291 | { |
||
292 | $rsd = dal_query('filters/ftfndk.sql', $id, $row['state_id']); |
||
293 | |||
294 | if ($rsd->rows != 0) |
||
295 | { |
||
296 | $date = $rsd->fetch(); |
||
297 | |||
298 | $xml .= '<text label="' . ustr2html($row['state_name']) . '">' |
||
299 | . sprintf('%s - %s', get_date($date['date1']), get_date($date['date2'])) |
||
300 | . '</text>'; |
||
301 | } |
||
302 | } |
||
303 | |||
304 | if (!isset($date)) |
||
305 | { |
||
306 | $xml .= '<text>' . get_html_resource(RES_NONE2_ID) . '</text>'; |
||
307 | } |
||
308 | |||
309 | $xml .= '</group>'; |
||
310 | } |
||
311 | |||
312 | // generate fields list |
||
313 | |||
314 | if ($template_id != 0) |
||
315 | { |
||
316 | $rs = dal_query('states/list.sql', $template_id, 'state_type, state_name'); |
||
317 | |||
318 | while (($row = $rs->fetch())) |
||
319 | { |
||
320 | $rsf = dal_query('filters/flist.sql', |
||
321 | $row['state_id'], |
||
322 | $_SESSION[VAR_USERID], |
||
323 | FIELD_ALLOW_TO_READ); |
||
324 | |||
325 | $state_name = $row['state_name']; |
||
326 | |||
327 | $text = NULL; |
||
328 | |||
329 | while (($row = $rsf->fetch())) |
||
330 | { |
||
331 | $rsp = dal_query('filters/fffndk.sql', $id, $row['field_id']); |
||
332 | |||
333 | if ($rsp->rows != 0) |
||
334 | { |
||
335 | $field = $rsp->fetch(); |
||
336 | $param1 = $field['param1']; |
||
337 | $param2 = $field['param2']; |
||
338 | |||
339 | $text .= '<text label="' . ustr2html($row['field_name']) . '">'; |
||
340 | |||
341 | switch ($row['field_type']) |
||
342 | { |
||
343 | case FIELD_TYPE_NUMBER: |
||
344 | case FIELD_TYPE_DATE: |
||
345 | $text .= sprintf('%s - %s', $param1, $param2); |
||
346 | break; |
||
347 | |||
348 | View Code Duplication | case FIELD_TYPE_FLOAT: |
|
349 | $text .= sprintf('%.10f - %.10f', value_find(FIELD_TYPE_FLOAT, $param1), value_find(FIELD_TYPE_FLOAT, $param2)); |
||
350 | break; |
||
351 | |||
352 | case FIELD_TYPE_STRING: |
||
353 | case FIELD_TYPE_MULTILINED: |
||
354 | $text .= ustr2html(value_find(FIELD_TYPE_STRING, $param1)); |
||
355 | break; |
||
356 | |||
357 | case FIELD_TYPE_CHECKBOX: |
||
358 | $text .= get_html_resource($param1 ? RES_ON_ID : RES_OFF_ID); |
||
359 | break; |
||
360 | |||
361 | case FIELD_TYPE_LIST: |
||
362 | $text .= ustr2html(value_find_listvalue($row['field_id'], $param1)); |
||
363 | break; |
||
364 | |||
365 | case FIELD_TYPE_RECORD: |
||
366 | $text .= sprintf('%s', $param1); |
||
367 | break; |
||
368 | |||
369 | case FIELD_TYPE_DURATION: |
||
370 | $text .= sprintf('%s - %s', time2ustr($param1), time2ustr($param2)); |
||
371 | break; |
||
372 | |||
373 | default: |
||
374 | debug_write_log(DEBUG_WARNING, 'Unknown field type = ' . $row['field_type']); |
||
375 | } |
||
376 | |||
377 | $text .= '</text>'; |
||
378 | } |
||
379 | } |
||
380 | |||
381 | if (!is_null($text)) |
||
382 | { |
||
383 | $xml .= '<group title="' . ustrprocess(get_html_resource(RES_FIELDS_OF_STATE_X_ID), $state_name) . '">' . $text . '</group>'; |
||
384 | } |
||
385 | } |
||
386 | } |
||
387 | |||
388 | echo(xml2html($xml)); |
||
389 | |||
390 | ?> |
||
391 |
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.