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 | /** Adminer customization allowing usage of plugins |
||
4 | * @link https://www.adminer.org/plugins/#use |
||
5 | * @author Jakub Vrana, http://www.vrana.cz/ |
||
6 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 |
||
7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) |
||
8 | */ |
||
9 | class AdminerPlugin extends Adminer { |
||
10 | /** @access protected */ |
||
11 | var $plugins; |
||
12 | |||
13 | function _findRootClass($class) { // is_subclass_of(string, string) is available since PHP 5.0.3 |
||
0 ignored issues
–
show
|
|||
14 | do { |
||
15 | $return = $class; |
||
16 | } while ($class = get_parent_class($class)); |
||
17 | return $return; |
||
18 | } |
||
19 | |||
20 | /** Register plugins |
||
21 | * @param array object instances or null to register all classes starting by 'Adminer' |
||
22 | */ |
||
23 | function __construct($plugins) { |
||
0 ignored issues
–
show
|
|||
24 | if ($plugins === null) { |
||
25 | $plugins = array(); |
||
26 | foreach (get_declared_classes() as $class) { |
||
27 | if (preg_match('~^Adminer.~i', $class) && strcasecmp($this->_findRootClass($class), 'Adminer')) { //! can use interface |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
28 | $plugins[$class] = new $class; |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 | $this->plugins = $plugins; |
||
33 | //! it is possible to use ReflectionObject to find out which plugins defines which methods at once |
||
34 | } |
||
35 | |||
36 | function _callParent($function, $args) { |
||
0 ignored issues
–
show
|
|||
37 | return call_user_func_array(array('parent', $function), $args); |
||
38 | } |
||
39 | |||
40 | function _applyPlugin($function, $args) { |
||
0 ignored issues
–
show
|
|||
41 | foreach ($this->plugins as $plugin) { |
||
42 | if (method_exists($plugin, $function)) { |
||
43 | switch (count($args)) { // call_user_func_array() doesn't work well with references |
||
44 | case 0: $return = $plugin->$function(); break; |
||
45 | case 1: $return = $plugin->$function($args[0]); break; |
||
46 | case 2: $return = $plugin->$function($args[0], $args[1]); break; |
||
47 | View Code Duplication | case 3: $return = $plugin->$function($args[0], $args[1], $args[2]); break; |
|
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. ![]() |
|||
48 | View Code Duplication | case 4: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3]); break; |
|
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. ![]() |
|||
49 | View Code Duplication | case 5: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]); break; |
|
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. ![]() |
|||
50 | case 6: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); break; |
||
51 | default: trigger_error('Too many parameters.', E_USER_WARNING); |
||
52 | } |
||
53 | if ($return !== null) { |
||
54 | return $return; |
||
0 ignored issues
–
show
The variable
$return does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
55 | } |
||
56 | } |
||
57 | } |
||
58 | return $this->_callParent($function, $args); |
||
59 | } |
||
60 | |||
61 | function _appendPlugin($function, $args) { |
||
0 ignored issues
–
show
|
|||
62 | $return = $this->_callParent($function, $args); |
||
63 | foreach ($this->plugins as $plugin) { |
||
64 | if (method_exists($plugin, $function)) { |
||
65 | $return += call_user_func_array(array($plugin, $function), $args); |
||
66 | } |
||
67 | } |
||
68 | return $return; |
||
69 | } |
||
70 | |||
71 | // appendPlugin |
||
72 | |||
73 | function dumpFormat() { |
||
0 ignored issues
–
show
|
|||
74 | $args = func_get_args(); |
||
75 | return $this->_appendPlugin(__FUNCTION__, $args); |
||
76 | } |
||
77 | |||
78 | function dumpOutput() { |
||
0 ignored issues
–
show
|
|||
79 | $args = func_get_args(); |
||
80 | return $this->_appendPlugin(__FUNCTION__, $args); |
||
81 | } |
||
82 | |||
83 | function editFunctions($field) { |
||
0 ignored issues
–
show
|
|||
84 | $args = func_get_args(); |
||
85 | return $this->_appendPlugin(__FUNCTION__, $args); |
||
86 | } |
||
87 | |||
88 | // applyPlugin |
||
89 | |||
90 | function name() { |
||
0 ignored issues
–
show
|
|||
91 | $args = func_get_args(); |
||
92 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
93 | } |
||
94 | |||
95 | function credentials() { |
||
0 ignored issues
–
show
|
|||
96 | $args = func_get_args(); |
||
97 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
98 | } |
||
99 | |||
100 | function permanentLogin($create = false) { |
||
0 ignored issues
–
show
|
|||
101 | $args = func_get_args(); |
||
102 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
103 | } |
||
104 | |||
105 | function database() { |
||
0 ignored issues
–
show
|
|||
106 | $args = func_get_args(); |
||
107 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
108 | } |
||
109 | |||
110 | function schemas() { |
||
0 ignored issues
–
show
|
|||
111 | $args = func_get_args(); |
||
112 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
113 | } |
||
114 | |||
115 | function databases($flush = true) { |
||
0 ignored issues
–
show
|
|||
116 | $args = func_get_args(); |
||
117 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
118 | } |
||
119 | |||
120 | function queryTimeout() { |
||
0 ignored issues
–
show
|
|||
121 | $args = func_get_args(); |
||
122 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
123 | } |
||
124 | |||
125 | function headers() { |
||
0 ignored issues
–
show
|
|||
126 | $args = func_get_args(); |
||
127 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
128 | } |
||
129 | |||
130 | function head() { |
||
0 ignored issues
–
show
|
|||
131 | $args = func_get_args(); |
||
132 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
133 | } |
||
134 | |||
135 | function loginForm() { |
||
0 ignored issues
–
show
|
|||
136 | $args = func_get_args(); |
||
137 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
138 | } |
||
139 | |||
140 | function login($login, $password) { |
||
0 ignored issues
–
show
|
|||
141 | $args = func_get_args(); |
||
142 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
143 | } |
||
144 | |||
145 | function tableName($tableStatus) { |
||
0 ignored issues
–
show
|
|||
146 | $args = func_get_args(); |
||
147 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
148 | } |
||
149 | |||
150 | function fieldName($field, $order = 0) { |
||
0 ignored issues
–
show
|
|||
151 | $args = func_get_args(); |
||
152 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
153 | } |
||
154 | |||
155 | function selectLinks($tableStatus, $set = '') { |
||
0 ignored issues
–
show
|
|||
156 | $args = func_get_args(); |
||
157 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
158 | } |
||
159 | |||
160 | function foreignKeys($table) { |
||
0 ignored issues
–
show
|
|||
161 | $args = func_get_args(); |
||
162 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
163 | } |
||
164 | |||
165 | function backwardKeys($table, $tableName) { |
||
0 ignored issues
–
show
|
|||
166 | $args = func_get_args(); |
||
167 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
168 | } |
||
169 | |||
170 | function backwardKeysPrint($backwardKeys, $row) { |
||
0 ignored issues
–
show
|
|||
171 | $args = func_get_args(); |
||
172 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
173 | } |
||
174 | |||
175 | function selectQuery($query, $time) { |
||
0 ignored issues
–
show
|
|||
176 | $args = func_get_args(); |
||
177 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
178 | } |
||
179 | |||
180 | function rowDescription($table) { |
||
0 ignored issues
–
show
|
|||
181 | $args = func_get_args(); |
||
182 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
183 | } |
||
184 | |||
185 | function rowDescriptions($rows, $foreignKeys) { |
||
0 ignored issues
–
show
|
|||
186 | $args = func_get_args(); |
||
187 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
188 | } |
||
189 | |||
190 | function selectLink($val, $field) { |
||
0 ignored issues
–
show
|
|||
191 | $args = func_get_args(); |
||
192 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
193 | } |
||
194 | |||
195 | function selectVal($val, $link, $field, $original) { |
||
0 ignored issues
–
show
|
|||
196 | $args = func_get_args(); |
||
197 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
198 | } |
||
199 | |||
200 | function editVal($val, $field) { |
||
0 ignored issues
–
show
|
|||
201 | $args = func_get_args(); |
||
202 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
203 | } |
||
204 | |||
205 | function selectColumnsPrint($select, $columns) { |
||
0 ignored issues
–
show
|
|||
206 | $args = func_get_args(); |
||
207 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
208 | } |
||
209 | |||
210 | function selectSearchPrint($where, $columns, $indexes) { |
||
0 ignored issues
–
show
|
|||
211 | $args = func_get_args(); |
||
212 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
213 | } |
||
214 | |||
215 | function selectOrderPrint($order, $columns, $indexes) { |
||
0 ignored issues
–
show
|
|||
216 | $args = func_get_args(); |
||
217 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
218 | } |
||
219 | |||
220 | function selectLimitPrint($limit) { |
||
0 ignored issues
–
show
|
|||
221 | $args = func_get_args(); |
||
222 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
223 | } |
||
224 | |||
225 | function selectLengthPrint($text_length) { |
||
0 ignored issues
–
show
|
|||
226 | $args = func_get_args(); |
||
227 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
228 | } |
||
229 | |||
230 | function selectActionPrint($indexes) { |
||
0 ignored issues
–
show
|
|||
231 | $args = func_get_args(); |
||
232 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
233 | } |
||
234 | |||
235 | function selectCommandPrint() { |
||
0 ignored issues
–
show
|
|||
236 | $args = func_get_args(); |
||
237 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
238 | } |
||
239 | |||
240 | function selectImportPrint() { |
||
0 ignored issues
–
show
|
|||
241 | $args = func_get_args(); |
||
242 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
243 | } |
||
244 | |||
245 | function selectEmailPrint($emailFields, $columns) { |
||
0 ignored issues
–
show
|
|||
246 | $args = func_get_args(); |
||
247 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
248 | } |
||
249 | |||
250 | function selectColumnsProcess($columns, $indexes) { |
||
0 ignored issues
–
show
|
|||
251 | $args = func_get_args(); |
||
252 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
253 | } |
||
254 | |||
255 | function selectSearchProcess($fields, $indexes) { |
||
0 ignored issues
–
show
|
|||
256 | $args = func_get_args(); |
||
257 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
258 | } |
||
259 | |||
260 | function selectOrderProcess($fields, $indexes) { |
||
0 ignored issues
–
show
|
|||
261 | $args = func_get_args(); |
||
262 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
263 | } |
||
264 | |||
265 | function selectLimitProcess() { |
||
0 ignored issues
–
show
|
|||
266 | $args = func_get_args(); |
||
267 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
268 | } |
||
269 | |||
270 | function selectLengthProcess() { |
||
0 ignored issues
–
show
|
|||
271 | $args = func_get_args(); |
||
272 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
273 | } |
||
274 | |||
275 | function selectEmailProcess($where, $foreignKeys) { |
||
0 ignored issues
–
show
|
|||
276 | $args = func_get_args(); |
||
277 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
278 | } |
||
279 | |||
280 | function selectQueryBuild($select, $where, $group, $order, $limit, $page) { |
||
0 ignored issues
–
show
|
|||
281 | $args = func_get_args(); |
||
282 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
283 | } |
||
284 | |||
285 | function messageQuery($query, $time) { |
||
0 ignored issues
–
show
|
|||
286 | $args = func_get_args(); |
||
287 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
288 | } |
||
289 | |||
290 | function editInput($table, $field, $attrs, $value) { |
||
0 ignored issues
–
show
|
|||
291 | $args = func_get_args(); |
||
292 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
293 | } |
||
294 | |||
295 | function processInput($field, $value, $function = '') { |
||
0 ignored issues
–
show
|
|||
296 | $args = func_get_args(); |
||
297 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
298 | } |
||
299 | |||
300 | function dumpDatabase($db) { |
||
0 ignored issues
–
show
|
|||
301 | $args = func_get_args(); |
||
302 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
303 | } |
||
304 | |||
305 | function dumpTable($table, $style, $is_view = 0) { |
||
0 ignored issues
–
show
|
|||
306 | $args = func_get_args(); |
||
307 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
308 | } |
||
309 | |||
310 | function dumpData($table, $style, $query) { |
||
0 ignored issues
–
show
|
|||
311 | $args = func_get_args(); |
||
312 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
313 | } |
||
314 | |||
315 | function dumpFilename($identifier) { |
||
0 ignored issues
–
show
|
|||
316 | $args = func_get_args(); |
||
317 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
318 | } |
||
319 | |||
320 | function dumpHeaders($identifier, $multi_table = false) { |
||
0 ignored issues
–
show
|
|||
321 | $args = func_get_args(); |
||
322 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
323 | } |
||
324 | |||
325 | function homepage() { |
||
0 ignored issues
–
show
|
|||
326 | $args = func_get_args(); |
||
327 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
328 | } |
||
329 | |||
330 | function navigation($missing) { |
||
0 ignored issues
–
show
|
|||
331 | $args = func_get_args(); |
||
332 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
333 | } |
||
334 | |||
335 | function databasesPrint($missing) { |
||
0 ignored issues
–
show
|
|||
336 | $args = func_get_args(); |
||
337 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
338 | } |
||
339 | |||
340 | function tablesPrint($tables) { |
||
0 ignored issues
–
show
|
|||
341 | $args = func_get_args(); |
||
342 | return $this->_applyPlugin(__FUNCTION__, $args); |
||
343 | } |
||
344 | |||
345 | } |
||
346 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.