/** * Handle functions passed to gpPlugin::RegisterShutdown() * This function should not be called directly. */ function ShutdownFunction($addonFolderName, $args) { if (!is_array($args) || count($args) < 1) { return false; } gpPlugin::SetDataFolder($addonFolderName); $function = array_shift($args); if (count($args) > 0) { call_user_func_array($function, $args); } else { call_user_func($function); } gpPlugin::ClearDataFolder(); }
function UpdateAddon($addon) { if (!function_exists('OnTextChange')) { return; } gpPlugin::SetDataFolder($addon); OnTextChange(); gpPlugin::ClearDataFolder(); }
/** * Execute a set of directives for theme areas, hooks and special pages * */ static function ExecInfo($info, $args = array()) { global $dataDir, $addonFolderName, $installed_addon, $config, $page, $gp_overwrite_scripts; //addonDir is deprecated as of 2.0b3 if (isset($info['addonDir'])) { if (gp_safe_mode) { return; } gpPlugin::SetDataFolder($info['addonDir']); } elseif (isset($info['addon'])) { if (gp_safe_mode) { return; } gpPlugin::SetDataFolder($info['addon']); } //if addon was just installed if ($installed_addon && $installed_addon === $addonFolderName) { gpPlugin::ClearDataFolder(); return $args; } // check for fatal errors if (self::FatalNotice('exec', $info)) { return $args; } //data if (!empty($info['data'])) { IncludeScript($dataDir . $info['data'], 'include_if', array('page', 'dataDir', 'langmessage')); } //script $has_script = false; if (isset($info['script'])) { if (is_array($gp_overwrite_scripts) && isset($gp_overwrite_scripts[$info['script']])) { $full_path = $gp_overwrite_scripts[$info['script']]; } else { $full_path = $dataDir . $info['script']; } if (!file_exists($full_path)) { $name =& $config['addons'][$addonFolderName]['name']; trigger_error('gpEasy Error: Addon hook script doesn\'t exist. Script: ' . $info['script'] . ' Addon: ' . $name); } elseif (IncludeScript($full_path, 'include_once', array('page', 'dataDir', 'langmessage'))) { $has_script = true; } } //class & method if (!empty($info['class'])) { if (class_exists($info['class'])) { $object = new $info['class']($args); if (!empty($info['method'])) { if (method_exists($object, $info['method'])) { $args[0] = call_user_func_array(array($object, $info['method']), $args); } elseif ($has_script) { trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method']); } } } elseif ($has_script) { $name =& $config['addons'][$addonFolderName]['name']; trigger_error('gpEasy Error: Addon class doesn\'t exist. Class: ' . $info['class'] . ' Addon: ' . $name); } else { trigger_error('gpEasy Error: Addon class doesn\'t exist. Class: ' . $info['class']); } } elseif (!empty($info['method'])) { $callback = $info['method']; //object callbacks since gpEasy 3.0 if (is_string($callback) && strpos($callback, '->') !== false) { $has_script = true; list($object, $method) = explode('->', $callback); if (isset($GLOBALS[$object]) && is_object($GLOBALS[$object]) && method_exists($GLOBALS[$object], $method)) { $callback = array($GLOBALS[$object], $method); } } if (is_callable($callback)) { $args[0] = call_user_func_array($callback, $args); $method_called = true; } elseif ($has_script) { $name =& $config['addons'][$addonFolderName]['name']; trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method'] . ' Addon: ' . $name); } } gpPlugin::ClearDataFolder(); gpOutput::PopCatchable(); return $args; }
/** * Setup SPL Autoloading * */ static function Autoload($class) { global $config; $parts = explode('\\', $class); $part_0 = array_shift($parts); if (!$parts) { return; } //look for addon namespace if ($part_0 === 'Addon') { $namespace = array_shift($parts); if (!$parts) { return; } foreach ($config['addons'] as $addon_key => $addon) { if (isset($addon['Namespace']) && $addon['Namespace'] == $namespace) { gpPlugin::SetDataFolder($addon_key); $file = gpPlugin::$current['code_folder_full'] . '/' . implode('/', $parts) . '.php'; if (file_exists($file)) { include $file; } else { trigger_error('Script not found in namespaced autoloader for ' . $class); } gpPlugin::ClearDataFolder(); } } } }
/** * Find the requested admin script and execute it if the user has permissions to view it * */ function RunAdminScript() { global $dataDir, $langmessage; //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234 $parts = explode('/', $this->requested); do { $request_string = implode('/', $parts); $scriptinfo = false; $scripts = admin_tools::AdminScripts(); if (isset($scripts[$request_string])) { $scriptinfo = $scripts[$request_string]; if (admin_tools::HasPermission($request_string)) { if (isset($scriptinfo['addon'])) { gpPlugin::SetDataFolder($scriptinfo['addon']); } admin_display::OrganizeFrequentScripts($request_string); if (isset($scriptinfo['script'])) { require $dataDir . $scriptinfo['script']; } if (isset($scriptinfo['class'])) { new $scriptinfo['class'](); } gpPlugin::ClearDataFolder(); return; } else { message($langmessage['not_permitted']); $parts = array(); } } elseif (count($scripts) > 0) { //check case $case_check = array_keys($scripts); $case_check = array_combine($case_check, $case_check); $case_check = array_change_key_case($case_check, CASE_LOWER); $lower = strtolower($request_string); if (isset($case_check[$lower])) { $location = common::GetUrl($case_check[$lower], '', false); common::Redirect($location); } } //these are here because they should be available to everyone switch ($request_string) { case 'Admin_Browser': includeFile('admin/admin_browser.php'); new admin_browser(); return; case 'Admin_Preferences': includeFile('admin/admin_preferences.php'); new admin_preferences(); return; case 'Admin_About': includeFile('admin/admin_about.php'); new admin_about(); return; case 'Admin_Finder': includeFile('thirdparty/elfinder/connector.php'); return; } } while (array_pop($parts)); $this->AdminPanel(); }
/** * Execute a set of directives for theme areas, hooks and special pages * */ static function ExecInfo($info, $args = array()) { global $addonFolderName, $installed_addon; //addonDir is deprecated as of 2.0b3 if (isset($info['addonDir'])) { if (gp_safe_mode) { return; } gpPlugin::SetDataFolder($info['addonDir']); } elseif (isset($info['addon'])) { if (gp_safe_mode) { return; } gpPlugin::SetDataFolder($info['addon']); } //if addon was just installed if ($installed_addon && $installed_addon === $addonFolderName) { gpPlugin::ClearDataFolder(); return $args; } // check for fatal errors if (self::FatalNotice('exec', $info)) { return $args; } $args = self::_ExecInfo($info, $args); gpPlugin::ClearDataFolder(); gpOutput::PopCatchable(); return $args; }
function ExecInfo($info, $args = array()) { global $dataDir, $addonFolderName, $installed_addon; //addonDir is deprecated as of 2.0b3 if (isset($info['addonDir'])) { gpPlugin::SetDataFolder($info['addonDir']); } elseif (isset($info['addon'])) { gpPlugin::SetDataFolder($info['addon']); } //if addon was just installed if ($installed_addon && $installed_addon === $addonFolderName) { gpPlugin::ClearDataFolder(); return $args; } //data if (!empty($info['data']) && file_exists($dataDir . $info['data'])) { include $dataDir . $info['data']; } //script $has_script = false; if (isset($info['script'])) { if (file_exists($dataDir . $info['script'])) { include_once $dataDir . $info['script']; $has_script = true; } else { trigger_error('gpEasy Error: Addon hook script doesn\'t exist. Script: ' . $info['script']); } } //class & method if (!empty($info['class'])) { if (class_exists($info['class'])) { $object = new $info['class']($args); if (!empty($info['method'])) { if (method_exists($object, $info['method'])) { $args[0] = call_user_func_array(array($object, $info['method']), $args); } elseif ($has_script) { trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method']); } } } elseif ($has_script) { trigger_error('gpEasy Error: Addon hook class doesn\'t exist. Script: ' . $info['class']); } } elseif (!empty($info['method'])) { $callback = $info['method']; //object callbacks since gpEasy 3.0 if (is_string($callback) && strpos($callback, '->') !== false) { $has_script = true; list($object, $method) = explode('->', $callback); if (isset($GLOBALS[$object]) && method_exists($GLOBALS[$object], $method)) { $callback = array($GLOBALS[$object], $method); } } if (is_callable($callback)) { $args[0] = call_user_func_array($callback, $args); $method_called = true; } elseif ($has_script) { trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method']); } } gpPlugin::ClearDataFolder(); return $args; }
function ExecInfo($scriptinfo) { global $dataDir; ob_start(); if (isset($scriptinfo['addon'])) { gpPlugin::SetDataFolder($scriptinfo['addon']); } if (isset($scriptinfo['script'])) { require $dataDir . $scriptinfo['script']; } if (isset($scriptinfo['class'])) { new $scriptinfo['class'](); //not passing any args to class, this is being used by special_missing.php } gpPlugin::ClearDataFolder(); return ob_get_clean(); }