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/groups.php'); |
||
33 | require_once('../dbo/projects.php'); |
||
34 | require_once('../dbo/states.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 state exists |
||
46 | |||
47 | $id = ustr2int(try_request('id')); |
||
48 | $state = state_find($id); |
||
49 | |||
50 | if (!$state) |
||
0 ignored issues
–
show
|
|||
51 | { |
||
52 | debug_write_log(DEBUG_NOTICE, 'State cannot be found.'); |
||
53 | exit; |
||
54 | } |
||
55 | |||
56 | if ($state['state_type'] == STATE_TYPE_FINAL) |
||
57 | { |
||
58 | debug_write_log(DEBUG_NOTICE, 'State must be intermediate.'); |
||
59 | exit; |
||
60 | } |
||
61 | |||
62 | // get lists of groups and states |
||
63 | |||
64 | $groups = dal_query('groups/list.sql', $state['project_id'], 'is_global, group_name'); |
||
65 | $states = dal_query('states/list.sql', $state['template_id'], 'state_type, state_name'); |
||
66 | |||
67 | // save changed transitions |
||
68 | |||
69 | if (try_request('submitted') == 'transform') |
||
70 | { |
||
71 | debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
||
72 | |||
73 | $gid = ustr2int(try_request('group', STATE_ROLE_AUTHOR), MIN_STATE_ROLE); |
||
74 | |||
75 | dal_query(($gid < 0 ? 'states/rtdelete.sql' : 'states/gtdelete.sql'), $id, $gid); |
||
76 | |||
77 | while (($row = $states->fetch())) |
||
78 | { |
||
79 | if (isset($_REQUEST['state' . $row['state_id']])) |
||
80 | { |
||
81 | dal_query(($gid < 0 ? 'states/rtadd.sql' : 'states/gtadd.sql'), $id, $row['state_id'], $gid); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | exit; |
||
86 | } |
||
87 | else |
||
88 | { |
||
89 | debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
||
90 | } |
||
91 | |||
92 | // JS array with permissions |
||
93 | |||
94 | $xml = '<script>' |
||
95 | . 'var transitions = new Array();'; |
||
96 | |||
97 | $roles = array(STATE_ROLE_AUTHOR, |
||
98 | STATE_ROLE_RESPONSIBLE, |
||
99 | STATE_ROLE_REGISTERED); |
||
100 | |||
101 | foreach ($roles as $role) |
||
102 | { |
||
103 | $xml .= sprintf('transitions["g%d"] = new Array();', $role); |
||
104 | |||
105 | $list = dal_query('states/rtlist.sql', $state['template_id'], $id, $role); |
||
106 | |||
107 | View Code Duplication | while (($row = $list->fetch())) |
|
108 | { |
||
109 | $xml .= sprintf('transitions["g%d"]["state%d"] = %s;', |
||
110 | $role, |
||
111 | $row['state_id'], |
||
112 | ($row['is_set'] == 0 ? 'false' : 'true')); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | while (($group = $groups->fetch())) |
||
117 | { |
||
118 | $xml .= sprintf('transitions["g%d"] = new Array();', $group['group_id']); |
||
119 | |||
120 | $list = dal_query('states/gtlist.sql', $state['template_id'], $id, $group['group_id']); |
||
121 | |||
122 | View Code Duplication | while (($row = $list->fetch())) |
|
123 | { |
||
124 | $xml .= sprintf('transitions["g%d"]["state%d"] = %s;', |
||
125 | $group['group_id'], |
||
126 | $row['state_id'], |
||
127 | ($row['is_set'] == 0 ? 'false' : 'true')); |
||
128 | } |
||
129 | } |
||
130 | |||
131 | // local JS functions |
||
132 | |||
133 | $resTitle = get_js_resource(RES_TRANSITIONS_ID); |
||
134 | $resMessage = get_js_resource(RES_ALERT_SUCCESSFULLY_SAVED_ID); |
||
135 | $resOK = get_js_resource(RES_OK_ID); |
||
136 | |||
137 | $xml .= <<<JQUERY |
||
138 | |||
139 | function transitionsSuccess () |
||
140 | { |
||
141 | var id = $("#group").val(); |
||
142 | |||
143 | $("#transform input:checkbox").each(function () { |
||
144 | var name = $(this).prop("name"); |
||
145 | transitions["g"+id][name] = $(this).prop("checked"); |
||
146 | }); |
||
147 | |||
148 | jqAlert("{$resTitle}", "{$resMessage}", "{$resOK}"); |
||
149 | } |
||
150 | |||
151 | function updateTrans () |
||
152 | { |
||
153 | var id = $("#group").val(); |
||
154 | |||
155 | $("#transform input:checkbox").each(function () { |
||
156 | var name = $(this).prop("name"); |
||
157 | $(this).prop("checked", transitions["g"+id][name]); |
||
158 | }); |
||
159 | } |
||
160 | |||
161 | </script> |
||
162 | JQUERY; |
||
163 | |||
164 | // generate left side |
||
165 | |||
166 | $xml .= '<form name="transform" action="strans.php?id=' . $id . '" success="transitionsSuccess">' |
||
167 | . '<dual>' |
||
168 | . '<dualleft>' |
||
169 | . '<group title="' . get_html_resource(RES_GROUPS_ID) . '">' |
||
170 | . '<control name="group">' |
||
171 | . '<listbox size="10" action="updateTrans()">' |
||
172 | . '<listitem value="' . STATE_ROLE_AUTHOR . '">' . sprintf('%s (%s)', get_html_resource(RES_AUTHOR_ID), get_html_resource(RES_ROLE_ID)) . '</listitem>' |
||
173 | . '<listitem value="' . STATE_ROLE_RESPONSIBLE . '">' . sprintf('%s (%s)', get_html_resource(RES_RESPONSIBLE_ID), get_html_resource(RES_ROLE_ID)) . '</listitem>' |
||
174 | . '<listitem value="' . STATE_ROLE_REGISTERED . '">' . sprintf('%s (%s)', get_html_resource(RES_REGISTERED_ID), get_html_resource(RES_ROLE_ID)) . '</listitem>'; |
||
175 | |||
176 | $groups->seek(); |
||
177 | |||
178 | View Code Duplication | while (($row = $groups->fetch())) |
|
179 | { |
||
180 | $xml .= '<listitem value="' . $row['group_id'] . '">' |
||
181 | . ustr2html(sprintf('%s (%s)', $row['group_name'], get_html_resource($row['is_global'] ? RES_GLOBAL_ID : RES_LOCAL_ID))) |
||
182 | . '</listitem>'; |
||
183 | } |
||
184 | |||
185 | $xml .= '</listbox>' |
||
186 | . '</control>' |
||
187 | . '</group>' |
||
188 | . '</dualleft>'; |
||
189 | |||
190 | // generate right side |
||
191 | |||
192 | $xml .= '<dualright>' |
||
193 | . '<group title="' . get_html_resource(RES_STATES_ID) . '">'; |
||
194 | |||
195 | $states->seek(); |
||
196 | |||
197 | while (($row = $states->fetch())) |
||
198 | { |
||
199 | $xml .= '<control name="state' . $row['state_id'] . '">' |
||
200 | . '<checkbox>' . ustr2html($row['state_name']) . '</checkbox>' |
||
201 | . '</control>'; |
||
202 | } |
||
203 | |||
204 | $xml .= '</group>' |
||
205 | . '<button default="true">' . get_html_resource(RES_SAVE_ID) . '</button>' |
||
206 | . '</dualright>' |
||
207 | . '</dual>' |
||
208 | . '</form>'; |
||
209 | |||
210 | $xml .= '<onready>' |
||
211 | . '$("#group :first-child").prop("selected", true);' |
||
212 | . 'updateTrans();' |
||
213 | . '</onready>'; |
||
214 | |||
215 | echo(xml2html($xml)); |
||
216 | |||
217 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
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.
Loading history...
|
|||
218 |
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.