Example #1
0
function plug_download($idplug, $idclient, $_zip = false, $_name = false, $_ext = false)
{
    global $rep, $cfg_cms, $sess;
    $plugin = $rep->plug_data($idplug, $idclient);
    // todo:zlib abfrage + popup
    if (is_array($plugin)) {
        // Event
        $zip = false;
        require_once "Archive/Tar.php";
        $xmlstring = $rep->plug_generate($plugin);
        $name = $_name == '' ? $plugin['root_name'] : trim($_name);
        $zip = $cfg_cms['gzip_enabled'] == true && $_zip == true ? true : false;
        if ($zip === true && ($_ext == 'tar' || $_ext == 'tgz')) {
            $_ext = 'tgz';
        } elseif ($zip === false && ($_ext == 'tar' || $_ext == 'tgz')) {
            $_ext = 'tar';
        } else {
            $_ext = 'cmsplugin';
        }
        $_mtype = $zip === true ? 'application/x-compressed' : 'application/x-tar';
        $file = $cfg_cms['cms_path'] . 'upload/' . 'out/' . $name . '.' . $_ext;
        $download = $cfg_cms['cms_html_path'] . 'upload/' . 'out/' . $name . '.' . $_ext;
        lib_write_file($cfg_cms['cms_path'] . 'plugins/' . $name . '/' . $name . '.cmsplug', $xmlstring);
        if (false == ($tar = new Archive_Tar($file, $zip))) {
            return '1615';
        } elseif ($tar == '-1' && $zip == true) {
            return plug_download($idplug, $idclient, false, $_name, $_ext);
        }
        $old_working_dir = getcwd();
        chdir($cfg_cms['cms_path'] . 'plugins/');
        $tar->create(trim($name));
        chdir($old_working_dir);
        ob_end_clean();
        header('Content-Type: ' . $_mtype);
        header('Content-Transfer-Encoding: binary');
        header('Content-Description: Download Data');
        header('Content-Length: ' . filesize($file));
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Expires: 0');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
        //old function: header('Location:' . $download);
        readfile($file);
        fire_event('plug_download', array('idplug' => $idplug, 'name' => $name));
        lib_delete_file($file);
        exit;
    }
}
Example #2
0
     // Konfiguration speichern
     $perm->check(4, 'plug', $idplug);
     $config = make_array_to_urlstring($PLUG_VAR);
     $errno = plug_save_config($idplug, $config, $plug_config_overwrite_all);
     if (isset($_REQUEST['sf_apply'])) {
         header('Location:' . $sess->urlRaw("main.php?area=plug_config&idplug={$idplug}&idclient={$idclient}"));
         exit;
     }
     break;
 case 'download':
     // Plugin downloaden
     $perm->check(10, 'plug', $idplug);
     $gzip = !$nogzip && $type != 'tar' ? true : false;
     $name = empty($name) ? false : urldecode($name);
     $type = empty($type) ? false : trim($type);
     $errno = plug_download($idplug, $idclient, $gzip, $name, $type);
     break;
 case 'upload':
     // Plugin hochladen
     $perm->check(9, 'plug', $idplug);
     if ($override == 'false') {
         if ($sess->is_registered('s_update')) {
             $sess->unregister('s_update');
         }
         $errno = '1618';
         break;
     } else {
         list($errno, $errmsg) = plug_upload($idclient, $override);
     }
     if ($errno == '1617') {
         // Plugin Update?