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-2010 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 | require_once('../dbo/groups.php'); |
||
34 | require_once('../dbo/projects.php'); |
||
35 | /**#@-*/ |
||
36 | |||
37 | init_page(LOAD_TAB); |
||
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 | exit; |
||
43 | } |
||
44 | |||
45 | // check that requested project exists |
||
46 | |||
47 | $pid = ustr2int(try_request('pid')); |
||
48 | $project = project_find($pid); |
||
49 | |||
50 | if (!$project) |
||
0 ignored issues
–
show
|
|||
51 | { |
||
52 | debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
||
53 | exit; |
||
54 | } |
||
55 | |||
56 | // check that requested group exists |
||
57 | |||
58 | $id = ustr2int(try_request('id')); |
||
59 | $group = group_find($id); |
||
60 | |||
61 | if (!$group) |
||
0 ignored issues
–
show
The expression
$group of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
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
Loading history...
|
|||
62 | { |
||
63 | debug_write_log(DEBUG_NOTICE, 'Group cannot be found.'); |
||
64 | exit; |
||
65 | } |
||
66 | |||
67 | // add/remove selected accounts |
||
68 | |||
69 | View Code Duplication | if (try_request('submitted') == 'othersform') |
|
70 | { |
||
71 | debug_write_log(DEBUG_NOTICE, 'Data are submitted (adding new members).'); |
||
72 | |||
73 | if (LDAP_ENABLED && !LDAP_ENUMERATION) |
||
74 | { |
||
75 | $accounts = ustrcut($_REQUEST['accounts'], 1000); |
||
76 | $accounts = ustr_replace("\n", ',', $accounts); |
||
77 | |||
78 | mb_regex_encoding('UTF-8'); |
||
79 | $names = mb_split(',', $accounts); |
||
80 | |||
81 | $accounts = NULL; |
||
82 | } |
||
83 | else |
||
84 | { |
||
85 | $names = try_request('accounts', array()); |
||
86 | } |
||
87 | |||
88 | foreach ($names as $username) |
||
89 | { |
||
90 | $username = trim($username); |
||
91 | |||
92 | if (ustrlen($username) != 0) |
||
93 | { |
||
94 | if (LDAP_ENABLED && !LDAP_ENUMERATION) |
||
95 | { |
||
96 | if (usubstr($username, ustrlen($username) - 1, 1) == '@') |
||
97 | { |
||
98 | debug_write_log(DEBUG_NOTICE, 'Found @ at the end of login.'); |
||
99 | $username = usubstr($username, 0, ustrlen($username) - 1); |
||
100 | $account = FALSE; |
||
101 | } |
||
102 | else |
||
103 | { |
||
104 | $account = account_find_username($username . ACCOUNT_SUFFIX); |
||
105 | } |
||
106 | } |
||
107 | else |
||
108 | { |
||
109 | $account = account_find_username($username); |
||
110 | } |
||
111 | |||
112 | if ($account) |
||
113 | { |
||
114 | group_membership_add($id, $account['account_id']); |
||
115 | } |
||
116 | else |
||
117 | { |
||
118 | $account_id = (LDAP_ENABLED ? account_register_ldapuser($username) : NULL); |
||
119 | |||
120 | if (is_null($account_id)) |
||
121 | { |
||
122 | debug_write_log(DEBUG_NOTICE, 'Cannot find Active Directory account.'); |
||
123 | |||
124 | if (LDAP_ENABLED && !LDAP_ENUMERATION) |
||
125 | { |
||
126 | $accounts .= $username . "\n"; |
||
127 | } |
||
128 | } |
||
129 | else |
||
130 | { |
||
131 | group_membership_add($id, $account_id); |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 | |||
137 | if (LDAP_ENABLED && !LDAP_ENUMERATION) |
||
138 | { |
||
139 | $_SESSION[VAR_LDAP_ENUMERATION] = $accounts; |
||
140 | } |
||
141 | |||
142 | exit; |
||
143 | } |
||
144 | elseif (try_request('submitted') == 'membersform') |
||
145 | { |
||
146 | debug_write_log(DEBUG_NOTICE, 'Data are submitted (removing selected members).'); |
||
147 | |||
148 | if (isset($_REQUEST['accounts'])) |
||
149 | { |
||
150 | foreach ($_REQUEST['accounts'] as $account) |
||
151 | { |
||
152 | group_membership_remove($id, $account); |
||
153 | } |
||
154 | } |
||
155 | else |
||
156 | { |
||
157 | debug_write_log(DEBUG_NOTICE, 'No accounts are selected.'); |
||
158 | } |
||
159 | |||
160 | exit; |
||
161 | } |
||
162 | else |
||
163 | { |
||
164 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
165 | } |
||
166 | |||
167 | // generate left side |
||
168 | |||
169 | $xml = '<dual>' |
||
170 | . '<dualleft>' |
||
171 | . '<form name="othersform" action="gmembers.php?pid=' . $pid . '&id=' . $id . '" success="reloadTab">' |
||
172 | . '<group title="' . get_html_resource(RES_OTHERS_ID) . '">'; |
||
173 | |||
174 | View Code Duplication | if (LDAP_ENABLED && !LDAP_ENUMERATION) |
|
175 | { |
||
176 | $xml .= '<control name="accounts">' |
||
177 | . '<textbox rows="10" maxlen="1000">' |
||
178 | . $_SESSION[VAR_LDAP_ENUMERATION] |
||
179 | . '</textbox>' |
||
180 | . '</control>'; |
||
181 | } |
||
182 | else |
||
183 | { |
||
184 | $xml .= '<control name="accounts[]">' |
||
185 | . '<listbox size="10">'; |
||
186 | |||
187 | $list = group_not_amongs($id); |
||
188 | |||
189 | foreach ($list as $item) |
||
190 | { |
||
191 | $xml .= '<listitem value="' . $item['username'] . '">' |
||
192 | . ustr2html(sprintf('%s (%s)', $item['fullname'], account_get_username($item['username']))) |
||
193 | . '</listitem>'; |
||
194 | } |
||
195 | |||
196 | $xml .= '</listbox>' |
||
197 | . '</control>'; |
||
198 | } |
||
199 | |||
200 | $xml .= '</group>' |
||
201 | . '</form>' |
||
202 | . '</dualleft>'; |
||
203 | |||
204 | // generate right side |
||
205 | |||
206 | $xml .= '<dualright>' |
||
207 | . '<form name="membersform" action="gmembers.php?pid=' . $pid . '&id=' . $id . '" success="reloadTab">' |
||
208 | . '<group title="' . get_html_resource(RES_MEMBERS_ID) . '">' |
||
209 | . '<control name="accounts[]">' |
||
210 | . '<listbox size="10">'; |
||
211 | |||
212 | $rs = group_amongs($id); |
||
213 | |||
214 | View Code Duplication | while (($row = $rs->fetch())) |
|
215 | { |
||
216 | $xml .= '<listitem value="' . $row['account_id'] . '">' |
||
217 | . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username']))) |
||
218 | . '</listitem>'; |
||
219 | } |
||
220 | |||
221 | $xml .= '</listbox>' |
||
222 | . '</control>' |
||
223 | . '</group>' |
||
224 | . '</form>' |
||
225 | . '</dualright>'; |
||
226 | |||
227 | // generate buttons |
||
228 | |||
229 | $xml .= '<button action="$(\'#othersform\').submit()">%gt;%gt;</button>' |
||
230 | . '<button action="$(\'#membersform\').submit()">%lt;%lt;</button>' |
||
231 | . '</dual>'; |
||
232 | |||
233 | echo(xml2html($xml)); |
||
234 | |||
235 | ?> |
||
236 |
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.