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 that a closing PHP tag ("?>") is never present
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/subscriptions.php'); |
||
33 | /**#@-*/ |
||
34 | |||
35 | init_page(LOAD_INLINE); |
||
36 | |||
37 | if (!EMAIL_NOTIFICATIONS_ENABLED) |
||
38 | { |
||
39 | debug_write_log(DEBUG_NOTICE, 'Email Notifications functionality is disabled.'); |
||
40 | header('HTTP/1.1 307 ../index.php'); |
||
41 | exit; |
||
42 | } |
||
43 | |||
44 | $error = NO_ERROR; |
||
45 | $subscription_name = NULL; |
||
46 | $carbon_copy = NULL; |
||
47 | $subscription_flags = DEFAULT_NOTIFY_FLAG; |
||
48 | |||
49 | // project has been selected |
||
50 | |||
51 | if (try_request('submitted') == 'projectform') |
||
52 | { |
||
53 | debug_write_log(DEBUG_NOTICE, 'Project is selected.'); |
||
54 | |||
55 | $project_id = ustr2int(try_request('project')); |
||
56 | |||
57 | View Code Duplication | if ($project_id == 0) |
|
58 | { |
||
59 | $project_name = get_html_resource(RES_ALL_PROJECTS_ID); |
||
60 | $form = 'createform'; |
||
61 | } |
||
62 | else |
||
63 | { |
||
64 | $rs = dal_query('records/pfndid2.sql', $_SESSION[VAR_USERID], $project_id); |
||
65 | |||
66 | if ($rs->rows == 0) |
||
67 | { |
||
68 | debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
||
69 | header('HTTP/1.1 307 index.php'); |
||
70 | exit; |
||
71 | } |
||
72 | |||
73 | $project_name = $rs->fetch('project_name'); |
||
74 | $form = 'templateform'; |
||
75 | } |
||
76 | } |
||
77 | |||
78 | // template has been selected |
||
79 | |||
80 | elseif (try_request('submitted') == 'templateform') |
||
81 | { |
||
82 | debug_write_log(DEBUG_NOTICE, 'Template is selected.'); |
||
83 | |||
84 | $project_id = ustr2int(try_request('project')); |
||
85 | $template_id = ustr2int(try_request('template')); |
||
86 | |||
87 | if ($template_id == 0) |
||
88 | { |
||
89 | $rs = dal_query('records/pfndid2.sql', $_SESSION[VAR_USERID], $project_id); |
||
90 | |||
91 | if ($rs->rows == 0) |
||
92 | { |
||
93 | debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
||
94 | header('HTTP/1.1 307 index.php'); |
||
95 | exit; |
||
96 | } |
||
97 | |||
98 | $project_name = $rs->fetch('project_name'); |
||
99 | $template_name = get_html_resource(RES_ALL_TEMPLATES_ID); |
||
100 | $form = 'createform'; |
||
101 | } |
||
102 | View Code Duplication | else |
|
103 | { |
||
104 | $rs = dal_query('records/tfndid2.sql', $_SESSION[VAR_USERID], $project_id, $template_id); |
||
105 | |||
106 | if ($rs->rows == 0) |
||
107 | { |
||
108 | debug_write_log(DEBUG_NOTICE, 'Template cannot be found.'); |
||
109 | header('HTTP/1.1 307 index.php'); |
||
110 | exit; |
||
111 | } |
||
112 | |||
113 | $row = $rs->fetch(); |
||
114 | |||
115 | $project_name = $row['project_name']; |
||
116 | $template_name = $row['template_name']; |
||
117 | $form = 'createform'; |
||
118 | } |
||
119 | } |
||
120 | |||
121 | // new subscription has been submitted |
||
122 | |||
123 | elseif (try_request('submitted') == 'createform') |
||
124 | { |
||
125 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
126 | |||
127 | $project_id = ustr2int(try_request('project')); |
||
128 | $template_id = ustr2int(try_request('template')); |
||
129 | |||
130 | $subscription_name = ustrcut($_REQUEST['subscription_name'], MAX_SUBSCRIPTION_NAME); |
||
131 | $carbon_copy = ustrcut($_REQUEST['carbon_copy'], MAX_SUBSCRIPTION_CARBON_COPY); |
||
132 | $subscription_flags = 0; |
||
133 | |||
134 | View Code Duplication | foreach ($notifications as $notification) |
|
135 | { |
||
136 | $subscription_flags |= (isset($_REQUEST[$notification[NOTIFY_CONTROL]]) ? $notification[NOTIFY_EVENT] : 0); |
||
137 | } |
||
138 | |||
139 | $error = subscription_validate($subscription_name, $carbon_copy); |
||
140 | |||
141 | if ($error == NO_ERROR) |
||
142 | { |
||
143 | if ($project_id == 0) |
||
144 | { |
||
145 | $subscription_type = SUBSCRIPTION_TYPE_ALL_PROJECTS; |
||
146 | $subscription_param = NULL; |
||
147 | } |
||
148 | elseif ($template_id == 0) |
||
149 | { |
||
150 | $subscription_type = SUBSCRIPTION_TYPE_ALL_TEMPLATES; |
||
151 | $subscription_param = $project_id; |
||
152 | } |
||
153 | else |
||
154 | { |
||
155 | $subscription_type = SUBSCRIPTION_TYPE_ONE_TEMPLATE; |
||
156 | $subscription_param = $template_id; |
||
157 | } |
||
158 | |||
159 | $error = subscription_create($subscription_name, |
||
160 | $carbon_copy, |
||
161 | $subscription_type, |
||
162 | $subscription_flags, |
||
163 | $subscription_param); |
||
164 | } |
||
165 | |||
166 | View Code Duplication | switch ($error) |
|
167 | { |
||
168 | case NO_ERROR: |
||
169 | header('HTTP/1.0 200 OK'); |
||
170 | break; |
||
171 | |||
172 | case ERROR_INCOMPLETE_FORM: |
||
173 | send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
||
174 | break; |
||
175 | |||
176 | case ERROR_ALREADY_EXISTS: |
||
177 | send_http_error(get_html_resource(RES_ALERT_SUBSCRIPTION_ALREADY_EXISTS_ID)); |
||
178 | break; |
||
179 | |||
180 | case ERROR_INVALID_EMAIL: |
||
181 | send_http_error(get_html_resource(RES_ALERT_INVALID_EMAIL_ID)); |
||
182 | break; |
||
183 | |||
184 | default: |
||
185 | send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
||
186 | } |
||
187 | |||
188 | exit; |
||
189 | } |
||
190 | else |
||
191 | { |
||
192 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
193 | |||
194 | $form = 'projectform'; |
||
195 | } |
||
196 | |||
197 | // local JS functions |
||
198 | |||
199 | $resTitle = get_js_resource(RES_ERROR_ID); |
||
200 | $resOK = get_js_resource(RES_OK_ID); |
||
201 | |||
202 | $xml = <<<JQUERY |
||
203 | <script> |
||
204 | |||
205 | function createSuccess () |
||
206 | { |
||
207 | closeModal(); |
||
208 | reloadTab(); |
||
209 | } |
||
210 | |||
211 | function createError (XMLHttpRequest) |
||
212 | { |
||
213 | jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
||
214 | } |
||
215 | |||
216 | </script> |
||
217 | JQUERY; |
||
218 | |||
219 | // generate header |
||
220 | |||
221 | $xml .= '<form name="' . $form . '" action="create.php" success="createSuccess" error="createError">' |
||
222 | . '<group>'; |
||
223 | |||
224 | // generate project selector |
||
225 | |||
226 | View Code Duplication | if ($form == 'projectform') |
|
227 | { |
||
228 | $xml .= '<control name="project" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
229 | . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>' |
||
230 | . '<combobox>' |
||
231 | . '<listitem value="0">' . get_html_resource(RES_ALL_PROJECTS_ID) . '</listitem>'; |
||
232 | |||
233 | $rs = dal_query('records/plist2.sql', $_SESSION[VAR_USERID]); |
||
234 | |||
235 | while (($row = $rs->fetch())) |
||
236 | { |
||
237 | $xml .= '<listitem value="' . $row['project_id'] . '">' |
||
238 | . ustr2html($row['project_name']) |
||
239 | . '</listitem>'; |
||
240 | } |
||
241 | |||
242 | $xml .= '</combobox>' |
||
243 | . '</control>'; |
||
244 | } |
||
245 | elseif (isset($project_id)) |
||
246 | { |
||
247 | $xml .= '<control name="project" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
248 | . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>' |
||
249 | . '<combobox>' |
||
250 | . '<listitem value="' . $project_id . '">' . ustr2html($project_name) . '</listitem>' |
||
251 | . '</combobox>' |
||
252 | . '</control>'; |
||
253 | } |
||
254 | |||
255 | // generate template selector |
||
256 | |||
257 | View Code Duplication | if ($form == 'templateform') |
|
258 | { |
||
259 | $xml .= '<control name="template" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
260 | . '<label>' . get_html_resource(RES_TEMPLATE_ID) . '</label>' |
||
261 | . '<combobox>' |
||
262 | . '<listitem value="0">' . get_html_resource(RES_ALL_TEMPLATES_ID) . '</listitem>'; |
||
263 | |||
264 | $rs = dal_query('records/tlist2.sql', $_SESSION[VAR_USERID], $project_id); |
||
265 | |||
266 | while (($row = $rs->fetch())) |
||
267 | { |
||
268 | $xml .= '<listitem value="' . $row['template_id'] . '">' |
||
269 | . ustr2html($row['template_name']) |
||
270 | . '</listitem>'; |
||
271 | } |
||
272 | |||
273 | $xml .= '</combobox>' |
||
274 | . '</control>'; |
||
275 | } |
||
276 | elseif (isset($template_id)) |
||
277 | { |
||
278 | $xml .= '<control name="template" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
279 | . '<label>' . get_html_resource(RES_TEMPLATE_ID) . '</label>' |
||
280 | . '<combobox>' |
||
281 | . '<listitem value="' . $template_id . '">' . ustr2html($template_name) . '</listitem>' |
||
282 | . '</combobox>' |
||
283 | . '</control>'; |
||
284 | } |
||
285 | |||
286 | // generate other subscription attributes |
||
287 | |||
288 | if ($form == 'createform') |
||
289 | { |
||
290 | $xml .= '<control name="subscription_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
291 | . '<label>' . get_html_resource(RES_SUBSCRIPTION_NAME_ID) . '</label>' |
||
292 | . '<editbox maxlen="' . MAX_SUBSCRIPTION_NAME . '">' . ustr2html($subscription_name) . '</editbox>' |
||
293 | . '</control>' |
||
294 | . '<control name="carbon_copy">' |
||
295 | . '<label>' . get_html_resource(RES_CARBON_COPY_ID) . '</label>' |
||
296 | . '<editbox maxlen="' . MAX_SUBSCRIPTION_CARBON_COPY . '">' . ustr2html($carbon_copy) . '</editbox>' |
||
297 | . '</control>' |
||
298 | . '</group>' |
||
299 | . '<group title="' . get_html_resource(RES_EVENTS_ID) . '">'; |
||
300 | |||
301 | View Code Duplication | foreach ($notifications as $notification) |
|
302 | { |
||
303 | $xml .= '<control name="' . $notification[NOTIFY_CONTROL] . '">' |
||
304 | . (($subscription_flags & $notification[NOTIFY_EVENT]) != 0 |
||
305 | ? '<checkbox checked="true">' |
||
306 | : '<checkbox>') |
||
307 | . get_html_resource($notification[NOTIFY_RESOURCE]) |
||
308 | . '</checkbox>' |
||
309 | . '</control>'; |
||
310 | } |
||
311 | } |
||
312 | |||
313 | // generate footer |
||
314 | |||
315 | $xml .= '</group>' |
||
316 | . '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>' |
||
317 | . '</form>'; |
||
318 | |||
319 | echo(xml2html($xml)); |
||
320 | |||
321 | ?> |
||
0 ignored issues
–
show
|
|||
322 |
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.