public function download($req, $res, $args)
    {
        $repoList = Container::get('remote')->getExtensionsInfoList();
        // not care about indexes, simple retrieve twice
        // get category
        $category = Utils::recursiveArraySearch($args['name'], $repoList);
        // get plugin
        $plugKey = Utils::recursiveArraySearch($args['name'], $repoList[$category]);
        $plug = $repoList[$category][$plugKey];

        return View::setPageInfo([
            'admin_console' => true,
            'active_page' => 'admin',
//            'key' => $args['name'],
            'package' => $plug['package'],
            'stability' => $plug['stability'],
            'category' => $category,
            'pluginInfo' => base64_encode(json_encode($plug)),
            'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Extension')],
        ])->display('@forum/misc/modal', false);
/*
        $zipFile = ForumEnv::get('FORUM_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('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip = new ZipArchive;

        if ($zip->open($zipFile) != true) {
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip->extractTo(ForumEnv::get('FORUM_ROOT') . 'plugins');
        $zip->close();

        if (file_exists(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'])) {
            AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        }
        rename(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'], ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        unlink(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');

        return Router::redirect(Router::pathFor('adminPlugins'), 'Plugin downloaded!');
*/
    }
public function download($req, $res, $args)
    {
        $repoList = Container::get('remote')->getExtensionsInfoList();
        // not care about indexes, simple retrieve twice
        // get category
        $category = Utils::recursiveArraySearch($args['name'], $repoList);
        // get plugin
        $plugKey = Utils::recursiveArraySearch($args['name'], $repoList[$category]);
        $plug = $repoList[$category][$plugKey];

        return View::setPageInfo([
            'admin_console' => true,
            'active_page' => 'admin',
//            'key' => $args['name'],
            'package' => $plug['package'],
            'stability' => $plug['stability'],
            'category' => $category,
            'pluginInfo' => base64_encode(json_encode($plug)),
            'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Extension')],
        ])->display('@forum/misc/modal', false);
/*
        $zipFile = ForumEnv::get('FORUM_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('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip = new ZipArchive;

        if ($zip->open($zipFile) != true) {
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip->extractTo(ForumEnv::get('FORUM_ROOT') . 'plugins');
        $zip->close();

        if (file_exists(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'])) {
            AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        }
        rename(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'], ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        unlink(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');

        return Router::redirect(Router::pathFor('adminPlugins'), 'Plugin downloaded!');
*/
    }
public function download ( $ req , $ res , $ args ) { $ repoList = Container :: get ( 'remote' ) -> getExtensionsInfoList ( ) ; // not care about indexes, simple retrieve twice // get category $ category = Utils :: recursiveArraySearch ( $ args [ 'name' ] , $ repoList ) ; // get plugin $ plugKey = Utils :: recursiveArraySearch ( $ args [ 'name' ] , $ repoList [ $ category ] ) ; $ plug = $ repoList [ $ category ] [ $ plugKey ] ; return View :: setPageInfo ( [ 'admin_console' => true , 'active_page' => 'admin' , //            'key' => $args['name'], 'package' => $ plug [ 'package' ] , 'stability' => $ plug [ 'stability' ] , 'category' => $ category , 'pluginInfo' => base64_encode ( json_encode ( $ plug ) ) , 'title' => [ Utils :: escape ( ForumSettings :: get ( 'o_board_title' ) ) , __ ( 'Admin' ) , __ ( 'Extension' ) ] , ] ) -> display ( '@forum/misc/modal' , false ) ; /*
        $zipFile = ForumEnv::get('FORUM_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('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip = new ZipArchive;

        if ($zip->open($zipFile) != true) {
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip->extractTo(ForumEnv::get('FORUM_ROOT') . 'plugins');
        $zip->close();

        if (file_exists(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'])) {
            AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        }
        rename(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'], ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        unlink(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');

        return Router::redirect(Router::pathFor('adminPlugins'), 'Plugin downloaded!');
*/ }
Download a plugin, unzip it and rename it
@param $req
@param $res
@param $args
@return mixed
@throws RunBBException
Download a plugin unzip it and rename it