コード例 #1
0
ファイル: Plugins.php プロジェクト: featherbb/featherbb
 /**
  * Uninstall a plugin after deactivated
  */
 public function uninstall($name)
 {
     $name = Container::get('hooks')->fire('model.plugin.uninstall.name', $name);
     $activePlugins = $this->manager->getActivePlugins();
     // Check if plugin is disabled, for security
     if (!in_array($name, $activePlugins)) {
         $plugin = DB::for_table('plugins')->where('name', $name)->find_one();
         if ($plugin) {
             $plugin->delete();
         }
         // Allow additional uninstalling functions
         $this->manager->uninstall($name);
         if (file_exists(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $name)) {
             AdminUtils::delete_folder(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $name);
         }
         $this->manager->setActivePlugins();
     }
     return true;
 }
コード例 #2
0
ファイル: Plugins.php プロジェクト: featherbb/featherbb
 /**
  * Download a plugin, unzip it and rename it
  */
 public function download($req, $res, $args)
 {
     $zipFile = ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] . "-" . $args['version'] . '.zip';
     $zipResource = fopen($zipFile, "w");
     // Get the zip file straight from GitHub
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'https://codeload.github.com/featherbb/' . $args['name'] . '/zip/' . $args['version']);
     curl_setopt($ch, CURLOPT_FAILONERROR, true);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_FILE, $zipResource);
     $page = curl_exec($ch);
     curl_close($ch);
     fclose($zipResource);
     if (!$page) {
         unlink(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] . "-" . $args['version'] . '.zip');
         throw new Error(__('Bad request'), 400);
     }
     $zip = new ZipArchive();
     if ($zip->open($zipFile) != true) {
         throw new Error(__('Bad request'), 400);
     }
     $zip->extractTo(ForumEnv::get('FEATHER_ROOT') . 'plugins');
     $zip->close();
     if (file_exists(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'])) {
         AdminUtils::delete_folder(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
     }
     rename(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] . "-" . $args['version'], ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
     unlink(ForumEnv::get('FEATHER_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] . "-" . $args['version'] . '.zip');
     return Router::redirect(Router::pathFor('adminPlugins'), 'Plugin downloaded!');
 }
コード例 #3
0
ファイル: _upgrade.php プロジェクト: featherbb/bbcode-toolbar
<?php

/**
 * Copyright (C) 2015-2016 FeatherBB
 * based on code by (C) 2008-2012 FluxBB
 * and Rickard Andersson (C) 2002-2008 PunBB
 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 */
namespace FeatherBB\Plugins;

use FeatherBB\Core\AdminUtils;
// Make sure no one attempts to run this script "directly"
if (isset($upgrade_script)) {
    // Check if 'style' folder from version <= 0.2.2 exists
    if (is_dir(__DIR__ . '/style')) {
        AdminUtils::delete_folder(__DIR__ . '/style');
    }
}