예제 #1
0
 /**
  * repository::_write()
  *
  * { Description }
  *
  * @param integer $mode
  */
 function _write($file, $content, $mode = 2)
 {
     $return = lib_write_file($file, $content, $mode);
     switch ($return) {
         case '-1':
         case '-2':
         case '-4':
             return $this->_set_error('0', '1501');
             break;
         case '-3':
         case '-5':
         case '-6':
             return $this->_set_error('0', '1505');
             break;
     }
     return true;
 }
예제 #2
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;
    }
}