'init' && !pnModAvailable($modinfo['name'])) {
header('HTTP/1.0 404 Not Found');
include ('header.php');
echo 'Module ' . pnVarPrepForDisplay($module) . ' not available';
include ('footer.php');
exit;
}
if ($modinfo['type'] == 2 || $modinfo['type'] == 3)
{
// New-new style of loading modules
if (empty($type)) {
$type = 'user';
}
if (empty($func)) {
$func = 'main';
}
if (!isset($arguments)) {
$arguments = array();
}
// temporary additional security check.....
if ($type == 'admin' && $func == 'updateconfig' && !pnSecAuthAction(0, "$modinfo[name]::", '::', ACCESS_ADMIN)) {
header('HTTP/1.0 403 Access Denied');
include ('header.php');
echo _MODULENOAUTH;
include ('footer.php');
exit;
}
// we need to force the mod load if we want to call a modules interactive init
// function because the modules is not active right now
$force_modload = ($type=='init') ? true : false;
if (pnModLoad($modinfo['name'], $type, $force_modload)) {
// Run the function
$return = pnModFunc($modinfo['name'], $type, $func, $arguments);
} else {
$return = false;
}
// Sort out return of function. Can be
// true - finished
// false - display error msg
// text - return information
if ($return !== true) {
include_once('header.php');
if ($return === false) {
// Failed to load the module
header('HTTP/1.0 404 Not Found');
echo 'Failed to load module ' . pnVarPrepForDisplay($module) .' (at function: "'. pnVarPrepForDisplay($func).'")';
} elseif (is_string($return) && strlen($return) > 0) {
// Text
echo $return;
} elseif (is_array($return)) {
$pnRender =& new pnRender($modinfo['name']);
$pnRender->assign($return);
if (isset($return['template'])) {
echo $pnRender->fetch($return['template']);
} else {
$modname = strtolower($modinfo['name']);
$type = strtolower($type);
$func = strtolower($func);
echo $pnRender->fetch("{$modname}_{$type}_{$func}.htm");
}
} else {
echo 'Function ' . pnVarPrepForDisplay($func) . ' in module ' . pnVarPrepForDisplay($module) .' returned.';
}
include_once('footer.php');
}
} else {
// Old-old style of loading modules
if (empty($file)) {
$file = 'index';
}
define('LOADED_AS_MODULE', '1');
if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/' . pnVarPrepForOS($file) . '.php')) {
include 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/' . pnVarPrepForOS($file) . '.php';
} else {
// Failed to load the module
header('HTTP/1.0 404 Not Found');
include ('header.php');
echo 'Failed to load module ' . pnVarPrepForDisplay($modinfo['name']) . '';
include ('footer.php');
}
}
?>