Skip to content

Commit 20e0107

Browse files
author
Marius Burkard
committed
- added callPluginEvent handling for module plugins
- added module_name parameter on registerEvent
1 parent 6b15d5f commit 20e0107

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

interface/lib/classes/plugin.inc.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private function loadPluginCache() {
5050
if(is_dir(ISPC_WEB_PATH)) {
5151
if($dh = opendir(ISPC_WEB_PATH)) {
5252
while(($file = readdir($dh)) !== false) {
53-
if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d';
53+
if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . FS_DIV . $file . FS_DIV . 'lib' . FS_DIV . 'plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . FS_DIV . $file . FS_DIV . 'lib' . FS_DIV . 'plugin.d';
5454
}
5555
closedir($dh);
5656
}
@@ -96,10 +96,10 @@ private function loadPluginCache() {
9696
for faster lookups without the need to load all plugins for every page.
9797
*/
9898

99-
public function registerEvent($event_name, $plugin_name, $function_name) {
99+
public function registerEvent($event_name, $plugin_name, $function_name, $module_name = '') {
100100
global $app;
101101

102-
$_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name);
102+
$_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name, 'module' => $module_name);
103103
if($this->debug) $app->log("Plugin '$plugin_name' has registered the function '$function_name' for the event '$event_name'", LOGLEVEL_DEBUG);
104104
}
105105

@@ -155,8 +155,16 @@ private function callPluginEvent($event_name, $data) {
155155
foreach($_SESSION['s']['plugin_cache'][$event_name] as $rec) {
156156
$plugin_name = $rec['plugin'];
157157
$function_name = $rec['function'];
158-
$plugin_file = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV.$plugin_name.'.inc.php';
159-
158+
$module_name = $rec['function'];
159+
if($module_name != '') {
160+
if(strpos($module_name, '..') !== false || strpos($module_name, '/') !== false) {
161+
if($this->debug) $app->log('Module name ' . $module_name . ' contains illegal characters.', LOGLEVEL_DEBUG);
162+
continue;
163+
}
164+
$plugin_file = ISPC_WEB_PATH . FS_DIV . $module_name . FS_DIV . 'lib' . FS_DIV . 'plugin.d' . FS_DIV . $plugin_name . '.inc.php';
165+
} else {
166+
$plugin_file = ISPC_LIB_PATH . FS_DIV . 'plugins' . FS_DIV . $plugin_name . '.inc.php';
167+
}
160168

161169
if(is_file($plugin_file)) {
162170
if(!isset($app->loaded_plugins[$plugin_name])) {

0 commit comments

Comments
 (0)