From 20e0107a472249920455a517b6099c75a9d06cae Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Mon, 14 Dec 2015 10:31:15 -0500
Subject: [PATCH] - added callPluginEvent handling for module plugins - added module_name parameter on registerEvent
---
interface/lib/classes/plugin.inc.php | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/interface/lib/classes/plugin.inc.php b/interface/lib/classes/plugin.inc.php
index 6a6ff70..058a1ba 100644
--- a/interface/lib/classes/plugin.inc.php
+++ b/interface/lib/classes/plugin.inc.php
@@ -50,7 +50,7 @@
if(is_dir(ISPC_WEB_PATH)) {
if($dh = opendir(ISPC_WEB_PATH)) {
while(($file = readdir($dh)) !== false) {
- if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d';
+ 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';
}
closedir($dh);
}
@@ -96,10 +96,10 @@
for faster lookups without the need to load all plugins for every page.
*/
- public function registerEvent($event_name, $plugin_name, $function_name) {
+ public function registerEvent($event_name, $plugin_name, $function_name, $module_name = '') {
global $app;
- $_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name);
+ $_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name, 'module' => $module_name);
if($this->debug) $app->log("Plugin '$plugin_name' has registered the function '$function_name' for the event '$event_name'", LOGLEVEL_DEBUG);
}
@@ -155,8 +155,16 @@
foreach($_SESSION['s']['plugin_cache'][$event_name] as $rec) {
$plugin_name = $rec['plugin'];
$function_name = $rec['function'];
- $plugin_file = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV.$plugin_name.'.inc.php';
-
+ $module_name = $rec['function'];
+ if($module_name != '') {
+ if(strpos($module_name, '..') !== false || strpos($module_name, '/') !== false) {
+ if($this->debug) $app->log('Module name ' . $module_name . ' contains illegal characters.', LOGLEVEL_DEBUG);
+ continue;
+ }
+ $plugin_file = ISPC_WEB_PATH . FS_DIV . $module_name . FS_DIV . 'lib' . FS_DIV . 'plugin.d' . FS_DIV . $plugin_name . '.inc.php';
+ } else {
+ $plugin_file = ISPC_LIB_PATH . FS_DIV . 'plugins' . FS_DIV . $plugin_name . '.inc.php';
+ }
if(is_file($plugin_file)) {
if(!isset($app->loaded_plugins[$plugin_name])) {
--
Gitblit v1.9.1