//returns http://example.com/rss/plugins/ return guessTransportProto() . $_SERVER['HTTP_HOST'] . getPath() . RSS_PLUGINS_DIR . "/"; } /** * loads the specified plugin file */ function rss_load_plugin($plugin_filename) { set_loading_plugin($plugin_filename); if (file_exists(rss_home_dir() . RSS_PLUGINS_DIR . '/' . $plugin_filename)) { rss_require(RSS_PLUGINS_DIR . '/' . $plugin_filename); } set_loading_plugin(''); } /** * loads the active plugins from the config, instantiates * them */ foreach (getConfig('rss.config.plugins') as $pf) { rss_load_plugin($pf); } /* * autoload plugins specific to a theme without the * need to add them to config * all plugins def must be inside a unique file called plugins.php that * do all the works */ $mythemeplugin = getThemePath(GREGARIUS_HOME) . "plugins.php"; if (file_exists($mythemeplugin)) { require_once $mythemeplugin; }
function plugin_options() { if (!array_key_exists('plugin_name', $_REQUEST) || array_key_exists('admin_plugin_options_cancel_changes', $_REQUEST)) { plugins(); return; } // TBD $plugin_filename = $_REQUEST['plugin_name']; $plugin_filename = str_replace("%2F", "/", $plugin_filename); $plugin_output = ""; if (preg_match('/([a-zA-Z0-9_\\/\\-]+).php/', $plugin_filename, $matches)) { $plugin_filename = $matches[1] . ".php"; // sanitize input $plugin_info = getPluginInfo($plugin_filename); if ($plugin_info && array_key_exists('configuration', $plugin_info)) { $plugin_config_func = $plugin_info['configuration']; ob_start(); rss_load_plugin($plugin_filename); if (function_exists($plugin_config_func)) { call_user_func($plugin_config_func); // Are you happy now? $plugin_output = ob_get_contents(); } ob_end_clean(); rss_invalidate_cache(); } if ($plugin_output) { // Let us set up a form echo "<h2\n class=\"trigger\">" . __('Plugin Options') . " " . TITLE_SEP . " " . $plugin_info['name'] . "</h2>\n" . "<div id=\"admin_plugin_options\">\n"; echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">\n"; echo "<p><input type=\"hidden\" name=\"" . CST_ADMIN_DOMAIN . "\" value=\"" . CST_ADMIN_DOMAIN_PLUGIN_OPTIONS . "\" /></p>\n"; echo $plugin_output; echo "<p><input type=\"hidden\" name=\"plugin_name\" value=\"" . $plugin_filename . "\"/>\n"; echo "<p><input type=\"hidden\" name=\"" . CST_ADMIN_METAACTION . "\" value=\"ACT_ADMIN_SUBMIT_CHANGES\"/>\n"; echo "<input type=\"submit\" name=\"admin_plugin_options_submit_changes\" value=\"" . __('Submit Changes') . "\" />\n"; echo "<input type=\"submit\" name=\"admin_plugin_options_cancel_changes\"\n value=\"" . __('Cancel') . "\" /></p></form>\n"; echo "</div>"; } else { plugins(); } } }