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 | // check that requested account exists |
||
47 | |||
48 | $id = ustr2int(try_request('id')); |
||
49 | $account = account_find($id); |
||
50 | |||
51 | if (!$account) |
||
52 | { |
||
53 | debug_write_log(DEBUG_NOTICE, 'Account cannot be found.'); |
||
54 | header('HTTP/1.1 307 index.php'); |
||
55 | exit; |
||
56 | } |
||
57 | |||
58 | if ($account['is_ldapuser']) |
||
59 | { |
||
60 | debug_write_log(DEBUG_NOTICE, 'Active Directory account cannot be modified.'); |
||
61 | header('HTTP/1.1 307 index.php'); |
||
62 | exit; |
||
63 | } |
||
64 | |||
65 | // changed account has been submitted |
||
66 | |||
67 | if (try_request('submitted') == 'modifyform') |
||
68 | { |
||
69 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
70 | |||
71 | $username = ustrcut($_REQUEST['username'], MAX_ACCOUNT_USERNAME); |
||
72 | $fullname = ustrcut($_REQUEST['fullname'], MAX_ACCOUNT_FULLNAME); |
||
73 | $email = ustrcut($_REQUEST['email'], MAX_ACCOUNT_EMAIL); |
||
74 | $description = ustrcut($_REQUEST['description'], MAX_ACCOUNT_DESCRIPTION); |
||
75 | $passwd1 = ustrcut($_REQUEST['passwd1'], MAX_ACCOUNT_PASSWORD); |
||
76 | $passwd2 = ustrcut($_REQUEST['passwd2'], MAX_ACCOUNT_PASSWORD); |
||
77 | $locale = ustr2int($_REQUEST['locale']); |
||
78 | $is_admin = isset($_REQUEST['is_admin']); |
||
79 | $is_disabled = isset($_REQUEST['is_disabled']); |
||
80 | $is_locked = isset($_REQUEST['is_locked']); |
||
81 | |||
82 | $error = account_validate($username, |
||
83 | $fullname, |
||
84 | $email, |
||
85 | $passwd1, |
||
86 | $passwd2); |
||
87 | |||
88 | if ($error == NO_ERROR) |
||
89 | { |
||
90 | $error = account_modify($id, |
||
91 | $username, |
||
92 | $fullname, |
||
93 | $email, |
||
94 | $description, |
||
95 | $is_admin, |
||
96 | $is_disabled, |
||
97 | ($is_locked ? $account['locks_count'] : 0)); |
||
98 | |||
99 | if ($error == NO_ERROR) |
||
100 | { |
||
101 | if ($passwd1 != str_repeat('*', MAX_ACCOUNT_PASSWORD)) |
||
102 | { |
||
103 | dal_query('accounts/passwd.sql', $id, base64_encode(sha1($passwd1, TRUE)), 0); |
||
104 | } |
||
105 | |||
106 | if ($locale != $account['locale']) |
||
107 | { |
||
108 | locale_change($id, $locale); |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 | |||
113 | View Code Duplication | switch ($error) |
|
0 ignored issues
–
show
|
|||
114 | { |
||
115 | case NO_ERROR: |
||
116 | header('HTTP/1.0 200 OK'); |
||
117 | break; |
||
118 | |||
119 | case ERROR_INCOMPLETE_FORM: |
||
120 | send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
||
121 | break; |
||
122 | |||
123 | case ERROR_INVALID_USERNAME: |
||
124 | send_http_error(get_html_resource(RES_ALERT_INVALID_USERNAME_ID)); |
||
125 | break; |
||
126 | |||
127 | case ERROR_ALREADY_EXISTS: |
||
128 | send_http_error(get_html_resource(RES_ALERT_ACCOUNT_ALREADY_EXISTS_ID)); |
||
129 | break; |
||
130 | |||
131 | case ERROR_INVALID_EMAIL: |
||
132 | send_http_error(get_html_resource(RES_ALERT_INVALID_EMAIL_ID)); |
||
133 | break; |
||
134 | |||
135 | case ERROR_PASSWORDS_DO_NOT_MATCH: |
||
136 | send_http_error(get_html_resource(RES_ALERT_PASSWORDS_DO_NOT_MATCH_ID)); |
||
137 | break; |
||
138 | |||
139 | case ERROR_PASSWORD_TOO_SHORT: |
||
140 | send_http_error(ustrprocess(get_html_resource(RES_ALERT_PASSWORD_TOO_SHORT_ID), MIN_PASSWORD_LENGTH)); |
||
141 | break; |
||
142 | |||
143 | default: |
||
144 | send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
||
145 | } |
||
146 | |||
147 | exit; |
||
148 | } |
||
149 | else |
||
150 | { |
||
151 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
152 | |||
153 | $username = account_get_username($account['username'], FALSE); |
||
154 | $fullname = $account['fullname']; |
||
155 | $email = $account['email']; |
||
156 | $description = $account['description']; |
||
157 | $passwd1 = $account['passwd']; |
||
158 | $passwd2 = $account['passwd']; |
||
159 | $locale = $account['locale']; |
||
160 | $is_admin = $account['is_admin']; |
||
161 | $is_disabled = $account['is_disabled']; |
||
162 | $is_locked = is_account_locked($account['locks_count'], $account['lock_time']); |
||
163 | } |
||
164 | |||
165 | // local JS functions |
||
166 | |||
167 | $resTitle = get_js_resource(RES_ERROR_ID); |
||
168 | $resOK = get_js_resource(RES_OK_ID); |
||
169 | |||
170 | $xml = <<<JQUERY |
||
171 | <script> |
||
172 | |||
173 | function modifySuccess () |
||
174 | { |
||
175 | closeModal(); |
||
176 | reloadTab(); |
||
177 | } |
||
178 | |||
179 | function modifyError (XMLHttpRequest) |
||
180 | { |
||
181 | jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
||
182 | } |
||
183 | |||
184 | </script> |
||
185 | JQUERY; |
||
186 | |||
187 | // generate page |
||
188 | |||
189 | $xml .= '<form name="modifyform" action="modify.php?id=' . $id . '" success="modifySuccess" error="modifyError">' |
||
190 | . '<group>' |
||
191 | . '<control name="username" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
192 | . '<label>' . get_html_resource(RES_USERNAME_ID) . '</label>' |
||
193 | . '<editbox maxlen="' . MAX_ACCOUNT_USERNAME . '">' . ustr2html($username) . '</editbox>' |
||
194 | . '</control>' |
||
195 | . '<control name="fullname" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
196 | . '<label>' . get_html_resource(RES_FULLNAME_ID) . '</label>' |
||
197 | . '<editbox maxlen="' . MAX_ACCOUNT_FULLNAME . '">' . ustr2html($fullname) . '</editbox>' |
||
198 | . '</control>' |
||
199 | . '<control name="email" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
200 | . '<label>' . get_html_resource(RES_EMAIL_ID) . '</label>' |
||
201 | . '<editbox maxlen="' . MAX_ACCOUNT_EMAIL . '">' . ustr2html($email) . '</editbox>' |
||
202 | . '</control>' |
||
203 | . '<control name="description">' |
||
204 | . '<label>' . get_html_resource(RES_DESCRIPTION_ID) . '</label>' |
||
205 | . '<editbox maxlen="' . MAX_ACCOUNT_DESCRIPTION . '">' . ustr2html($description) . '</editbox>' |
||
206 | . '</control>' |
||
207 | . '<control name="passwd1" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
208 | . '<label>' . get_html_resource(RES_PASSWORD_ID) . '</label>' |
||
209 | . '<passbox maxlen="' . MAX_ACCOUNT_PASSWORD . '">' . str_repeat('*', MAX_ACCOUNT_PASSWORD) . '</passbox>' |
||
210 | . '</control>' |
||
211 | . '<control name="passwd2" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
212 | . '<label>' . get_html_resource(RES_PASSWORD_CONFIRM_ID) . '</label>' |
||
213 | . '<passbox maxlen="' . MAX_ACCOUNT_PASSWORD . '">' . str_repeat('*', MAX_ACCOUNT_PASSWORD) . '</passbox>' |
||
214 | . '</control>' |
||
215 | . '<control name="locale" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
||
216 | . '<label>' . get_html_resource(RES_LANGUAGE_ID) . '</label>' |
||
217 | . '<combobox>'; |
||
218 | |||
219 | $supported_locales = get_supported_locales_sorted(); |
||
220 | |||
221 | View Code Duplication | foreach ($supported_locales as $locale_id => $locale_name) |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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.
Loading history...
|
|||
222 | { |
||
223 | $xml .= ($locale == $locale_id |
||
224 | ? '<listitem value="' . $locale_id . '" selected="true">' |
||
225 | : '<listitem value="' . $locale_id . '">') |
||
226 | . $locale_name |
||
227 | . '</listitem>'; |
||
228 | } |
||
229 | |||
230 | $xml .= '</combobox>' |
||
231 | . '</control>' |
||
232 | . '<control name="is_admin">' |
||
233 | . '<label/>' |
||
234 | . ($is_admin |
||
235 | ? '<checkbox checked="true">' |
||
236 | : '<checkbox>') |
||
237 | . get_html_resource(RES_ADMINISTRATOR_ID) |
||
238 | . '</checkbox>' |
||
239 | . '</control>' |
||
240 | . '<control name="is_disabled">' |
||
241 | . '<label/>' |
||
242 | . ($is_disabled |
||
243 | ? '<checkbox checked="true">' |
||
244 | : '<checkbox>') |
||
245 | . get_html_resource(RES_DISABLED_ID) |
||
246 | . '</checkbox>' |
||
247 | . '</control>' |
||
248 | . (is_account_locked($account['locks_count'], $account['lock_time']) |
||
249 | ? '<control name="is_locked">' |
||
250 | : '<control name="is_locked" disabled="true">') |
||
251 | . '<label/>' |
||
252 | . ($is_locked |
||
253 | ? '<checkbox checked="true">' |
||
254 | : '<checkbox>') |
||
255 | . get_html_resource(RES_LOCKED_ID) |
||
256 | . '</checkbox>' |
||
257 | . '</control>' |
||
258 | . '</group>' |
||
259 | . '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>' |
||
260 | . '<note>' . ustrprocess(get_html_resource(RES_ALERT_PASSWORD_TOO_SHORT_ID), MIN_PASSWORD_LENGTH) . '</note>' |
||
261 | . '</form>'; |
||
262 | |||
263 | echo(xml2html($xml)); |
||
264 | |||
265 | ?> |
||
266 |
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.