예제 #1
0
/**
 * Call the given function in all available plugins
 * @param $function The function name to execute
 * @param $paramArr The array of parameters for the function
 * @param $reverse  If true, the plugins are considered in reverse priority
 *
 * This function will try to call all _$plugins_$functionName function
 * The plugins are looked up according to their priority, and in reverse order if $reverse = True
 */
function callPluginFunction($function, $paramArr = null, $reverse = False)
{
    /* Fetch and order available plugins for the current logged user */
    $list = $_SESSION["modulesList"];
    if ($reverse) {
        $list = array_reverse($list);
    }
    /*
      If the user try to change his/her password, we do it for each available
      module, and we bypass all ACL check
    */
    if ($function == "changeUserPasswd" || $function == "baseEdit") {
        /* Change password for all modules, even those where the user has no right. */
        $list = $_SESSION["supportModList"];
        global $conf;
        foreach ($list as $module) {
            if (!function_exists("_" . $module . "_" . "changeUserPasswd")) {
                includePublicFunc(array($conf["global"]["rootfsmodules"] . "/{$module}"));
            }
        }
    }
    $result = array();
    foreach ($list as $item) {
        $functionName = "_" . $item . "_" . $function;
        if (function_exists($functionName)) {
            $result[$item] = call_user_func_array($functionName, $paramArr);
            if (isXMLRPCError()) {
                /* Break the loop if there is an error */
                global $errorDesc;
                $result[$item] = $errorDesc;
                break;
            }
        }
    }
    return $result;
}
예제 #2
0
파일: main.php 프로젝트: neoclust/mmc
/**
Lookup and load all MMC modules
*/
function autoInclude()
{
    global $redirArray;
    global $redirAjaxArray;
    global $conf;
    global $filter;
    $modules = fetchModulesList($conf["global"]["rootfsmodules"]);
    includeInfoPackage($modules);
    includePublicFunc($modules);
    if (isset($_GET["module"])) {
        $__module = $_GET["module"];
    } else {
        $__module = "default";
    }
    if (isset($_GET["submod"])) {
        $__submod = $_GET["submod"];
    } else {
        $__submod = "default";
    }
    if (isset($_GET["action"])) {
        $__action = $_GET["action"];
    } else {
        $__action = "default";
    }
    /* Check filter info */
    // we must be in a ajax call
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" and isset($_GET['filter'])) {
        // get the page who called us
        preg_match('/module=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches);
        if (isset($matches[1])) {
            $module = $matches[1];
        } else {
            $module = "default";
        }
        preg_match('/submod=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches);
        if (isset($matches[1])) {
            $submod = $matches[1];
        } else {
            $submod = "default";
        }
        preg_match('/action=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches);
        if (isset($matches[1])) {
            $action = $matches[1];
        } else {
            $action = "default";
        }
        preg_match('/tab=([^&]+)/', $_SERVER["HTTP_REFERER"], $matches);
        if (isset($matches[1])) {
            $tab = $matches[1];
        } else {
            $tab = "default";
        }
        // extra arguments of the request so we don't cache filters for another
        // page
        $extra = "";
        foreach ($_GET as $key => $value) {
            if (!in_array($key, array('module', 'submod', 'tab', 'action', 'filter', 'start', 'end', 'maxperpage'))) {
                $extra .= $key . "_" . $value;
            }
        }
        // store the filter
        if (isset($_GET['filter'])) {
            $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_filter_" . $extra] = $_GET['filter'];
        }
        // store pagination info
        if (isset($_GET['maxperpage'])) {
            $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_max_" . $extra] = $_GET['maxperpage'];
        }
        if (isset($_GET['start'])) {
            $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_start_" . $extra] = $_GET['start'];
        }
        if (isset($_GET['end'])) {
            $_SESSION[$module . "_" . $submod . "_" . $action . "_" . $tab . "_end_" . $extra] = $_GET['end'];
        }
        unset($module);
        unset($submod);
        unset($action);
        unset($tab);
    }
    /* Redirect user to a default page. */
    if (!isset($redirArray[$__module][$__submod][$__action]) && !isset($redirAjaxArray[$__module][$__submod][$__action])) {
        header("Location: " . getDefaultPage());
        exit;
    }
    if (!isNoHeader($__module, $__submod, $__action)) {
        require_once "graph/header.inc.php";
        /* Include specific module CSS if there is one */
        require "graph/dynamicCss.php";
    }
    /* ACL check */
    if (!hasCorrectAcl($__module, $__submod, $__action)) {
        header("Location: " . getDefaultPage());
        exit;
    }
    /* Warn user once at login if her account is expired. */
    if (in_array("ppolicy", $_SESSION["supportModList"])) {
        require_once "modules/ppolicy/default/warnuser.php";
    }
    if (!empty($redirArray[$__module][$__submod][$__action])) {
        require $redirArray[$__module][$__submod][$__action];
    } else {
        if (!empty($redirAjaxArray[$__module][$__submod][$__action])) {
            require $redirAjaxArray[$__module][$__submod][$__action];
        }
    }
    require_once "includes/check_notify.inc.php";
    if (!isNoHeader($__module, $__submod, $__action)) {
        require_once "graph/footer.inc.php";
    }
}