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/accounts.php'); |
||
33 | /**#@-*/ |
||
34 | |||
35 | init_page(LOAD_INLINE); |
||
36 | |||
37 | $error = NO_ERROR; |
||
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 | $accounts = dal_query('accounts/count.sql'); |
||
47 | |||
48 | if (MAX_ACCOUNTS_NUMBER != 0 && $accounts->fetch(0) >= MAX_ACCOUNTS_NUMBER) |
||
49 | { |
||
50 | debug_write_log(DEBUG_NOTICE, 'Maximum amount of accounts is already reached.'); |
||
51 | header('HTTP/1.1 307 index.php'); |
||
52 | exit; |
||
53 | } |
||
54 | |||
55 | // new account has been submitted |
||
56 | |||
57 | if (try_request('submitted') == 'createform') |
||
58 | { |
||
59 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
60 | |||
61 | $username = ustrcut($_REQUEST['username'], MAX_ACCOUNT_USERNAME); |
||
62 | $fullname = ustrcut($_REQUEST['fullname'], MAX_ACCOUNT_FULLNAME); |
||
63 | $email = ustrcut($_REQUEST['email'], MAX_ACCOUNT_EMAIL); |
||
64 | $description = ustrcut($_REQUEST['description'], MAX_ACCOUNT_DESCRIPTION); |
||
65 | $passwd1 = ustrcut($_REQUEST['passwd1'], MAX_ACCOUNT_PASSWORD); |
||
66 | $passwd2 = ustrcut($_REQUEST['passwd2'], MAX_ACCOUNT_PASSWORD); |
||
67 | $locale = ustr2int($_REQUEST['locale']); |
||
68 | $is_admin = isset($_REQUEST['is_admin']); |
||
69 | $is_disabled = isset($_REQUEST['is_disabled']); |
||
70 | |||
71 | $error = account_validate($username, |
||
72 | $fullname, |
||
73 | $email, |
||
74 | $passwd1, |
||
75 | $passwd2); |
||
76 | |||
77 | if ($error == NO_ERROR) |
||
78 | { |
||
79 | $error = account_create($username, |
||
80 | $fullname, |
||
81 | $email, |
||
82 | $passwd1, |
||
83 | $description, |
||
84 | $is_admin, |
||
85 | $is_disabled, |
||
86 | $locale); |
||
87 | } |
||
88 | |||
89 | View Code Duplication | switch ($error) |
|
90 | { |
||
91 | case NO_ERROR: |
||
92 | header('HTTP/1.0 200 OK'); |
||
93 | break; |
||
94 | |||
95 | case ERROR_INCOMPLETE_FORM: |
||
96 | send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
||
97 | break; |
||
98 | |||
99 | case ERROR_INVALID_USERNAME: |
||
100 | send_http_error(get_html_resource(RES_ALERT_INVALID_USERNAME_ID)); |
||
101 | break; |
||
102 | |||
103 | case ERROR_ALREADY_EXISTS: |
||
104 | send_http_error(get_html_resource(RES_ALERT_ACCOUNT_ALREADY_EXISTS_ID)); |
||
105 | break; |
||
106 | |||
107 | case ERROR_INVALID_EMAIL: |
||
108 | send_http_error(get_html_resource(RES_ALERT_INVALID_EMAIL_ID)); |
||
109 | break; |
||
110 | |||
111 | case ERROR_PASSWORDS_DO_NOT_MATCH: |
||
112 | send_http_error(get_html_resource(RES_ALERT_PASSWORDS_DO_NOT_MATCH_ID)); |
||
113 | break; |
||
114 | |||
115 | case ERROR_PASSWORD_TOO_SHORT: |
||
116 | send_http_error(ustrprocess(get_html_resource(RES_ALERT_PASSWORD_TOO_SHORT_ID), MIN_PASSWORD_LENGTH)); |
||
117 | break; |
||
118 | |||
119 | default: |
||
120 | send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
||
121 | } |
||
122 | |||
123 | exit; |
||
124 | } |
||
125 | else |
||
126 | { |
||
127 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
128 | |||
129 | $username = NULL; |
||
130 | $fullname = NULL; |
||
131 | $email = NULL; |
||
132 | $description = NULL; |
||
133 | $locale = LANG_DEFAULT; |
||
134 | $is_admin = FALSE; |
||
135 | $is_disabled = FALSE; |
||
136 | } |
||
137 | |||
138 | // local JS functions |
||
139 | |||
140 | $resTitle = get_js_resource(RES_ERROR_ID); |
||
141 | $resOK = get_js_resource(RES_OK_ID); |
||
142 | |||
143 | $xml = <<<JQUERY |
||
144 | <script> |
||
145 | |||
146 | function createSuccess () |
||
147 | { |
||
148 | closeModal(); |
||
149 | reloadTab(); |
||
150 | } |
||
151 | |||
152 | function createError (XMLHttpRequest) |
||
153 | { |
||
154 | jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
||
155 | } |
||
156 | |||
157 | </script> |
||
158 | JQUERY; |
||
159 | |||
160 | // generate page |
||
161 | |||
162 | $xml .= '<form name="createform" action="create.php" success="createSuccess" error="createError">' |
||
163 | . '<group>' |
||
164 | . '<control name="username" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
165 | . '<label>' . get_html_resource(RES_USERNAME_ID) . '</label>' |
||
166 | . '<editbox maxlen="' . MAX_ACCOUNT_USERNAME . '">' . ustr2html($username) . '</editbox>' |
||
167 | . '</control>' |
||
168 | . '<control name="fullname" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
169 | . '<label>' . get_html_resource(RES_FULLNAME_ID) . '</label>' |
||
170 | . '<editbox maxlen="' . MAX_ACCOUNT_FULLNAME . '">' . ustr2html($fullname) . '</editbox>' |
||
171 | . '</control>' |
||
172 | . '<control name="email" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
173 | . '<label>' . get_html_resource(RES_EMAIL_ID) . '</label>' |
||
174 | . '<editbox maxlen="' . MAX_ACCOUNT_EMAIL . '">' . ustr2html($email) . '</editbox>' |
||
175 | . '</control>' |
||
176 | . '<control name="description">' |
||
177 | . '<label>' . get_html_resource(RES_DESCRIPTION_ID) . '</label>' |
||
178 | . '<editbox maxlen="' . MAX_ACCOUNT_DESCRIPTION . '">' . ustr2html($description) . '</editbox>' |
||
179 | . '</control>' |
||
180 | . '<control name="passwd1" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
181 | . '<label>' . get_html_resource(RES_PASSWORD_ID) . '</label>' |
||
182 | . '<passbox maxlen="' . MAX_ACCOUNT_PASSWORD . '"/>' |
||
183 | . '</control>' |
||
184 | . '<control name="passwd2" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
185 | . '<label>' . get_html_resource(RES_PASSWORD_CONFIRM_ID) . '</label>' |
||
186 | . '<passbox maxlen="' . MAX_ACCOUNT_PASSWORD . '"/>' |
||
187 | . '</control>' |
||
188 | . '<control name="locale" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
189 | . '<label>' . get_html_resource(RES_LANGUAGE_ID) . '</label>' |
||
190 | . '<combobox>'; |
||
191 | |||
192 | $supported_locales = get_supported_locales_sorted(); |
||
193 | |||
194 | View Code Duplication | foreach ($supported_locales as $locale_id => $locale_name) |
|
195 | { |
||
196 | $xml .= ($locale == $locale_id |
||
197 | ? '<listitem value="' . $locale_id . '" selected="true">' |
||
198 | : '<listitem value="' . $locale_id . '">') |
||
199 | . $locale_name |
||
200 | . '</listitem>'; |
||
201 | } |
||
202 | |||
203 | $xml .= '</combobox>' |
||
204 | . '</control>' |
||
205 | . '<control name="is_admin">' |
||
206 | . '<label/>' |
||
207 | . ($is_admin |
||
208 | ? '<checkbox checked="true">' |
||
209 | : '<checkbox>') |
||
210 | . get_html_resource(RES_ADMINISTRATOR_ID) |
||
211 | . '</checkbox>' |
||
212 | . '</control>' |
||
213 | . '<control name="is_disabled">' |
||
214 | . '<label/>' |
||
215 | . ($is_disabled |
||
216 | ? '<checkbox checked="true">' |
||
217 | : '<checkbox>') |
||
218 | . get_html_resource(RES_DISABLED_ID) |
||
219 | . '</checkbox>' |
||
220 | . '</control>' |
||
221 | . '</group>' |
||
222 | . '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>' |
||
223 | . '<note>' . ustrprocess(get_html_resource(RES_ALERT_PASSWORD_TOO_SHORT_ID), MIN_PASSWORD_LENGTH) . '</note>' |
||
224 | . '</form>'; |
||
225 | |||
226 | echo(xml2html($xml)); |
||
227 | |||
228 | ?> |
||
0 ignored issues
–
show
|
|||
229 |
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.