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/events.php'); |
||
35 | /**#@-*/ |
||
36 | |||
37 | init_page(LOAD_INLINE); |
||
38 | |||
39 | // check that requested record exists |
||
40 | |||
41 | $id = ustr2int(try_request('id')); |
||
42 | $record = record_find($id); |
||
43 | |||
44 | if (!$record) |
||
45 | { |
||
46 | debug_write_log(DEBUG_NOTICE, 'Record cannot be found.'); |
||
47 | header('HTTP/1.1 307 index.php'); |
||
48 | exit; |
||
49 | } |
||
50 | |||
51 | // get current user's permissions and verify them |
||
52 | |||
53 | $permissions = record_get_permissions($record['template_id'], $record['creator_id'], $record['responsible_id']); |
||
54 | |||
55 | View Code Duplication | if (!can_record_be_postponed($record, $permissions)) |
|
0 ignored issues
–
show
|
|||
56 | { |
||
57 | debug_write_log(DEBUG_NOTICE, 'Record cannot be postponed.'); |
||
58 | header('HTTP/1.1 307 view.php?id=' . $id); |
||
59 | exit; |
||
60 | } |
||
61 | |||
62 | // get current date |
||
63 | |||
64 | $today = date_floor(time()); |
||
65 | |||
66 | // postpone form is submitted |
||
67 | |||
68 | if (try_request('submitted') == 'postponeform') |
||
69 | { |
||
70 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
71 | |||
72 | $value = ustrcut(try_request('duedate'), ustrlen(get_date(SAMPLE_DATE))); |
||
73 | $comment = ustrcut(try_request('comment'), MAX_COMMENT_BODY); |
||
74 | |||
75 | if (ustrlen($value) == 0) |
||
76 | { |
||
77 | debug_write_log(DEBUG_NOTICE, 'Date value is not specified.'); |
||
78 | send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
||
79 | } |
||
80 | else |
||
81 | { |
||
82 | $duedate = ustr2date($value); |
||
83 | |||
84 | if ($duedate == -1) |
||
85 | { |
||
86 | debug_write_log(DEBUG_NOTICE, 'Invalid date value.'); |
||
87 | send_http_error(get_html_resource(RES_ALERT_INVALID_DATE_VALUE_ID)); |
||
88 | } |
||
89 | elseif ($duedate < ($today + SECS_IN_DAY)) |
||
90 | { |
||
91 | debug_write_log(DEBUG_NOTICE, 'Date value is out of range.'); |
||
92 | send_http_error(ustrprocess(get_js_resource(RES_ALERT_DATE_VALUE_OUT_OF_RANGE_ID), get_date($today + SECS_IN_DAY), get_date(MAXINT))); |
||
93 | } |
||
94 | else |
||
95 | { |
||
96 | if (ustrlen($comment) != 0) |
||
97 | { |
||
98 | comment_add($id, $comment); |
||
99 | } |
||
100 | |||
101 | record_postpone($id, $duedate); |
||
102 | $event = event_create($id, EVENT_RECORD_POSTPONED, time(), $duedate); |
||
103 | event_mail($event); |
||
104 | |||
105 | header('HTTP/1.0 200 OK'); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | exit; |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
114 | |||
115 | $duedate = $today + SECS_IN_WEEK; |
||
116 | $comment = NULL; |
||
117 | } |
||
118 | |||
119 | // local JS functions |
||
120 | |||
121 | $resTitle = get_js_resource(RES_ERROR_ID); |
||
122 | $resOK = get_js_resource(RES_OK_ID); |
||
123 | |||
124 | $xml = <<<JQUERY |
||
125 | <script> |
||
126 | |||
127 | function postponeSuccess () |
||
128 | { |
||
129 | closeModal(); |
||
130 | reloadTab(); |
||
131 | } |
||
132 | |||
133 | function postponeError (XMLHttpRequest) |
||
134 | { |
||
135 | jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
||
136 | } |
||
137 | |||
138 | </script> |
||
139 | JQUERY; |
||
140 | |||
141 | // generate postpone form |
||
142 | |||
143 | $xml .= '<form name="postponeform" action="postpone.php?id=' . $id . '" success="postponeSuccess" error="postponeError">' |
||
144 | . '<group>' |
||
145 | . '<control name="duedate" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
146 | . '<label>' . sprintf('%s (%s)', get_html_resource(RES_DUEDATE_ID), get_date_format_str()) . '</label>' |
||
147 | . '<editbox maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">' |
||
148 | . ustr2html(get_date($duedate)) |
||
149 | . '</editbox>' |
||
150 | . '</control>' |
||
151 | . '<control name="comment">' |
||
152 | . '<label>' . get_html_resource(RES_COMMENT_ID) . '</label>' |
||
153 | . '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_COMMENT_BODY . '">' |
||
154 | . ustr2html($comment) |
||
155 | . '</textbox>' |
||
156 | . '</control>' |
||
157 | . '</group>' |
||
158 | . '<note>' . ustrprocess(get_html_resource(RES_ALERT_DATE_VALUE_OUT_OF_RANGE_ID), get_date($today + SECS_IN_DAY), get_date(MAXINT)) . '</note>' |
||
159 | . '<script>' |
||
160 | . '$("#duedate").datepicker($.datepicker.regional["' . $_SESSION[VAR_LOCALE] . '"]);' |
||
161 | . '</script>' |
||
162 | . '</form>'; |
||
163 | |||
164 | echo(xml2html($xml)); |
||
165 | |||
166 | ?> |
||
167 |
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.