Exemplo n.º 1
0
 public function zip()
 {
     if (!CONFIG()->pool_zips) {
         throw new Rails\ActiveRecord\Exception\RecordNotFoundException();
     }
     $pool = Pool::find($this->params()->id);
     $files = $pool->get_zip_data($this->params()->all());
     $zip = new ZipStream($pool->pretty_name() . '.zip');
     foreach ($files as $file) {
         list($path, $filename) = $file;
         $zip->addLargeFile($path, $filename);
     }
     $zip->finalize();
     $this->render(['nothing' => true]);
 }
Exemplo n.º 2
0
ini_set('max_execution_time', 600);
include_once "ZipStream.php";
//print_r(ini_get_all());
$fileTime = date("D, d M Y H:i:s T");
$chapter1 = "Chapter 1\n" . "Lorem ipsum\n" . "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec magna lorem, mattis sit amet porta vitae, consectetur ut eros. Nullam id mattis lacus. In eget neque magna, congue imperdiet nulla. Aenean erat lacus, imperdiet a adipiscing non, dignissim eget felis. Nulla facilisi. Vivamus sit amet lorem eget mauris dictum pharetra. In mauris nulla, placerat a accumsan ac, mollis sit amet ligula. Donec eget facilisis dui. Cras elit quam, imperdiet at malesuada vitae, luctus id orci. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque eu libero in leo ultrices tristique. Etiam quis ornare massa. Donec in velit leo. Sed eu ante tortor.\n";
$zip = new ZipStream("ZipStreamExample1.zip");
$zip->setComment("Example Zip file for Large file sets.\nCreated on " . date('l jS \\of F Y h:i:s A'));
$zip->addFile("Hello World!\r\n", "Hello.txt");
$zip->openStream("big one3.txt");
$zip->addStreamData($chapter1 . "\n\n\n");
$zip->addStreamData($chapter1 . "\n\n\n");
$zip->addStreamData($chapter1 . "\n\n\n");
$zip->closeStream();
// For this test you need to create a large text file called "big one1.txt"
if (file_exists("big one1.txt")) {
    $zip->addLargeFile("big one1.txt", "big one2a.txt");
    $fhandle = fopen("big one1.txt", "rb");
    $zip->addLargeFile($fhandle, "big one2b.txt");
    fclose($fhandle);
}
$zip->addDirectory("Empty Dir");
//Dir test, using the stream option on $zip->addLargeFile
$fileDir = './';
@($handle = opendir($fileDir));
if ($handle) {
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..' && is_file($file)) {
            $zip->addLargeFile($fileDir . $file, "dirTest/" . $file, filectime($fileDir . $file));
        }
    }
Exemplo n.º 3
0
<?php

require_once "../lib/init.php";
protectPage(12);
// Profile pictures privileges
// Get a list of all current members
$q = "SELECT ID FROM Members WHERE WardID={$MEMBER->WardID} AND PictureFile != '' ORDER BY FirstName ASC, LastName ASC";
$r = DB::Run($q);
if (mysql_num_rows($r) == 0) {
    fail("No pictures to export; no members have a profile picture.");
}
$zip = new ZipStream("profile_pics.zip");
while ($row = mysql_fetch_array($r)) {
    $member = Member::Load($row['ID']);
    $file = $member->PictureFile;
    if (file_exists("../uploads/{$file}")) {
        $zip->addLargeFile("../uploads/" . $file, "profile_pictures/" . $file);
    }
}
$zip->finalize();
Exemplo n.º 4
0
 /**
  * Sends all files from a set of rows of a users table to the client.
  * @param string $name name of the database table
  * @param string $rowIds ids of the rows
  */
 public function row($table, array $rowIds)
 {
     // look for the files in the table
     $rowFiles = $this->_getFilesInRow($table, $rowIds);
     if (empty($rowFiles)) {
         throw new Daiquiri_Exception_NotFound();
     }
     // leave some time for the file to be transferred
     ini_set('max_execution_time', 3600);
     // setup zipped transfer
     $fileName = $table . ".zip";
     $zip = new ZipStream($fileName);
     $comment = "All files connected to rows " . implode(", ", $rowIds) . " of table " . $table . " downloaded on " . date('l jS \\of F Y h:i:s A');
     $zip->setComment($comment);
     // look for the files in the file system and stream files
     foreach ($rowFiles as $rowFile) {
         // look for file
         $file = $this->_findFile($rowFile);
         if (empty($file)) {
             continue;
         }
         // zip and stream
         $fhandle = fopen($file, "rb");
         $zip->addLargeFile($fhandle, $rowFile);
         fclose($fhandle);
     }
     $zip->finalize();
 }