Пример #1
0
 function exportUploadedFiles($gid)
 {
     require_once "File/Archive.php";
     File_Archive::setOption('zipCompressionLevel', 0);
     $baseDir = CUSTOMER_IMAGE_DIR . $gid;
     $files = list_files_dir($baseDir);
     File_Archive::extract($files, File_Archive::toArchive("campaign_" . $gid . "_uploadedfiles_" . date('dFY') . ".zip", File_Archive::toOutput()));
 }
Пример #2
0
    /**
     * ダウンロードメイン表示クラス
     *
     * @access  public
     */
    function execute()
    {
        $header = <<<EOD
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>NetCommons</title>
</head>
<body>

EOD;
        $footer = <<<EOD
</body>
</html>
EOD;
        require_once "File/Archive.php";
        $dest = File_Archive::toArchive("document.zip", File_Archive::toOutput());
        $dest->newFile("document.html");
        $download_url = "?action=" . $this->download_action . "&upload_id=";
        $count = substr_count($this->content, $download_url);
        if (!$count) {
            $dest->writeData($header . $this->content . $footer);
            $dest->close();
            exit;
        }
        $upload_id = array();
        $files = array();
        $trans = array();
        $parts = explode($download_url, $this->content);
        for ($i = 1; $i <= $count; $i++) {
            $id = substr($parts[$i], 0, strpos($parts[$i], '"'));
            if (!isset($upload_id[$id])) {
                $upload_id[$id] = true;
                list($pathname, $filename, $physical_file_name, $space_type) = $this->uploadsView->downloadCheck($id, null, 0, "common_download_main");
                if ($pathname != null) {
                    $files[] = $pathname . $physical_file_name;
                    $trans[BASE_URL . '/' . $download_url . $id] = "./" . $physical_file_name;
                    $trans[$download_url . $id] = $physical_file_name;
                }
            }
        }
        clearstatcache();
        $dest->writeData($header . strtr($this->content, $trans) . $footer);
        File_Archive::extract($files, $dest);
    }
Пример #3
0
 /**
  * handle export
  */
 private function handleExportGet()
 {
     $request = Request::getInstance();
     if (!$request->exists('id')) {
         throw new Exception('Thema ontbreekt.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id);
     $themedetail = $this->getDetail($key);
     $theme = $this->director->themeManager->getThemeFromId($key);
     $tempPath = $this->director->getTempPath() . "/theme" . session_id();
     $themePath = $themedetail['themePath'];
     $configPath = $theme->getConfigFile();
     mkdir($tempPath);
     Utils::copyRecursive($themePath, $tempPath);
     copy($configPath, $tempPath . "/" . basename($configPath));
     copy($themePath . "/script/ThemeInstaller.php", $tempPath . "/ThemeInstaller.php");
     $filename = sprintf("dif_%s_%s.tar.gz", strtolower($themedetail['classname']), $theme->getVersion());
     File_Archive::extract($tempPath, File_Archive::toArchive($filename, File_Archive::toOutput()));
     Utils::removeRecursive($tempPath);
     exit;
     /*
     $view = ViewManager::getInstance();
     
     $url = new Url(true);
     $url_back = clone $url;
     $url_back->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $template->setVariable('href_back',  $url_back->getUrl(true), false);
     
     $theme->addBreadcrumb(array('name' => $themedetail['name'], 'path' => $url_back->getUrl(true)));
     $theme->addBreadcrumb(array('name' => $view->getName(), 'path' => $url->getUrl(true)));
     
     $this->template[$this->director->theme->getExport()->main_tag] = $template;
     */
 }
<?php

/**
* FIXME ... just fixme, like 99% of it. Count this as a draft or something. 
* 
*  
* 
* @package test
*
* Trying out File_Archive
*/
require_once '../../autoload.php';
try {
    Module::require('File_Archive');
} catch (Exception $e) {
    die('Script requires PEAR File_Archive to work.');
}
// Set cache dir for Cache Lite
$options = array('cacheDir' => 'tmp');
if (Module::isLoaded('Cache_Lite')) {
    File_Archive::setOption('cache', new Cache_Lite($options));
}
File_Archive::setOption('zipCompressionLevel', 0);
// $files is an array of path to the files that must be added to the archive
File_Archive::extract($files, File_Archive::toArchive('myFiles.zip', File_Archive::toOutput()));
Пример #5
0
 /**
  * Execute action when called for explicitly by the user
  *
  * This function also contains the actions available in the interface provided, including file
  * uploading, compressed file extraction and the creation of folders.
  * @return void
  */
 function run()
 {
     global $Templates, $USER, $Controller, $ID, $CONFIG;
     /**
      * User input types
      */
     $_REQUEST->setType('action', 'string');
     $_REQUEST->setType('popup', 'string');
     $_REQUEST->setType('filter', 'string');
     if (!$this->may($USER, READ)) {
         errorPage(401);
     } else {
         if (!in_array($CMPRExtension = $CONFIG->files->compression_format, array('tar', 'gz', 'tgz', 'tbz', 'zip', 'ar', 'deb'))) {
             $CONFIG->files->compression_format = $CMPRExtension = 'zip';
         }
         $render = true;
         switch ($_REQUEST['action']) {
             // All users
             case 'download':
                 global $PREVENT_CSIZE_HEADER;
                 $PREVENT_CSIZE_HEADER = true;
                 while (ob_get_level()) {
                     echo ob_get_clean();
                 }
                 require_once "File/Archive.php";
                 File_Archive::extract($this->path, File_Archive::toArchive($this->filename . '.' . $CMPRExtension, File_Archive::toOutput()));
                 die;
             default:
                 $this->setContent("main", $this->genHTML());
                 break;
         }
         if ($render) {
             $t = 'admin';
             if ($_REQUEST['popup']) {
                 $t = 'popup';
             }
             $Templates->{$t}->render();
         }
     }
 }
Пример #6
0
/**
 * cmdDownloadDoc()
 *
 * @return void
 */
function cmdDownloadDoc()
{
    File_Archive::extract(File_Archive::read(BLOCKEN_DOC_DIR), File_Archive::toArchive('BlockenDoc.zip', File_Archive::toOutput()));
}