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 | * Plugin for creating web pages for your site |
||
4 | */ |
||
5 | |||
6 | elgg_register_event_handler('init', 'system', 'expages_init'); |
||
7 | |||
8 | function expages_init() { |
||
9 | |||
10 | // Register a page handler, so we can have nice URLs |
||
11 | elgg_register_page_handler('about-a_propos', 'expages_page_handler'); // GCChange change - Ilia: Bilingual page url |
||
12 | elgg_register_page_handler('terms', 'expages_page_handler'); // GCChange change - Ilia: Bilingual page url |
||
13 | elgg_register_page_handler('privacy-confidentialite', 'expages_page_handler'); // GCChange change - Ilia: Bilingual page url |
||
14 | elgg_register_page_handler('expages', 'expages_page_handler'); |
||
15 | |||
16 | // Register public external pages |
||
17 | elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'expages_public'); |
||
18 | |||
19 | elgg_register_plugin_hook_handler('register', 'menu:expages', 'expages_menu_register_hook'); |
||
20 | |||
21 | // add a menu item for the admin edit page |
||
22 | elgg_register_admin_menu_item('configure', 'expages', 'appearance'); |
||
23 | |||
24 | // add footer links |
||
25 | expages_setup_footer_menu(); |
||
26 | |||
27 | // register action |
||
28 | $actions_base = elgg_get_plugins_path() . 'externalpages/actions'; |
||
29 | elgg_register_action("expages/edit", "$actions_base/edit.php", 'admin'); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Extend the public pages range |
||
34 | * |
||
35 | */ |
||
36 | function expages_public($hook, $handler, $return, $params){ |
||
37 | $pages = array('about-a_propos', 'terms-termes', 'privacy-confidentialite'); // GCChange change - Ilia: Bilingual page url |
||
38 | return array_merge($pages, $return); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Setup the links to site pages |
||
43 | */ |
||
44 | function expages_setup_footer_menu() { |
||
45 | $pages = array('about-a_propos', 'terms-termes', 'privacy-confidentialite'); // GCChange change - Ilia: Bilingual page url |
||
46 | |||
47 | View Code Duplication | foreach ($pages as $page) { |
|
48 | $url = "$page"; |
||
49 | $wg_item = new ElggMenuItem($page, elgg_echo("expages:$page"), $url); |
||
50 | elgg_register_menu_item('walled_garden', $wg_item); |
||
51 | |||
52 | $footer_item = clone $wg_item; |
||
53 | elgg_register_menu_item('footer', $footer_item); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * External pages page handler |
||
59 | * |
||
60 | * @param array $page URL segements |
||
61 | * @param string $handler Handler identifier |
||
62 | * @return bool |
||
63 | */ |
||
64 | View Code Duplication | function expages_page_handler($page, $handler) { |
|
65 | if ($handler == 'expages') { |
||
66 | expages_url_forwarder($page[1]); |
||
67 | } |
||
68 | $type = strtolower($handler); |
||
69 | |||
70 | $title = elgg_echo("expages:$type"); |
||
71 | $header = elgg_view_title($title); |
||
72 | |||
73 | $object = elgg_get_entities(array( |
||
74 | 'type' => 'object', |
||
75 | 'subtype' => $type, |
||
76 | 'limit' => 1, |
||
77 | )); |
||
78 | if ($object) { |
||
79 | $content .= elgg_view('output/longtext', array('value' => $object[0]->description)); |
||
0 ignored issues
–
show
|
|||
80 | } else { |
||
81 | $content .= elgg_echo("expages:notset"); |
||
0 ignored issues
–
show
The variable
$content seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?
This error can happen if you refactor code and forget to move the variable initialization. Let’s take a look at a simple example: function someFunction() {
$x = 5;
echo $x;
}
The above code is perfectly fine. Now imagine that we re-order the statements: function someFunction() {
echo $x;
$x = 5;
}
In that case, ![]() |
|||
82 | } |
||
83 | $content = elgg_view('expages/wrapper', array('content' => $content)); |
||
84 | |||
85 | if (elgg_is_admin_logged_in()) { |
||
86 | elgg_register_menu_item('title', array( |
||
87 | 'name' => 'edit', |
||
88 | 'text' => elgg_echo('edit'), |
||
89 | 'href' => "admin/appearance/expages?type=$type", |
||
90 | 'link_class' => 'elgg-button elgg-button-action', |
||
91 | )); |
||
92 | } |
||
93 | |||
94 | if (elgg_is_logged_in() || !elgg_get_config('walled_garden')) { |
||
95 | $body = elgg_view_layout('one_column', array('title' => $title, 'content' => $content)); |
||
96 | echo elgg_view_page($title, $body); |
||
97 | } else { |
||
98 | elgg_load_css('elgg.walled_garden'); |
||
99 | $body = elgg_view_layout('walled_garden', array('content' => $header . $content)); |
||
100 | echo elgg_view_page($title, $body, 'walled_garden'); |
||
101 | } |
||
102 | return true; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Adds menu items to the expages edit form |
||
107 | * |
||
108 | * @param string $hook 'register' |
||
109 | * @param string $type 'menu:expages' |
||
110 | * @param array $return current menu items |
||
111 | * @param array $params parameters |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | function expages_menu_register_hook($hook, $type, $return, $params) { |
||
116 | $type = elgg_extract('type', $params); |
||
117 | |||
118 | $pages = array('about', 'terms', 'privacy'); |
||
119 | View Code Duplication | foreach ($pages as $page) { |
|
120 | $return[] = ElggMenuItem::factory(array( |
||
121 | 'name' => $page, |
||
122 | 'text' => elgg_echo("expages:$page"), |
||
123 | 'href' => "admin/appearance/expages?type=$page", |
||
124 | 'selected' => $page === $type, |
||
125 | )); |
||
126 | } |
||
127 | return $return; |
||
128 | } |
||
129 | |||
130 | |||
131 | /** |
||
132 | * Forward to the new style of URLs |
||
133 | * |
||
134 | * @param string $page |
||
135 | */ |
||
136 | function expages_url_forwarder($page) { |
||
137 | global $CONFIG; |
||
138 | $url = "{$CONFIG->wwwroot}{$page}"; |
||
139 | forward($url); |
||
140 | } |
||
141 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.