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 | * Elgg Etherpad lite plugin |
||
4 | * |
||
5 | * @package etherpad |
||
6 | */ |
||
7 | |||
8 | elgg_register_event_handler('init', 'system', 'etherpad_init'); |
||
9 | |||
10 | |||
11 | function etherpad_init() { |
||
12 | |||
13 | $actions_base = elgg_get_plugins_path() . 'etherpad/actions/docs'; |
||
14 | elgg_register_action("docs/save", "$actions_base/save.php"); |
||
15 | elgg_register_action("docs/delete", "$actions_base/delete.php"); |
||
16 | |||
17 | elgg_register_page_handler('docs', 'etherpad_page_handler'); |
||
18 | |||
19 | // Language short codes must be of the form "etherpad:key" |
||
20 | // where key is the array key below |
||
21 | elgg_set_config('etherpad', array( |
||
22 | 'title' => 'text', |
||
23 | 'tags' => 'tags', |
||
24 | 'access_id' => 'access', |
||
25 | 'write_access_id' => 'write_access', |
||
26 | )); |
||
27 | |||
28 | elgg_register_plugin_hook_handler('register', 'menu:entity', 'etherpad_entity_menu'); |
||
29 | |||
30 | elgg_register_entity_type('object', 'etherpad', 'ElggPad'); |
||
0 ignored issues
–
show
|
|||
31 | elgg_register_entity_type('object', 'subpad', 'ElggPad'); |
||
0 ignored issues
–
show
The call to
elgg_register_entity_type() has too many arguments starting with 'ElggPad' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
32 | |||
33 | // write permission plugin hooks |
||
34 | elgg_register_plugin_hook_handler('permissions_check', 'object', 'etherpad_write_permission_check'); |
||
35 | elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'etherpad_container_permission_check'); |
||
36 | |||
37 | //Widget |
||
38 | elgg_register_widget_type('etherpad', elgg_echo('etherpad'), elgg_echo('etherpad:profile:widgetdesc'), array("dashboard", "profile", "groups")); |
||
39 | |||
40 | // icon url override |
||
41 | elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'etherpad_icon_url_override'); |
||
42 | |||
43 | if(elgg_get_plugin_setting('integrate_in_pages', 'etherpad') != 'yes') { |
||
44 | $item = new ElggMenuItem('etherpad', elgg_echo('etherpad'), 'docs/all'); |
||
45 | elgg_register_menu_item('site', $item); |
||
46 | |||
47 | elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'etherpad_owner_block_menu'); |
||
48 | |||
49 | // add to groups |
||
50 | add_group_tool_option('etherpad', elgg_echo('groups:enablepads'), true); |
||
51 | elgg_extend_view('groups/tool_latest', 'etherpad/group_module'); |
||
52 | |||
53 | // Register a URL handler for bookmarks |
||
54 | elgg_register_entity_url_handler('object', 'etherpad', 'etherpad_url'); |
||
55 | elgg_register_entity_url_handler('object', 'subpad', 'etherpad_url'); |
||
56 | } else { |
||
57 | // override pages library |
||
58 | elgg_register_library('elgg:pages', elgg_get_plugins_path() . 'etherpad/lib/pages.php'); |
||
59 | |||
60 | elgg_register_page_handler('pages', 'etherpad_page_handler'); |
||
61 | |||
62 | // Register a URL handler for bookmarks |
||
63 | elgg_register_entity_url_handler('object', 'etherpad', 'pages_url'); |
||
64 | elgg_register_entity_url_handler('object', 'subpad', 'pages_url'); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | |||
69 | function etherpad_page_handler($page, $handler) { |
||
70 | |||
71 | elgg_load_library('elgg:pages'); |
||
72 | |||
73 | if($handler == 'pages'){ |
||
74 | // add the jquery treeview files for navigation |
||
75 | elgg_load_js('jquery-treeview'); |
||
76 | elgg_load_css('jquery-treeview'); |
||
77 | } |
||
78 | |||
79 | if (!isset($page[0])) { |
||
80 | $page[0] = 'all'; |
||
81 | } |
||
82 | |||
83 | elgg_push_breadcrumb(elgg_echo("etherpad:$handler"), "$handler/all"); |
||
84 | |||
85 | $base_dir = elgg_get_plugins_path() . "etherpad/pages/$handler"; |
||
86 | |||
87 | $page_type = $page[0]; |
||
88 | View Code Duplication | switch ($page_type) { |
|
89 | case 'owner': |
||
90 | include "$base_dir/owner.php"; |
||
91 | break; |
||
92 | case 'friends': |
||
93 | include "$base_dir/friends.php"; |
||
94 | break; |
||
95 | case 'view': |
||
96 | set_input('guid', $page[1]); |
||
97 | include "$base_dir/view.php"; |
||
98 | break; |
||
99 | case 'add': |
||
100 | set_input('guid', $page[1]); |
||
101 | include "$base_dir/new.php"; |
||
102 | break; |
||
103 | case 'edit': |
||
104 | set_input('guid', $page[1]); |
||
105 | include "$base_dir/edit.php"; |
||
106 | break; |
||
107 | case 'group': |
||
108 | include "$base_dir/owner.php"; |
||
109 | break; |
||
110 | case 'history': |
||
111 | set_input('guid', $page[1]); |
||
112 | include "$base_dir/history.php"; |
||
113 | break; |
||
114 | case 'revision': |
||
115 | set_input('id', $page[1]); |
||
116 | include "$base_dir/revision.php"; |
||
117 | break; |
||
118 | case 'all': |
||
119 | include "$base_dir/world.php"; |
||
120 | break; |
||
121 | default: |
||
122 | return false; |
||
123 | } |
||
124 | return true; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Add timeslider to entity menu |
||
129 | */ |
||
130 | function etherpad_entity_menu($hook, $type, $return, $params) { |
||
131 | |||
132 | $entity = $params['entity']; |
||
133 | |||
134 | if (elgg_in_context('widgets')) { |
||
135 | return $return; |
||
136 | } |
||
137 | |||
138 | if(!in_array($entity->getSubtype(), array('etherpad', 'subpad'))){ |
||
139 | return $return; |
||
140 | } |
||
141 | |||
142 | // timeslider button, show only if pages integration is enabled. |
||
143 | $handler = elgg_get_plugin_setting('integrate_in_pages', 'etherpad') == 'yes' ? 'pages' : 'docs'; |
||
144 | if($handler == 'pages') { |
||
145 | $options = array( |
||
146 | 'name' => 'etherpad-timeslider', |
||
147 | 'text' => elgg_echo('etherpad:timeslider'), |
||
148 | 'href' => elgg_get_site_url() . "$handler/history/" . $entity->guid, |
||
149 | 'priority' => 200, |
||
150 | ); |
||
151 | } else if(elgg_get_plugin_setting('show_fullscreen', 'etherpad') == 'yes'){ |
||
152 | // fullscreen button |
||
153 | $entity = new ElggPad($entity->guid); |
||
154 | $options = array( |
||
155 | 'name' => 'etherpadfs', |
||
156 | 'text' => elgg_echo('etherpad:fullscreen'), |
||
157 | 'href' => $entity->getPadPath(), |
||
158 | 'target' => '_blank', |
||
159 | 'priority' => 200, |
||
160 | ); |
||
161 | } |
||
162 | $return[] = ElggMenuItem::factory($options); |
||
0 ignored issues
–
show
The variable
$options 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
![]() |
|||
163 | |||
164 | return $return; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Returns a more meaningful message |
||
169 | * |
||
170 | * @param unknown_type $hook |
||
171 | * @param unknown_type $entity_type |
||
172 | * @param unknown_type $returnvalue |
||
173 | * @param unknown_type $params |
||
174 | */ |
||
175 | View Code Duplication | function etherpad_notify_message($hook, $entity_type, $returnvalue, $params) { |
|
176 | $entity = $params['entity']; |
||
177 | $to_entity = $params['to_entity']; |
||
178 | $method = $params['method']; |
||
179 | if (($entity instanceof ElggEntity) && (($entity->getSubtype() == 'etherpad'))) { |
||
180 | $descr = $entity->description; |
||
181 | $title = $entity->title; |
||
182 | //@todo why? |
||
183 | $url = elgg_get_site_url() . "view/" . $entity->guid; |
||
184 | $owner = $entity->getOwnerEntity(); |
||
185 | return $owner->name . ' ' . elgg_echo("pages:via") . ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL(); |
||
186 | } |
||
187 | return null; |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * Override the etherpad url |
||
192 | * |
||
193 | * @param ElggObject $entity Pad object |
||
194 | * @return string |
||
195 | */ |
||
196 | function etherpad_url($entity) { |
||
197 | $title = elgg_get_friendly_title($entity->title); |
||
198 | return "docs/view/$entity->guid/$title"; |
||
199 | } |
||
200 | |||
201 | /** |
||
202 | * Override the default entity icon for docs |
||
203 | * |
||
204 | * @return string Relative URL |
||
205 | */ |
||
206 | View Code Duplication | function etherpad_icon_url_override($hook, $type, $returnvalue, $params) { |
|
207 | $entity = $params['entity']; |
||
208 | if (elgg_instanceof($entity, 'object', 'etherpad') || |
||
209 | elgg_instanceof($entity, 'object', 'subpad')) { |
||
210 | switch ($params['size']) { |
||
211 | case 'small': |
||
212 | return 'mod/etherpad/images/etherpad.png'; |
||
213 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. ![]() |
|||
214 | case 'medium': |
||
215 | return 'mod/etherpad/images/etherpad_lrg.png'; |
||
216 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. ![]() |
|||
217 | } |
||
218 | } |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * Add a menu item to the user ownerblock |
||
223 | */ |
||
224 | View Code Duplication | function etherpad_owner_block_menu($hook, $type, $return, $params) { |
|
225 | if (elgg_instanceof($params['entity'], 'user')) { |
||
226 | $url = "docs/owner/{$params['entity']->username}"; |
||
227 | $item = new ElggMenuItem('etherpad', elgg_echo('etherpad'), $url); |
||
228 | $return[] = $item; |
||
229 | } else { |
||
230 | if ($params['entity']->pages_enable != "no") { |
||
231 | $url = "docs/group/{$params['entity']->guid}/all"; |
||
232 | $item = new ElggMenuItem('etherpad', elgg_echo('etherpad:group'), $url); |
||
233 | $return[] = $item; |
||
234 | } |
||
235 | } |
||
236 | |||
237 | return $return; |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * Extend permissions checking to extend can-edit for write users. |
||
242 | * |
||
243 | * @param unknown_type $hook |
||
244 | * @param unknown_type $entity_type |
||
245 | * @param unknown_type $returnvalue |
||
246 | * @param unknown_type $params |
||
247 | */ |
||
248 | function etherpad_write_permission_check($hook, $entity_type, $returnvalue, $params) |
||
249 | { |
||
250 | if ($params['entity']->getSubtype() == 'etherpad' || $params['entity']->getSubtype() == 'subpad') { |
||
251 | |||
252 | $write_permission = $params['entity']->write_access_id; |
||
253 | $user = $params['user']; |
||
254 | |||
255 | if( ($write_permission) && ($user) ){ |
||
256 | // $list = get_write_access_array($user->guid); |
||
257 | $list = get_access_array($user->guid); // get_access_list($user->guid); |
||
258 | |||
259 | if( ($write_permission!=0) && (in_array($write_permission,$list)) ){ |
||
260 | if( $params['entity'] instanceof ElggPad ) { |
||
261 | return true; |
||
262 | } |
||
263 | } |
||
264 | } |
||
265 | } |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * Extend container permissions checking to extend can_write_to_container for write users. |
||
270 | * |
||
271 | * @param unknown_type $hook |
||
272 | * @param unknown_type $entity_type |
||
273 | * @param unknown_type $returnvalue |
||
274 | * @param unknown_type $params |
||
275 | */ |
||
276 | View Code Duplication | function etherpad_container_permission_check($hook, $entity_type, $returnvalue, $params) { |
|
277 | |||
278 | if (elgg_get_context() == "etherpad") { |
||
279 | if( elgg_get_page_owner_guid() ){ |
||
280 | if( can_write_to_container(elgg_get_logged_in_user_guid(), elgg_get_page_owner_guid()) ) return true; |
||
281 | } |
||
282 | if( $page_guid = get_input('page_guid',0) ){ |
||
283 | $entity = get_entity($page_guid); |
||
284 | } else if ($parent_guid = get_input('parent_guid',0)) { |
||
285 | $entity = get_entity($parent_guid); |
||
286 | } |
||
287 | if ($entity instanceof ElggObject) { |
||
288 | if( can_write_to_container(elgg_get_logged_in_user_guid(), $entity->container_guid) || in_array($entity->write_access_id, get_access_list()) ){ |
||
0 ignored issues
–
show
The property
write_access_id does not seem to exist. Did you mean access_id ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() The variable
$entity 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
![]() |
|||
289 | return true; |
||
290 | } |
||
291 | } |
||
292 | } |
||
293 | |||
294 | } |
||
295 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.