コード例 #1
0
ファイル: FileBrowser.php プロジェクト: varvanin/currycms
 /**
  * Download file.
  */
 public function showDownload()
 {
     $paths = (array) $_GET['path'];
     $zip = count($paths) > 1;
     $physicals = array();
     foreach ($paths as $path) {
         $physical = self::virtualToPhysical($path);
         $physicals[] = $physical;
         if (is_dir($physical)) {
             $zip = true;
         }
     }
     $name = 'files.zip';
     if (count($physicals) === 1) {
         $name = basename($physicals[0]) . ($zip ? '.zip' : '');
     }
     if ($zip) {
         require_once 'pclzip/pclzip.lib.php';
         $tempfile = tempnam(Curry_Core::$config->curry->tempPath, "curry-download");
         $archive = new PclZip($tempfile);
         if (!$archive->create($physicals, PCLZIP_OPT_REMOVE_PATH, dirname($physicals[0]))) {
             $this->addMessage('Unable to create zip.');
             if (file_exists($tempfile)) {
                 @unlink($tempfile);
             }
         } else {
             Curry_Application::returnFile($tempfile, 'application/octet-stream', $name, false);
             @unlink($tempfile);
             exit;
         }
     } else {
         Curry_Application::returnFile($physicals[0], 'application/octet-stream', $name);
     }
 }
コード例 #2
0
ファイル: Module.php プロジェクト: varvanin/currycms
 /**
  * Return partial a file to browser and exit. Will set appropriate headers and return the content.
  * 
  * @deprecated Please use Curry_Application::returnPartial() instead.
  *
  * @param string $file
  * @param string $contentType
  * @param string $filename
  */
 public function returnFile($file, $contentType, $filename)
 {
     trace_warning('DEPRECATED: ' . __CLASS__ . '::' . __METHOD__ . '(), please use Curry_Application::' . __METHOD__ . '() instead.');
     Curry_Application::returnFile($file, $contentType, $filename);
 }