* @uses access_api.php * @uses authentication_api.php * @uses config_api.php * @uses form_api.php * @uses gpc_api.php * @uses plugin_api.php * @uses print_api.php */ /** @ignore */ define('PLUGINS_DISABLED', true); /** * MantisBT Core API's */ require_once 'core.php'; require_api('access_api.php'); require_api('authentication_api.php'); require_api('config_api.php'); require_api('form_api.php'); require_api('gpc_api.php'); require_api('plugin_api.php'); require_api('print_api.php'); form_security_validate('manage_plugin_install'); auth_reauthenticate(); access_ensure_global_level(config_get('manage_plugin_threshold')); $f_basename = gpc_get_string('name'); $t_plugin = plugin_register($f_basename, true); if (!is_null($t_plugin)) { plugin_install($t_plugin); } form_security_purge('manage_plugin_install'); print_successful_redirect('manage_plugin_page.php');
function install($plugin_version, &$errors = array()) { if (is_callable('plugin_install')) { return plugin_install($this->plugin_id, $plugin_version, $errors); } }
public static function install($plugin, $blobbed_plugin, $name) { global $txpcfg, $event; include_once $txpcfg['txpath'] . DS . 'include' . DS . 'txp_plugin.php'; $_POST['plugin64'] = $blobbed_plugin; $_POST['event'] = 'plugin'; $current_event = $event; # # Use a new output buffer to swallow the view that is output by calling plugin_install() # ob_start(); plugin_install(); ob_clean(); # # Unfortunately, due to Txp's lack of separation of view from model, we loose the result of the install and have to assume it went ok. # return true; }
function sed_cleaner_gogogo() { global $event, $prefs, $txpcfg; $files_path = $prefs['file_base_path']; $tpref = $txpcfg['table_prefix']; $debug = 0; # # Remove default content... # safe_query("TRUNCATE TABLE `{$tpref}txp_discuss`", $debug); safe_query("TRUNCATE TABLE `{$tpref}txp_link`", $debug); safe_query("TRUNCATE TABLE `{$tpref}textpattern`", $debug); safe_query("TRUNCATE TABLE `{$tpref}txp_image`", $debug); safe_delete('txp_category', "`name` <> 'root'"); # # Setup some defaults... # safe_update('txp_prefs', "`val`=''", "`name`='site_slogan'", $debug); safe_update('txp_prefs', "`val`=''", "`name`='custom_1_set'", $debug); safe_update('txp_prefs', "`val`=''", "`name`='custom_2_set'", $debug); safe_update('txp_prefs', "`val`=''", "`name`='spam_blacklists'", $debug); safe_update('txp_prefs', "`val`='0'", "`name`='use_dns'", $debug); safe_update('txp_prefs', "`val`='1'", "`name`='never_display_email'", $debug); # # Remove the setup directory (if permissions allow)... # sed_cleaner_rmdir('setup', $debug); # # identify installable files found in the files/ directory... # include_once $txpcfg['txpath'] . DS . 'include' . DS . 'txp_plugin.php'; $files = array(); $path = $files_path; if ($debug) { echo br, "Auto Install Plugins... Accessing dir({$path}) ..."; } $dir = @dir($path); if ($dir === false) { if ($debug) { echo " failed!"; } } else { while ($file = $dir->read()) { $parts = pathinfo($file); $fileaddr = $path . DS . $file; if (!is_dir($fileaddr)) { if ($debug) { echo br, "... found ({$file})"; } switch (@$parts['extension']) { case 'plugin': $files['plugins'][] = $file; if ($debug) { echo " : accepting as a candidate plugin file."; } break; case 'css': $files['css'][] = $file; if ($debug) { echo " : accepting as a candidate CSS file."; } break; case 'page': $files['page'][] = $file; if ($debug) { echo " : accepting as a candidate Txp page file."; } break; case 'form': $files['form'][] = $file; if ($debug) { echo " : accepting as a candidate Txp form file."; } break; default: break; } } } } $dir->close(); # # Try to auto-install any plugin files found in the files directory... # $plugin_count = 0; if (empty($files['plugins'])) { if ($debug) { echo " no plugin candidate files found."; } } else { include_once $txpcfg['txpath'] . '/lib/txplib_head.php'; foreach ($files['plugins'] as $file) { if ($debug) { echo br, "Processing {$file} : "; } # # Load the file into the $_POST['plugin64'] entry and try installing it... # $plugin = join('', file($path . DS . $file)); $_POST['plugin64'] = $plugin; if ($debug) { echo "installing,"; } plugin_install(); $plugin_count += 1; unlink($path . DS . $file); } } # # Try to install any CSS files found... # if (empty($files['css'])) { if ($debug) { echo " no CSS candidates found."; } } else { foreach ($files['css'] as $file) { if ($debug) { echo br, "Processing {$file} : "; } $content = doSlash(file_get_contents($path . DS . $file)); $parts = pathinfo($file); $name = doSlash($parts['filename']); safe_upsert('txp_css', "`css`='{$content}'", "`name`='{$name}'", $debug); unlink($path . DS . $file); } } # # Try to install any page files found... # if (empty($files['page'])) { if ($debug) { echo " no page candidates found."; } } else { foreach ($files['page'] as $file) { if ($debug) { echo br, "Processing {$file} : "; } $content = doSlash(file_get_contents($path . DS . $file)); $parts = pathinfo($file); $name = doSlash($parts['filename']); safe_upsert('txp_page', "`user_html`='{$content}'", "`name`='{$name}'", $debug); unlink($path . DS . $file); } } # # Try to install any form files found... # # Filename format = name.type.form # where type is one of { article, link, file, comment, misc } # if (empty($files['form'])) { if ($debug) { echo " no form candidates found."; } } else { foreach ($files['form'] as $file) { if ($debug) { echo br, "Processing {$file} : "; } $content = doSlash(file_get_contents($path . DS . $file)); $parts = pathinfo($file); $tmp = explode('.', $parts['filename']); $type = doSlash(array_pop($tmp)); $name = doSlash(implode('.', $tmp)); echo br, "Found form {$name} of type {$type}."; safe_upsert('txp_form', "`Form`='{$content}', `type`='{$type}'", "`name`='{$name}'", $debug); unlink($path . DS . $file); } } # # Process the cleanups.php file... # $file = $files_path . DS . 'cleanups.php'; if (file_exists($file)) { $cleanups = array(); # # Include the scripted cleanups... # @(include $file); if (is_callable('sed_cleaner_config')) { $cleanups = sed_cleaner_config(); } if (!empty($cleanups)) { # # Take the scripted actions... # foreach ($cleanups as $action) { $p = explode(' ', $action); if ($debug) { dmp($p); } $action = strtolower(array_shift($p)); $fn = "sed_cleaner_{$action}_action"; if (is_callable($fn)) { $fn($p, $debug); } } } elseif ($debug) { echo "<pre>No installation specific cleanups found.\n</pre>"; } unlink($file); } elseif ($debug) { echo "<pre>No installation specific cleanup file found.\n</pre>"; } sed_cleaner_done(); if (!$debug) { # # cleanup the cleanup files... # # sed_cleaner_empty_dir( $prefs['file_base_path'], $debug, true ); # exclude hiddens! safe_query("TRUNCATE TABLE `{$tpref}txp_file`", $debug); # # Finally, we self-destruct unless debugging and redirect to the plugins tab... # safe_delete('txp_plugin', "`name`='sed_cleaner'", $debug); if ($plugin_count) { while (@ob_end_clean()) { } header('Location: ' . hu . 'textpattern/index.php?event=prefs'); header('Connection: close'); header('Content-Length: 0'); } exit(0); } }
function plugin_activate() { global $conf; if (!is_array($conf['vjs_conf'])) { $conf['vjs_conf'] = unserialize($conf['vjs_conf']); } if (!isset($conf['vjs_conf']) or !isset($conf['vjs_customcss']) or !empty($conf['vjs_conf']) or count($conf['vjs_conf'], COUNT_RECURSIVE) != 12) { plugin_install(); } }
function plugins() { global $ADMIN_CONF; global $CatPage; global $message; global $specialchars; global $debug; $plugin_manage_open = false; # plugins löschen if (getRequestValue('plugin-all-del', 'post') and getRequestValue('plugin-del', 'post')) { plugin_del(); $plugin_manage_open = true; } # hochgeladenes plugin installieren if (isset($_FILES["plugin-install-file"]["error"]) and getRequestValue('plugin-install', 'post') and $_FILES["plugin-install-file"]["error"] == 0 and strtolower(substr($_FILES["plugin-install-file"]["name"], -4)) == ".zip") { $debug .= "install=" . $_FILES["plugin-install-file"]["name"] . "<br />\n"; plugin_install(); $plugin_manage_open = true; } elseif ($plugin_select = $specialchars->rebuildSpecialChars(getRequestValue('plugin-install-select', 'post'), false, false) and getRequestValue('plugin-install', 'post') and is_file(PLUGIN_DIR_REL . $specialchars->replaceSpecialChars($plugin_select, false)) !== false and strtolower(substr($plugin_select, -4)) == ".zip") { $debug .= "local install=" . getRequestValue('plugin-install-select', 'post') . "<br />\n"; plugin_install($plugin_select); $plugin_manage_open = true; } $showdebug = false; if ($showdebug and !empty($debug)) { $message .= returnMessage(false, $debug); } require_once BASE_DIR_CMS . "Plugin.php"; if (false !== ($plugin_name = getRequestValue('pluginadmin'))) { #,'get' if (file_exists(PLUGIN_DIR_REL . $plugin_name)) { define("PLUGINADMIN", $plugin_name); if (file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/index.php")) { require_once PLUGIN_DIR_REL . PLUGINADMIN . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists(PLUGINADMIN) and in_array(PLUGINADMIN, get_declared_classes())) { # $PLUGIN_ADMIN_ADD_HEAD gibts nur hier und ist für sachen die in den head sollen global $PLUGIN_ADMIN_ADD_HEAD; $PLUGIN_ADMIN_ADD_HEAD = array(); $multi_user = ""; if (defined('MULTI_USER') and MULTI_USER) { $multi_user = "******"; } define("PLUGINADMIN_GET_URL", URL_BASE . ADMIN_DIR_NAME . "/index.php?pluginadmin=" . PLUGINADMIN . "&nojs=true&action=" . ACTION . $multi_user); $plugin = new $plugin_name(); $info = $plugin->getInfo(); $config = $plugin->getConfig(); if (PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"] == PLUGIN_DIR_REL . PLUGINADMIN . "/index.php") { return $plugin->getContent(""); } else { return require_once PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"]; } } } else { die; } } else { die; } } if (getRequestValue('chanceplugin', 'post') == "true" and false !== ($plugin_name = getRequestValue('plugin_name', 'post'))) { if (file_exists(PLUGIN_DIR_REL . $plugin_name) and file_exists(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . $plugin_name . "/index.php")) { $conf_plugin = new Properties(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php"); } else { die("Fatal Error"); } if (false !== ($activ = getRequestValue(array($plugin_name, 'active'), 'post')) and ($activ == "true" or $activ == "false")) { $conf_plugin->set("active", $activ); ajax_return("success", true); } elseif ($conf_plugin->get("active") == "true") { require_once PLUGIN_DIR_REL . $plugin_name . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists($plugin_name) and in_array($plugin_name, get_declared_classes())) { $plugin = new $plugin_name(); # das ist nötig weil es sein kann das in getInfo() variblen initaliesiert werden $tmp = $plugin->getInfo(); $config = $plugin->getConfig(); echo save_plugin_settings($conf_plugin, $config, $plugin_name); exit; } else { die("Fatal Error"); } } die("Fatal Error"); } $pagecontent = ''; $show = $ADMIN_CONF->get("plugins"); if (!is_array($show)) { $show = array(); } if (ROOT or in_array("plugin_-_manage", $show)) { $multi_user = ""; if (defined('MULTI_USER') and MULTI_USER) { $multi_user = "******"; } $html_manage = ""; $plugin_manage = array(); $disabled = ''; if (!function_exists('gzopen')) { $disabled = ' disabled="disabled"'; } $plugin_install = array(); foreach (getDirAsArray(PLUGIN_DIR_REL, array(".zip")) as $zip_file) { $plugin_install[] = '<option value="' . mo_rawurlencode($zip_file) . '">' . $zip_file . '</option>'; } $plugin_install_html = ""; if (count($plugin_install) > 0) { $plugin_install_html .= '<br /><select class="mo-install-select mo-select-div" name="plugin-install-select" size="1"' . $disabled . '>' . '<option value="">' . getLanguageValue("plugins_select", true) . '</option>' . implode("", $plugin_install) . '</select>'; } $plugin_manage["plugins_title_manage"][] = '<form id="js-plugin-manage" action="index.php?nojs=true&action=plugins' . $multi_user . '" method="post" enctype="multipart/form-data">' . '<div class="mo-nowrap align-right ui-helper-clearfix">' . '<span class="align-left" style="float:left"><span class="mo-bold">' . getLanguageValue("plugins_text_filebutton") . '</span><br />' . getLanguageValue("plugins_text_fileinfo") . '</span>' . '<input type="file" id="js-plugin-install-file" name="plugin-install-file" class="mo-select-div"' . $disabled . ' />' . $plugin_install_html . '<input type="submit" id="js-plugin-install-submit" name="plugin-install" value="' . getLanguageValue("plugins_button_install", true) . '"' . $disabled . ' /><br />' . '<input type="submit" id="js-plugin-del-submit" value="' . getLanguageValue("plugins_button_delete", true) . '" class="mo-margin-top js-send-del-stop" />' . '</div></form>'; $plugin_manage["plugins_title_manage"]["toggle"] = true; $html_manage = contend_template($plugin_manage); $html_manage = str_replace("js-toggle", "js-toggle-manage", $html_manage); # es wurde in der template verwaltung was gemacht dann soll die aufgeklapt bleiben if ($plugin_manage_open) { $html_manage = str_replace("display:none;", "", $html_manage); } $pagecontent .= $html_manage; } $pagecontent .= '<ul class="js-plugins mo-ul">'; $dircontent = getDirAsArray(PLUGIN_DIR_REL, "dir", "natcasesort"); foreach ($dircontent as $currentelement) { $new_plugin_conf = false; if (!ROOT and !in_array($currentelement, $show)) { continue; } if (file_exists(PLUGIN_DIR_REL . $currentelement . "/index.php")) { if (!is_file(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) { if (false === newConf(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) { die; } else { $new_plugin_conf = true; } } require_once PLUGIN_DIR_REL . $currentelement . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists($currentelement) and in_array($currentelement, get_declared_classes())) { $plugin = new $currentelement(); } else { # Plugin Dirname stimt nicht mit Plugin Classnamen überein continue; } # plugin.conf.php wurde neu erstelt. # Wenn es die getDefaultSettings() gibt fühle die plugin.conf.php damit if ($new_plugin_conf and method_exists($plugin, 'getDefaultSettings')) { $plugin->settings->setFromArray($plugin->getDefaultSettings()); } $plugin_css_li_error = NULL; $plugin_error = false; $plugin_info = $plugin->getInfo(); # Plugin Info Prüfen if (isset($plugin_info) and count($plugin_info) > 0) { $plugin_name = strip_tags($plugin_info[0], '<b>'); if (substr(strip_tags($plugin_name), 0, strlen($currentelement)) != $currentelement) { $plugin_name = "<b>" . $currentelement . "</b> " . strip_tags($plugin_name); } $plugin_name = htmlentities($plugin_name, ENT_COMPAT, CHARSET); $plugin_name = str_replace(array("<", ">", "\$"), array("<", ">", ""), $plugin_name); } else { $plugin_error = '<img class="mo-tool-icon mo-icons-icon mo-icons-error" src="' . ICON_URL_SLICE . '" alt="error" />' . getLanguageValue('plugins_error') . ' <b>' . $currentelement . '</b>'; $plugin_css_li_error = ' ui-state-error'; } $pagecontent .= '<li class="js-plugin mo-li ui-widget-content ui-corner-all' . $plugin_css_li_error . '">' . '<div class="js-tools-show-hide mo-li-head-tag mo-li-head-tag-no-ul ui-state-active ui-corner-all ui-helper-clearfix">'; $check_show = ' style="display:none;"'; if ($plugin_manage_open) { $check_show = ''; } if ($plugin_error === false) { $pagecontent .= '<span class="js-plugin-name mo-padding-left mo-middle">' . $plugin_name . '</span>' . '<div style="float:right;" class="mo-tag-height-from-icon mo-middle mo-nowrap">' . '<span class="js-plugin-active mo-staus">' . buildCheckBox($currentelement . '[active]', $plugin->settings->get("active") == "true", getLanguageValue("plugins_input_active")) . '</span>' . '<img class="js-tools-icon-show-hide js-toggle mo-tool-icon mo-icons-icon mo-icons-edit" src="' . ICON_URL_SLICE . '" alt="edit" />' . '<input type="checkbox" value="' . $currentelement . '" class="mo-checkbox mo-checkbox-del js-plugin-del"' . $check_show . ' />' . '</div>' . '</div>' . '<div class="js-toggle-content mo-in-ul-ul ui-helper-clearfix" style="display:none;">' . get_plugin_info($plugin_info); # geändert damit getConfig() nicht 2mal ausgeführt wird $config = $plugin->getConfig(); # Beschreibung und inputs der Konfiguration Bauen und ausgeben $pagecontent .= get_plugin_config($plugin->settings, $config, $currentelement); } else { $pagecontent .= $plugin_error; } $pagecontent .= '</div></li>'; unset($plugin); } } $pagecontent .= '</ul>'; return $pagecontent; }
function plugin_unstall_code($file, $code) { $range_start = range_start_keyword($file, $code); if ($range_start === FALSE) { return xn_error(-1, '未找到特定字符串,可能版本不对或插件已经卸载。'); } $range_end = $range_start + strlen($code . $keyword); if (range_start_keyword($file, $code) === FALSE) { return xn_error(-1, '插件点已经卸载。'); } $plugin = array('file' => $file, 'range_start' => $range_start, 'range_end' => $range_end, 'code' => $keyword); return plugin_install($plugin); }
*/ require_once "../../lib/php/bootstrap.php"; $SysConf = array(); // fo system configuration variables $PG_CONN = 0; // Database connection $Plugins = array(); /* Set SYSCONFDIR and set global (for backward compatibility) */ $SysConf = bootstrap(); /* Initialize global system configuration variables $SysConfig[] */ ConfigInit($SYSCONFDIR, $SysConf); //debugprint($SysConf, "SysConf"); plugin_load(); // call install method of every plugin, core-auth creates the default user and // the fossy user plugin_install(FALSE); $Mod = GetParm("mod", PARM_STRING); if (!isset($Mod)) { $Mod = "Default"; } $PluginId = plugin_find_id($Mod); if ($PluginId >= 0) { /* Found a plugin, so call it! */ $Plugins[$PluginId]->OutputOpen("HTML", 1); // error_reporting(E_ALL | E_NOTICE); $Plugins[$PluginId]->Output(); $Plugins[$PluginId]->OutputClose(); } else { $Uri = Traceback_uri() . "?mod=auth"; $text = _("Module unavailable or your login session timed out."); print "{$text} <P />";
check_privs(1, 2); switch (strtolower($step)) { case "list": list_plugins(); break; case "edit": edit_plugin(); break; case "switch_status": switch_status(); break; case "plugin_save": plugin_save(); break; case "plugin_install": plugin_install(); break; case "view_hilighted": view_hilighted(); break; case "view_help": view_help(); break; case "delete": plugin_delete(); break; default: list_plugins(); } // ------------------------------------------------------------- function list_plugins($message = '')
function sed_plugin_auto_install($event, $step) { global $txpcfg, $prefs; require_privs('sed_plugin_auto_install'); include_once $txpcfg['txpath'] . '/include/txp_plugin.php'; $debug = false; if ($debug) { echo br, "Loading: Auto Install Plugin."; } # # Build a list of all files in the special plugins dir... # $files = array(); $path = $prefs['file_base_path'] . DS . 'sed_autoinst' . DS . 'plugins'; if ($debug) { echo br, "Auto Install Plugins... Accessing dir({$path}) ..."; } $dir = @dir($path); if ($dir === false) { if ($debug) { echo " failed!"; } return; } while ($file = $dir->read()) { if ($file !== '.' && $file !== '..') { if ($debug) { echo br, "... found ({$file})"; } $fileaddr = $path . DS . $file; if (!is_dir($fileaddr)) { $files[] = $file; if ($debug) { echo " : accepting as plugin."; } } } } $dir->close(); # # Exit if there is nothing to do... # if (empty($files)) { if ($debug) { echo " no plugins found: exiting."; } return; } # # Process each file... # foreach ($files as $file) { if ($debug) { echo br, "Processing {$file} : "; } # # Load the file into the $_POST['plugin64'] entry and try installing it... # $plugin = join('', file($path . DS . $file)); $_POST['plugin64'] = $plugin; if ($debug) { echo "installing,"; } include_once $txpcfg['txpath'] . '/lib/txplib_head.php'; plugin_install(); # # Drop the file extension to leave only the name... # $bits = explode('.', $file); array_pop($bits); $file = join('.', $bits); # # Try enabling it now (guesses at plugin name from file name)... # $plugin_name = strtr($file, array('-' => '_')); $_POST['name'] = $plugin_name; $_POST['status'] = '0'; if ($debug) { echo " attempting to activate {$plugin_name}."; } switch_status(); } if (!$debug) { # # Remove ourself from the plugin installation now (nice idea Ruud!)... # safe_delete('txp_plugin', "name = 'sed_auto_inst'"); while (@ob_end_clean()) { } header('Location: ' . hu . 'textpattern/index.php?event=plugin'); header('Connection: close'); header('Content-Length: 0'); exit(0); } }
function plugin_activate() { global $conf; if (!isset($conf['osm_conf']) or count($conf['osm_conf'], COUNT_RECURSIVE) != 43) { plugin_install(); } }
/** * Schema update to install and configure new Gravatar plugin. * If the instance has enabled use of avatars, then we register the plugin * @return int 2 if successful */ function install_gravatar_plugin() { if (config_get_global('show_avatar')) { $t_avatar_plugin = 'Gravatar'; # Register and install the plugin $t_plugin = plugin_register($t_avatar_plugin, true); if (!is_null($t_plugin)) { plugin_install($t_plugin); } else { error_parameters($t_avatar_plugin); echo '<br>' . error_string(ERROR_PLUGIN_INSTALL_FAILED); return 1; } } # Return 2 because that's what ADOdb/DataDict does when things happen properly return 2; }