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) 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/projects.php'); |
||
33 | require_once('../dbo/fields.php'); |
||
34 | require_once('../dbo/values.php'); |
||
35 | /**#@-*/ |
||
36 | |||
37 | init_page(LOAD_INLINE); |
||
38 | |||
39 | if (get_user_level() != USER_LEVEL_ADMIN) |
||
40 | { |
||
41 | debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
||
42 | header('HTTP/1.1 307 index.php'); |
||
43 | exit; |
||
44 | } |
||
45 | |||
46 | // check that requested field exists |
||
47 | |||
48 | $id = ustr2int(try_request('id')); |
||
49 | $field = field_find($id); |
||
50 | |||
51 | if (!$field) |
||
0 ignored issues
–
show
|
|||
52 | { |
||
53 | debug_write_log(DEBUG_NOTICE, 'Field cannot be found.'); |
||
54 | header('HTTP/1.1 307 index.php'); |
||
55 | exit; |
||
56 | } |
||
57 | |||
58 | View Code Duplication | if (!$field['is_locked']) |
|
59 | { |
||
60 | debug_write_log(DEBUG_NOTICE, 'Template must be locked.'); |
||
61 | header('HTTP/1.1 307 fview.php?id=' . $id); |
||
62 | exit; |
||
63 | } |
||
64 | |||
65 | // changed field has been submitted |
||
66 | |||
67 | $error = NO_ERROR; |
||
68 | $fields = field_count($field['state_id']); |
||
69 | |||
70 | if (try_request('submitted') == 'modifyform') |
||
71 | { |
||
72 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
73 | |||
74 | $field_name = ustrcut($_REQUEST['field_name'], MAX_FIELD_NAME); |
||
75 | $field_order = ustr2int($_REQUEST['field_order'], 1, $fields); |
||
76 | $is_required = ($field['field_type'] == FIELD_TYPE_CHECKBOX ? FALSE : isset($_REQUEST['is_required'])); |
||
77 | $guest_access = isset($_REQUEST['guest_access']); |
||
78 | $add_separator = isset($_REQUEST['add_separator']); |
||
79 | $show_in_emails = isset($_REQUEST['show_in_emails']); |
||
80 | $description = ustrcut($_REQUEST['description'], MAX_FIELD_DESCRIPTION); |
||
81 | |||
82 | switch ($field['field_type']) |
||
83 | { |
||
84 | View Code Duplication | case FIELD_TYPE_NUMBER: |
|
85 | |||
86 | $param1 = $_REQUEST['min_value']; |
||
87 | $param2 = $_REQUEST['max_value']; |
||
88 | $default = $_REQUEST['def_value']; |
||
89 | $default = (ustrlen($default) == 0 ? NULL : intval($default)); |
||
90 | $error = field_validate_number($field_name, $param1, $param2, $default); |
||
91 | |||
92 | break; |
||
93 | |||
94 | View Code Duplication | case FIELD_TYPE_FLOAT: |
|
95 | |||
96 | $param1 = $_REQUEST['min_value']; |
||
97 | $param2 = $_REQUEST['max_value']; |
||
98 | $default = $_REQUEST['def_value']; |
||
99 | $default = (ustrlen($default) == 0 ? NULL : $default); |
||
100 | $error = field_validate_float($field_name, $param1, $param2, $default); |
||
101 | |||
102 | break; |
||
103 | |||
104 | case FIELD_TYPE_STRING: |
||
105 | |||
106 | $param1 = $_REQUEST['max_length']; |
||
107 | $param2 = NULL; |
||
108 | $error = field_validate_string($field_name, $param1); |
||
109 | |||
110 | break; |
||
111 | |||
112 | case FIELD_TYPE_MULTILINED: |
||
113 | |||
114 | $param1 = $_REQUEST['max_length']; |
||
115 | $param2 = NULL; |
||
116 | $error = field_validate_multilined($field_name, $param1); |
||
117 | |||
118 | break; |
||
119 | |||
120 | case FIELD_TYPE_CHECKBOX: |
||
121 | |||
122 | $param1 = NULL; |
||
123 | $param2 = NULL; |
||
124 | $default = ustr2int(try_request('def_value', 1), 0, 1); |
||
125 | $error = NO_ERROR; |
||
126 | |||
127 | break; |
||
128 | |||
129 | case FIELD_TYPE_LIST: |
||
130 | |||
131 | $param1 = NULL; |
||
132 | $param2 = NULL; |
||
133 | $default = try_request('def_value'); |
||
134 | $default = (ustrlen($default) == 0 ? NULL : ustr2int($default, 1, MAXINT)); |
||
135 | $error = NO_ERROR; |
||
136 | |||
137 | break; |
||
138 | |||
139 | case FIELD_TYPE_RECORD: |
||
140 | |||
141 | $param1 = NULL; |
||
142 | $param2 = NULL; |
||
143 | $default = NULL; |
||
144 | $error = NO_ERROR; |
||
145 | |||
146 | break; |
||
147 | |||
148 | case FIELD_TYPE_DATE: |
||
149 | |||
150 | $param1 = ustrcut($_REQUEST['min_value'], ustrlen(MIN_FIELD_DATE)); |
||
151 | $param2 = ustrcut($_REQUEST['max_value'], ustrlen(MIN_FIELD_DATE)); |
||
152 | $default = ustrcut($_REQUEST['def_value'], ustrlen(MIN_FIELD_DATE)); |
||
153 | $default = (ustrlen($default) == 0 ? NULL : $default); |
||
154 | $error = field_validate_date($field_name, $param1, $param2, $default); |
||
155 | |||
156 | break; |
||
157 | |||
158 | case FIELD_TYPE_DURATION: |
||
159 | |||
160 | $param1 = ustrcut($_REQUEST['min_value'], ustrlen(time2ustr(MAX_FIELD_DURATION))); |
||
161 | $param2 = ustrcut($_REQUEST['max_value'], ustrlen(time2ustr(MAX_FIELD_DURATION))); |
||
162 | $default = ustrcut($_REQUEST['def_value'], ustrlen(time2ustr(MAX_FIELD_DURATION))); |
||
163 | $default = (ustrlen($default) == 0 ? NULL : $default); |
||
164 | $error = field_validate_duration($field_name, $param1, $param2, $default); |
||
165 | |||
166 | break; |
||
167 | |||
168 | default: ; // nop |
||
169 | } |
||
170 | |||
171 | if ($error == NO_ERROR) |
||
172 | { |
||
173 | $regex_check = NULL; |
||
174 | $regex_search = NULL; |
||
175 | $regex_replace = NULL; |
||
176 | |||
177 | $field_param1 = $param1; |
||
178 | $field_param2 = $param2; |
||
179 | |||
180 | if ($field['field_type'] == FIELD_TYPE_FLOAT) |
||
181 | { |
||
182 | $field_param1 = value_find_float($field_param1); |
||
183 | $field_param2 = value_find_float($field_param2); |
||
184 | $default = (ustrlen($default) == 0 ? NULL : value_find_float($default)); |
||
185 | } |
||
186 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_STRING) |
|
187 | { |
||
188 | $regex_check = ustrcut($_REQUEST['regex_check'], MAX_FIELD_REGEX); |
||
189 | $regex_search = ustrcut($_REQUEST['regex_search'], MAX_FIELD_REGEX); |
||
190 | $regex_replace = ustrcut($_REQUEST['regex_replace'], MAX_FIELD_REGEX); |
||
191 | $default = ustrcut($_REQUEST['def_value'], $field_param1); |
||
192 | $default = (ustrlen($default) == 0 ? NULL : value_find_string($default)); |
||
193 | } |
||
194 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_MULTILINED) |
|
195 | { |
||
196 | $regex_check = ustrcut($_REQUEST['regex_check'], MAX_FIELD_REGEX); |
||
197 | $regex_search = ustrcut($_REQUEST['regex_search'], MAX_FIELD_REGEX); |
||
198 | $regex_replace = ustrcut($_REQUEST['regex_replace'], MAX_FIELD_REGEX); |
||
199 | $default = ustrcut($_REQUEST['def_value'], $field_param1); |
||
200 | $default = (ustrlen($default) == 0 ? NULL : value_find_multilined($default)); |
||
201 | } |
||
202 | elseif ($field['field_type'] == FIELD_TYPE_DATE) |
||
203 | { |
||
204 | $default = (is_null($default) ? NULL : ustr2int($default, MIN_FIELD_DATE, MAX_FIELD_DATE)); |
||
205 | } |
||
206 | elseif ($field['field_type'] == FIELD_TYPE_DURATION) |
||
207 | { |
||
208 | $field_param1 = ustr2time($field_param1); |
||
209 | $field_param2 = ustr2time($field_param2); |
||
210 | $default = (is_null($default) ? NULL : ustr2time($default)); |
||
211 | } |
||
212 | |||
213 | $error = field_modify($id, |
||
214 | $field['state_id'], |
||
215 | $field['state_name'], |
||
216 | $field['field_name'], |
||
217 | $field_name, |
||
218 | $field['field_order'], |
||
219 | $field_order, |
||
220 | $field['field_type'], |
||
221 | $is_required, |
||
222 | $add_separator, |
||
223 | $guest_access, |
||
224 | $show_in_emails, |
||
225 | $description, |
||
226 | $regex_check, |
||
227 | $regex_search, |
||
228 | $regex_replace, |
||
229 | $field_param1, |
||
230 | $field_param2, |
||
231 | $default); |
||
232 | |||
233 | if ($error == NO_ERROR) |
||
234 | { |
||
235 | if ($field['field_type'] == FIELD_TYPE_LIST) |
||
236 | { |
||
237 | $list_items = ustrcut($_REQUEST['list_items'], MAX_FIELD_LIST_ITEMS); |
||
238 | field_create_list_items($field['state_id'], $field_name, $list_items); |
||
239 | } |
||
240 | } |
||
241 | } |
||
242 | |||
243 | View Code Duplication | switch ($error) |
|
244 | { |
||
245 | case NO_ERROR: |
||
246 | header('HTTP/1.0 200 OK'); |
||
247 | break; |
||
248 | |||
249 | case ERROR_INCOMPLETE_FORM: |
||
250 | send_http_error(get_js_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
||
251 | break; |
||
252 | |||
253 | case ERROR_ALREADY_EXISTS: |
||
254 | send_http_error(get_js_resource(RES_ALERT_FIELD_ALREADY_EXISTS_ID)); |
||
255 | break; |
||
256 | |||
257 | case ERROR_INVALID_INTEGER_VALUE: |
||
258 | send_http_error(get_js_resource(RES_ALERT_INVALID_INTEGER_VALUE_ID)); |
||
259 | break; |
||
260 | |||
261 | case ERROR_INVALID_FLOAT_VALUE: |
||
262 | send_http_error(get_js_resource(RES_ALERT_INVALID_DECIMAL_VALUE_ID)); |
||
263 | break; |
||
264 | |||
265 | case ERROR_INTEGER_VALUE_OUT_OF_RANGE: |
||
266 | case ERROR_FLOAT_VALUE_OUT_OF_RANGE: |
||
267 | |||
268 | if (try_request('submitted') == 'numberform') |
||
269 | { |
||
270 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), -MAX_FIELD_INTEGER, +MAX_FIELD_INTEGER)); |
||
271 | } |
||
272 | elseif (try_request('submitted') == 'floatform') |
||
273 | { |
||
274 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_DECIMAL_VALUE_OUT_OF_RANGE_ID), MIN_FIELD_FLOAT, MAX_FIELD_FLOAT)); |
||
275 | } |
||
276 | elseif (try_request('submitted') == 'stringform') |
||
277 | { |
||
278 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), 1, MAX_FIELD_STRING)); |
||
279 | } |
||
280 | elseif (try_request('submitted') == 'multilinedform') |
||
281 | { |
||
282 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), 1, MAX_FIELD_MULTILINED)); |
||
283 | } |
||
284 | else |
||
285 | { |
||
286 | send_http_error(get_js_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
||
287 | } |
||
288 | |||
289 | break; |
||
290 | |||
291 | case ERROR_MIN_MAX_VALUES: |
||
292 | send_http_error(get_js_resource(RES_ALERT_MIN_MAX_VALUES_ID)); |
||
293 | break; |
||
294 | |||
295 | case ERROR_INVALID_DATE_VALUE: |
||
296 | send_http_error(get_js_resource(RES_ALERT_INVALID_DATE_VALUE_ID)); |
||
297 | break; |
||
298 | |||
299 | case ERROR_DATE_VALUE_OUT_OF_RANGE: |
||
300 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_DATE_VALUE_OUT_OF_RANGE_ID), MIN_FIELD_DATE, MAX_FIELD_DATE)); |
||
301 | break; |
||
302 | |||
303 | case ERROR_INVALID_TIME_VALUE: |
||
304 | send_http_error(get_js_resource(RES_ALERT_INVALID_TIME_VALUE_ID)); |
||
305 | break; |
||
306 | |||
307 | case ERROR_TIME_VALUE_OUT_OF_RANGE: |
||
308 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_TIME_VALUE_OUT_OF_RANGE_ID), time2ustr(MIN_FIELD_DURATION), time2ustr(MAX_FIELD_DURATION))); |
||
309 | break; |
||
310 | |||
311 | case ERROR_DEFAULT_VALUE_OUT_OF_RANGE: |
||
312 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_DEFAULT_VALUE_OUT_OF_RANGE_ID), $param1, $param2)); |
||
313 | break; |
||
314 | |||
315 | default: |
||
316 | send_http_error(get_js_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
||
317 | } |
||
318 | |||
319 | exit; |
||
320 | } |
||
321 | else |
||
322 | { |
||
323 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
324 | |||
325 | $field_name = $field['field_name']; |
||
326 | $field_order = $field['field_order']; |
||
327 | $is_required = $field['is_required']; |
||
328 | $add_separator = $field['add_separator']; |
||
329 | $guest_access = $field['guest_access']; |
||
330 | $show_in_emails = $field['show_in_emails']; |
||
331 | $description = $field['description']; |
||
332 | $regex_check = $field['regex_check']; |
||
333 | $regex_search = $field['regex_search']; |
||
334 | $regex_replace = $field['regex_replace']; |
||
335 | $param1 = $field['param1']; |
||
336 | $param2 = $field['param2']; |
||
337 | $default = $field['value_id']; |
||
338 | |||
339 | if ($field['field_type'] == FIELD_TYPE_FLOAT) |
||
340 | { |
||
341 | $param1 = value_find(FIELD_TYPE_FLOAT, $param1); |
||
342 | $param2 = value_find(FIELD_TYPE_FLOAT, $param2); |
||
343 | } |
||
344 | elseif ($field['field_type'] == FIELD_TYPE_LIST) |
||
345 | { |
||
346 | $list_items = field_pickup_list_items($id); |
||
347 | } |
||
348 | elseif ($field['field_type'] == FIELD_TYPE_DURATION) |
||
349 | { |
||
350 | $param1 = time2ustr($param1); |
||
351 | $param2 = time2ustr($param2); |
||
352 | } |
||
353 | |||
354 | if (!is_null($default)) |
||
355 | { |
||
356 | switch ($field['field_type']) |
||
357 | { |
||
358 | case FIELD_TYPE_FLOAT: |
||
359 | case FIELD_TYPE_STRING: |
||
360 | case FIELD_TYPE_MULTILINED: |
||
361 | $default = value_find($field['field_type'], $default); |
||
362 | break; |
||
363 | |||
364 | case FIELD_TYPE_DURATION: |
||
365 | $default = time2ustr($default); |
||
366 | break; |
||
367 | |||
368 | default: ; // nop |
||
369 | } |
||
370 | } |
||
371 | } |
||
372 | |||
373 | // local JS functions |
||
374 | |||
375 | $resTitle = get_js_resource(RES_ERROR_ID); |
||
376 | $resOK = get_js_resource(RES_OK_ID); |
||
377 | |||
378 | $xml = <<<JQUERY |
||
379 | <script> |
||
380 | |||
381 | function modifySuccess () |
||
382 | { |
||
383 | closeModal(); |
||
384 | reloadTab(); |
||
385 | } |
||
386 | |||
387 | function modifyError (XMLHttpRequest) |
||
388 | { |
||
389 | jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
||
390 | } |
||
391 | |||
392 | </script> |
||
393 | JQUERY; |
||
394 | |||
395 | // generate header |
||
396 | |||
397 | $xml .= '<form name="modifyform" action="fmodify.php?id=' . $id . '" success="modifySuccess" error="modifyError">' |
||
398 | . '<group>'; |
||
399 | |||
400 | // generate common controls |
||
401 | |||
402 | $xml .= '<control name="field_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
403 | . '<label>' . get_html_resource(RES_FIELD_NAME_ID) . '</label>' |
||
404 | . '<editbox maxlen="' . MAX_FIELD_NAME . '">' . ustr2html($field_name) . '</editbox>' |
||
405 | . '</control>' |
||
406 | . '<control name="field_order" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
407 | . '<label>' . get_html_resource(RES_ORDER_ID) . '</label>' |
||
408 | . '<editbox maxlen="' . ustrlen($fields) . '">' . ustr2html($field_order) . '</editbox>' |
||
409 | . '</control>'; |
||
410 | |||
411 | $notes = '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>'; |
||
412 | |||
413 | // generate controls for 'number' field |
||
414 | |||
415 | if ($field['field_type'] == FIELD_TYPE_NUMBER) |
||
416 | { |
||
417 | $xml .= '<control name="min_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
418 | . '<label>' . get_html_resource(RES_MIN_VALUE_ID) . '</label>' |
||
419 | . '<editbox maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">' |
||
420 | . ustr2html($param1) |
||
421 | . '</editbox>' |
||
422 | . '</control>'; |
||
423 | |||
424 | $xml .= '<control name="max_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
425 | . '<label>' . get_html_resource(RES_MAX_VALUE_ID) . '</label>' |
||
426 | . '<editbox maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">' |
||
427 | . ustr2html($param2) |
||
428 | . '</editbox>' |
||
429 | . '</control>'; |
||
430 | |||
431 | $xml .= '<control name="def_value">' |
||
432 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
433 | . '<editbox maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">' |
||
434 | . ustr2html($default) |
||
435 | . '</editbox>' |
||
436 | . '</control>'; |
||
437 | |||
438 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), -MAX_FIELD_INTEGER, +MAX_FIELD_INTEGER) . '</note>' |
||
439 | . '<note>' . get_html_resource(RES_ALERT_MIN_MAX_VALUES_ID) . '</note>'; |
||
440 | } |
||
441 | |||
442 | // generate controls for 'decimal' field |
||
443 | |||
444 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_FLOAT) |
|
445 | { |
||
446 | $xml .= '<control name="min_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
447 | . '<label>' . get_html_resource(RES_MIN_VALUE_ID) . '</label>' |
||
448 | . '<editbox maxlen="' . ustrlen(MIN_FIELD_FLOAT) . '">' |
||
449 | . ustr2html($param1) |
||
450 | . '</editbox>' |
||
451 | . '</control>'; |
||
452 | |||
453 | $xml .= '<control name="max_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
454 | . '<label>' . get_html_resource(RES_MAX_VALUE_ID) . '</label>' |
||
455 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_FLOAT) . '">' |
||
456 | . ustr2html($param2) |
||
457 | . '</editbox>' |
||
458 | . '</control>'; |
||
459 | |||
460 | $xml .= '<control name="def_value">' |
||
461 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
462 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_FLOAT) . '">' |
||
463 | . ustr2html($default) |
||
464 | . '</editbox>' |
||
465 | . '</control>'; |
||
466 | |||
467 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_DECIMAL_VALUE_OUT_OF_RANGE_ID), MIN_FIELD_FLOAT, MAX_FIELD_FLOAT) . '</note>' |
||
468 | . '<note>' . get_html_resource(RES_ALERT_MIN_MAX_VALUES_ID) . '</note>'; |
||
469 | } |
||
470 | |||
471 | // generate controls for 'string' field |
||
472 | |||
473 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_STRING) |
|
474 | { |
||
475 | $xml .= '<control name="max_length" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
476 | . '<label>' . get_html_resource(RES_MAX_LENGTH_ID) . '</label>' |
||
477 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_STRING) . '">' |
||
478 | . ustr2html($param1) |
||
479 | . '</editbox>' |
||
480 | . '</control>'; |
||
481 | |||
482 | $xml .= '<control name="def_value">' |
||
483 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
484 | . '<editbox maxlen="' . MAX_FIELD_STRING . '">' |
||
485 | . ustr2html($default) |
||
486 | . '</editbox>' |
||
487 | . '</control>'; |
||
488 | |||
489 | $xml .= '<control name="regex_check">' |
||
490 | . '<label>' . get_html_resource(RES_REGEX_CHECK_ID) . '</label>' |
||
491 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
492 | . ustr2html($regex_check) |
||
493 | . '</editbox>' |
||
494 | . '</control>'; |
||
495 | |||
496 | $xml .= '<control name="regex_search">' |
||
497 | . '<label>' . get_html_resource(RES_REGEX_SEARCH_ID) . '</label>' |
||
498 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
499 | . ustr2html($regex_search) |
||
500 | . '</editbox>' |
||
501 | . '</control>'; |
||
502 | |||
503 | $xml .= '<control name="regex_replace">' |
||
504 | . '<label>' . get_html_resource(RES_REGEX_REPLACE_ID) . '</label>' |
||
505 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
506 | . ustr2html($regex_replace) |
||
507 | . '</editbox>' |
||
508 | . '</control>'; |
||
509 | |||
510 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), 1, MAX_FIELD_STRING) . '</note>'; |
||
511 | } |
||
512 | |||
513 | // generate controls for 'multilined' field |
||
514 | |||
515 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_MULTILINED) |
|
516 | { |
||
517 | $xml .= '<control name="max_length" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
518 | . '<label>' . get_html_resource(RES_MAX_LENGTH_ID) . '</label>' |
||
519 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_MULTILINED) . '">' |
||
520 | . ustr2html($param1) |
||
521 | . '</editbox>' |
||
522 | . '</control>'; |
||
523 | |||
524 | $xml .= '<control name="def_value">' |
||
525 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
526 | . '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_FIELD_MULTILINED . '">' |
||
527 | . ustr2html($default) |
||
528 | . '</textbox>' |
||
529 | . '</control>'; |
||
530 | |||
531 | $xml .= '<control name="regex_check">' |
||
532 | . '<label>' . get_html_resource(RES_REGEX_CHECK_ID) . '</label>' |
||
533 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
534 | . ustr2html($regex_check) |
||
535 | . '</editbox>' |
||
536 | . '</control>'; |
||
537 | |||
538 | $xml .= '<control name="regex_search">' |
||
539 | . '<label>' . get_html_resource(RES_REGEX_SEARCH_ID) . '</label>' |
||
540 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
541 | . ustr2html($regex_search) |
||
542 | . '</editbox>' |
||
543 | . '</control>'; |
||
544 | |||
545 | $xml .= '<control name="regex_replace">' |
||
546 | . '<label>' . get_html_resource(RES_REGEX_REPLACE_ID) . '</label>' |
||
547 | . '<editbox maxlen="' . MAX_FIELD_REGEX . '">' |
||
548 | . ustr2html($regex_replace) |
||
549 | . '</editbox>' |
||
550 | . '</control>'; |
||
551 | |||
552 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_INTEGER_VALUE_OUT_OF_RANGE_ID), 1, MAX_FIELD_MULTILINED) . '</note>'; |
||
553 | } |
||
554 | |||
555 | // generate controls for 'checkbox' field |
||
556 | |||
557 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_CHECKBOX) |
|
558 | { |
||
559 | $xml .= '<control name="def_value">' |
||
560 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
561 | . '<radio value="1"' . ($default != 0 ? ' checked="true">' : '>') . get_html_resource(RES_ON_ID) . '</radio>' |
||
562 | . '<radio value="0"' . ($default == 0 ? ' checked="true">' : '>') . get_html_resource(RES_OFF_ID) . '</radio>' |
||
563 | . '</control>'; |
||
564 | } |
||
565 | |||
566 | // generate controls for 'list' field |
||
567 | |||
568 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_LIST) |
|
569 | { |
||
570 | $xml .= '<control name="list_items" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
571 | . '<label>' . get_html_resource(RES_LIST_ITEMS_ID) . '</label>' |
||
572 | . '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_FIELD_LIST_ITEMS . '">' |
||
573 | . ustr2html($list_items) |
||
574 | . '</textbox>' |
||
575 | . '</control>'; |
||
576 | |||
577 | $xml .= '<control name="def_value">' |
||
578 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
579 | . '<editbox maxlen="' . ustrlen(MAXINT) . '">' |
||
580 | . ustr2html($default) |
||
581 | . '</editbox>' |
||
582 | . '</control>'; |
||
583 | } |
||
584 | |||
585 | // generate controls for 'date' field |
||
586 | |||
587 | elseif ($field['field_type'] == FIELD_TYPE_DATE) |
||
588 | { |
||
589 | $xml .= '<control name="min_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
590 | . '<label>' . get_html_resource(RES_MIN_VALUE_ID) . '</label>' |
||
591 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_DATE) . '">' |
||
592 | . ustr2html($param1) |
||
593 | . '</editbox>' |
||
594 | . '</control>'; |
||
595 | |||
596 | $xml .= '<control name="max_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
597 | . '<label>' . get_html_resource(RES_MAX_VALUE_ID) . '</label>' |
||
598 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_DATE) . '">' |
||
599 | . ustr2html($param2) |
||
600 | . '</editbox>' |
||
601 | . '</control>'; |
||
602 | |||
603 | $xml .= '<control name="def_value">' |
||
604 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
605 | . '<editbox maxlen="' . ustrlen(MAX_FIELD_DATE) . '">' |
||
606 | . ustr2html($default) |
||
607 | . '</editbox>' |
||
608 | . '</control>'; |
||
609 | |||
610 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_DATE_VALUE_OUT_OF_RANGE_ID), MIN_FIELD_DATE, MAX_FIELD_DATE) . '</note>' |
||
611 | . '<note>' . ustrprocess(get_html_resource(RES_ALERT_DEFAULT_VALUE_OUT_OF_RANGE_ID), MIN_FIELD_DATE, MAX_FIELD_DATE) . '</note>' |
||
612 | . '<note>' . get_html_resource(RES_ALERT_MIN_MAX_VALUES_ID) . '</note>'; |
||
613 | } |
||
614 | |||
615 | // generate controls for 'duration' field |
||
616 | |||
617 | View Code Duplication | elseif ($field['field_type'] == FIELD_TYPE_DURATION) |
|
618 | { |
||
619 | $xml .= '<control name="min_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
620 | . '<label>' . get_html_resource(RES_MIN_VALUE_ID) . '</label>' |
||
621 | . '<editbox maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">' |
||
622 | . ustr2html($param1) |
||
623 | . '</editbox>' |
||
624 | . '</control>'; |
||
625 | |||
626 | $xml .= '<control name="max_value" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
627 | . '<label>' . get_html_resource(RES_MAX_VALUE_ID) . '</label>' |
||
628 | . '<editbox maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">' |
||
629 | . ustr2html($param2) |
||
630 | . '</editbox>' |
||
631 | . '</control>'; |
||
632 | |||
633 | $xml .= '<control name="def_value">' |
||
634 | . '<label>' . get_html_resource(RES_DEFAULT_VALUE_ID) . '</label>' |
||
635 | . '<editbox maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">' |
||
636 | . ustr2html($default) |
||
637 | . '</editbox>' |
||
638 | . '</control>'; |
||
639 | |||
640 | $notes .= '<note>' . ustrprocess(get_html_resource(RES_ALERT_TIME_VALUE_OUT_OF_RANGE_ID), time2ustr(MIN_FIELD_DURATION), time2ustr(MAX_FIELD_DURATION)) . '</note>' |
||
641 | . '<note>' . get_html_resource(RES_ALERT_MIN_MAX_VALUES_ID) . '</note>'; |
||
642 | } |
||
643 | |||
644 | // generate common controls |
||
645 | |||
646 | $xml .= '<control name="description">' |
||
647 | . '<label>' . get_html_resource(RES_DESCRIPTION_ID) . '</label>' |
||
648 | . '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_FIELD_DESCRIPTION . '">' |
||
649 | . ustr2html($description) |
||
650 | . '</textbox>' |
||
651 | . '</control>'; |
||
652 | |||
653 | View Code Duplication | if ($field['field_type'] != FIELD_TYPE_CHECKBOX) |
|
654 | { |
||
655 | $xml .= '<control name="is_required">' |
||
656 | . '<label/>' |
||
657 | . ($is_required |
||
658 | ? '<checkbox checked="true">' |
||
659 | : '<checkbox>') |
||
660 | . ustrtolower(get_html_resource(RES_REQUIRED2_ID)) |
||
661 | . '</checkbox>' |
||
662 | . '</control>'; |
||
663 | } |
||
664 | |||
665 | $xml .= '<control name="guest_access">' |
||
666 | . '<label/>' |
||
667 | . ($guest_access |
||
668 | ? '<checkbox checked="true">' |
||
669 | : '<checkbox>') |
||
670 | . ustrtolower(get_html_resource(RES_GUEST_ACCESS_ID)) |
||
671 | . '</checkbox>' |
||
672 | . '</control>'; |
||
673 | |||
674 | $xml .= '<control name="add_separator">' |
||
675 | . '<label/>' |
||
676 | . ($add_separator |
||
677 | ? '<checkbox checked="true">' |
||
678 | : '<checkbox>') |
||
679 | . ustrtolower(get_html_resource(RES_ADD_SEPARATOR_ID)) |
||
680 | . '</checkbox>' |
||
681 | . '</control>'; |
||
682 | |||
683 | $xml .= '<control name="show_in_emails">' |
||
684 | . '<label/>' |
||
685 | . ($show_in_emails |
||
686 | ? '<checkbox checked="true">' |
||
687 | : '<checkbox>') |
||
688 | . ustrtolower(get_html_resource(RES_SHOW_IN_EMAILS_ID)) |
||
689 | . '</checkbox>' |
||
690 | . '</control>'; |
||
691 | |||
692 | // generate footer |
||
693 | |||
694 | $xml .= '</group>' |
||
695 | . $notes |
||
696 | . '</form>'; |
||
697 | |||
698 | echo(xml2html($xml)); |
||
699 | |||
700 | ?> |
||
701 |
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.