/** * Main plugin function, runs all the logic, you could call it the "controller" * @param PluginInstaller $pluginInstaller an instance of the PluginInstaller class. */ function gs_plugin_installer_main($pluginInstaller) { // TODO(03.07.2015) ~ Helge: Move a lot of this logic into a "controller" class, leaving this method as only a routing function if (isset($_GET["update"])) { $pluginInstaller->deleteCache(); ?> <script> $(function () { $('div.bodycontent').before('<div class="updated" style="display:block;"><?php i18n("gs_plugin_installer/CACHE_REFRESHED"); ?> </div>'); $('.updated, .error').fadeOut(300).fadeIn(500); }); </script> <?php } if (isset($_GET["install"])) { $plugin_ids = $_GET["plugins"]; $installed = 0; if (is_array($plugin_ids)) { foreach ($plugin_ids as $plugin_id) { if ($pluginInstaller->installPlugin($plugin_id)) { $installed++; } } } else { if ($pluginInstaller->installPlugin($plugin_ids)) { $installed++; } } $install_msg = $installed ? $installed . i18n_r("gs_plugin_installer/INSTALLED_SUCCESS") : i18n_r("gs_plugin_installer/INSTALLED_FAIL"); ?> <script> $(function () { $('div.bodycontent').before('<div class="<?php echo $installed ? 'updated' : 'error'; ?> " style="display:block;">' + "<?php echo $install_msg; ?> " + '</div>'); $('.updated, .error').fadeOut(300).fadeIn(500); }); </script> <?php } if (isset($_GET["uninstall"])) { $plugin_ids = $_GET["plugins"]; $uninstalled = 0; if (is_array($plugin_ids)) { foreach ($plugin_ids as $plugin_id) { if ($pluginInstaller->uninstallPlugin($plugin_id)) { $uninstalled++; } } } else { if ($pluginInstaller->uninstallPlugin($plugin_ids)) { $uninstalled++; } } $uninstall_msg = $uninstalled ? $uninstalled . i18n_r("gs_plugin_installer/UNINSTALLED_SUCCESS") : i18n_r("gs_plugin_installer/UNINSTALLED_FAIL"); ?> <script> $(function () { $('div.bodycontent').before('<div class="<?php echo $uninstalled ? 'updated' : 'error'; ?> " style="display:block;">' + "<?php echo $uninstall_msg; ?> " + '</div>'); $('.updated, .error').fadeOut(300).fadeIn(500); }); </script> <?php } $plugins = $pluginInstaller->getPlugins(); ?> <script> (function(i18n) { i18n['CONFIRM_UNINSTALL'] = '<?php i18n("gs_plugin_installer/CONFIRM_UNINSTALL"); ?> '; i18n['CONFIRM_UNINSTALL_ALL'] = '<?php i18n("gs_plugin_installer/CONFIRM_UNINSTALL_ALL"); ?> '; }(GS.i18n)); </script> <form id="gs_plugin_form" action="load.php" method="GET"> <input type="hidden" name="id" value="gs_plugin_installer"> <h3 class="floated"><?php i18n("gs_plugin_installer/PLUGIN_NAME"); ?> </h3> <div class="edit-nav clearfix"> <a href="load.php?id=gs_plugin_installer&update"><?php i18n("gs_plugin_installer/REFRESH"); ?> </a> <button id="install" type="submit" name="install" value="1"><?php i18n("gs_plugin_installer/INSTALL"); ?> </button> <button id="uninstall" type="submit" name="uninstall" value="1"><?php i18n("gs_plugin_installer/UNINSTALL"); ?> </button> </div> <table id="plugin_table" class="highlight"> <thead> <tr> <th><?php i18n("gs_plugin_installer/LIST_PLUGIN"); ?> </th> <th><?php i18n("gs_plugin_installer/LIST_DESCRIPTION"); ?> </th> <th><?php i18n("gs_plugin_installer/LIST_INSTALL"); ?> </th> <th> </th> </tr> </thead> <tbody> <?php foreach ($plugins as $index => $plugin) { ?> <tr id="tr-<?php echo $index; ?> "> <td> <a href="<?php echo $plugin->path; ?> " target="_blank"> <b><?php echo $plugin->name; ?> </b> </a> </td> <td> <div class="description"> <?php echo trim(strip_tags(nl2br($plugin->description), "<br><br/>")); ?> </div> <b><?php i18n("gs_plugin_installer/VERSION"); ?> <?php echo $plugin->version; ?> </b> — <?php i18n("gs_plugin_installer/AUTHOR"); ?> : <a href="<?php echo $plugin->author_url; ?> " target="_blank"><?php echo $plugin->owner; ?> </a> </td> <td> <?php if ($pluginInstaller->isPluginInstalled($plugin)) { ?> <a class="cancel" href="load.php?id=gs_plugin_installer&uninstall=1&plugins=<?php echo $plugin->id; ?> ">Uninstall</a> <?php } else { ?> <a href="load.php?id=gs_plugin_installer&install=1&plugins=<?php echo $plugin->id; ?> "><?php i18n("gs_plugin_installer/INSTALL"); ?> </a> <?php } ?> </td> <td> <input name="plugins[]" type="checkbox" value="<?php echo $plugin->id; ?> "> </td> </tr> <?php } ?> </tbody> </table> </form> <?php }
/** * Get code for install * @return string */ private function getCodeForInstall() { $Factory = new PluginFactory(); $Plugins = $Factory->notInstalledPlugins(); if (empty($Plugins)) { return HTML::fileBlock(__('There are no new plugins to install.')); } $Code = ' <table class="fullwidth zebra-style more-padding"> <thead> <tr class="b"> <th colspan="3">' . __('Plugin') . '</th> <th colspan="2">' . __('Type') . '</th> </tr> </thead> <tbody>'; foreach ($Plugins as $Data) { $Plugin = $Factory->newInstallerInstance($Data['key']); $Code .= ' <tr> <td>' . Icon::$ADD . '</td> <td class="b">' . PluginInstaller::link($Plugin->key(), $Plugin->name()) . '</td> <td>' . $Plugin->description() . '</td> <td colspan="2">' . PluginType::readableString($Plugin->type()) . '</td> </tr>'; } $Code .= ' </tbody> </table>'; return $Code; }
public function other_install() { require_once 'lib/plugin-installer/installer.php'; $installer = new PluginInstaller(array("name" => "BruteProtect", "slug" => "bruteprotect", "redirect" => admin_url("admin.php?page=bruteprotect-config"))); if ($installer->called()) { $installer->install_and_activate(); } }
<?php /** * File for uninstalling plugins. * Call: call.Plugin.uninstall.php?key= */ require '../inc/class.Frontend.php'; $Pluginkey = filter_input(INPUT_GET, 'key'); $Frontend = new Frontend(); $Installer = new PluginInstaller($Pluginkey); echo '<h1>' . __('Uninstall') . ' ' . $Pluginkey . '</h1>'; if ($Installer->uninstall()) { echo HTML::okay(__('The plugin has been uninstalled.')); PluginFactory::clearCache(); Ajax::setReloadFlag(Ajax::$RELOAD_ALL); echo Ajax::getReloadCommand(); } else { echo HTML::error(__('There was a problem, the plugin could not be uninstalled.')); } echo '<ul class="blocklist">'; echo '<li>'; echo Ajax::window('<a href="' . ConfigTabPlugins::getExternalUrl() . '">' . Icon::$TABLE . ' ' . __('back to list') . '</a>'); echo '</li>'; echo '</ul>';
<?php /** * File for installing plugins. * Call: call.Plugin.install.php?key= */ require '../inc/class.Frontend.php'; $Pluginkey = filter_input(INPUT_GET, 'key'); $Frontend = new Frontend(); $Installer = new PluginInstaller($Pluginkey); echo '<h1>' . __('Install') . ' ' . $Pluginkey . '</h1>'; if ($Installer->install()) { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance($Pluginkey); echo HTML::okay(__('The plugin has been successfully installed.')); echo '<ul class="blocklist">'; echo '<li>'; echo $Plugin->getConfigLink(Icon::$CONF . ' ' . __('Configuration')); echo '</li>'; echo '</ul>'; Ajax::setReloadFlag(Ajax::$RELOAD_ALL); echo Ajax::getReloadCommand(); } else { echo HTML::error(__('There was a problem, the plugin could not be installed.')); } echo '<ul class="blocklist">'; echo '<li>'; echo Ajax::window('<a href="' . ConfigTabPlugins::getExternalUrl() . '">' . Icon::$TABLE . ' ' . __('back to list') . '</a>'); echo '</li>'; echo '</ul>';
/* * Bluethrust Clan Scripts v4 * Copyright 2014 * * Author: Bluethrust Web Development * E-mail: support@bluethrust.com * Website: http://www.bluethrust.com * * License: http://www.bluethrust.com/license.php * */ $prevFolder = "../"; include_once "../_setup.php"; // Start Page $consoleObj = new ConsoleOption($mysqli); $cID = $consoleObj->findConsoleIDByName("Plugin Manager"); $consoleObj->select($cID); $consoleInfo = $consoleObj->get_info_filtered(); $member = new Member($mysqli); $member->select($_SESSION['btUsername']); $pluginObj = new btPlugin($mysqli); // Check Login $LOGIN_FAIL = true; if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj) && isset($_GET['plugin'])) { $pluginInstaller = new PluginInstaller($mysqli); require BASE_DIRECTORY . "plugins/" . $_GET['plugin'] . "/install_setup.php"; $pluginInstaller->install(); if ($pluginInstaller->isInstalled()) { $member->logAction("Installed " . $pluginInstaller->pluginName . " Plugin."); } }
/* * Bluethrust Clan Scripts v4 * Copyright 2014 * * Author: Bluethrust Web Development * E-mail: support@bluethrust.com * Website: http://www.bluethrust.com * * License: http://www.bluethrust.com/license.php * */ $prevFolder = "../"; include_once "../_setup.php"; // Start Page $consoleObj = new ConsoleOption($mysqli); $cID = $consoleObj->findConsoleIDByName("Plugin Manager"); $consoleObj->select($cID); $consoleInfo = $consoleObj->get_info_filtered(); $member = new Member($mysqli); $member->select($_SESSION['btUsername']); $pluginObj = new btPlugin($mysqli); // Check Login $LOGIN_FAIL = true; if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj) && isset($_GET['plugin'])) { $pluginInstaller = new PluginInstaller($mysqli); require BASE_DIRECTORY . "plugins/" . $_GET['plugin'] . "/install_setup.php"; $pluginInstaller->uninstall(); if (!$pluginInstaller->isInstalled()) { $member->logAction("Uninstalled " . $pluginInstaller->pluginName . " Plugin."); } }