} else {
                         if ($action == 'info') {
                             // checks if a preview can be done and the file size is returned.
                             tfu_info($file);
                         } else {
                             if ($action == 'text') {
                                 // get infos about a file
                                 tfu_text($file);
                             } else {
                                 if ($action == 'savetext') {
                                     // save a textfile
                                     tfu_savetext($file);
                                 } else {
                                     if ($action == 'download') {
                                         // download a file - we set the header !
                                         tfu_download($file, $enable_file_download);
                                     } else {
                                         if ($action == 'zipdownload') {
                                             // download multipe files as zip!
                                             tfu_zip_download($file, $enable_file_download);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 } else {
function tfu_zip_download($files, $enable_file_download)
{
    global $zip_folder;
    // The folder is used to create the temp download files!
    if ($enable_file_download == 'false' && !isset($_GET['fullscreen'])) {
        echo 'This action is not enabled!';
        exit(0);
    }
    $createZip = new createZip();
    $nrfiles = count($files);
    for ($i = 0; $i < $nrfiles; $i++) {
        $createZip->addFile(file_get_contents($files[$i]), my_basename($files[$i]));
    }
    $fileName = $zip_folder . '/' . $_GET['zipname'];
    $fd = fopen($fileName, "wb");
    $out = fwrite($fd, $createZip->getZippedfile());
    fclose($fd);
    tfu_download($fileName, $enable_file_download);
    @unlink($fileName);
}
Example #3
0
function tfu_zip_download($files, $enable_file_download)
{
    global $zip_folder, $zip_file_pattern;
    // The folder is used to create the temp download files!
    if ($enable_file_download == 'false' && !isset($_GET['fullscreen'])) {
        echo 'This action is not enabled!';
        exit(0);
    }
    /*
    $createZip = new createZip;
    $nrfiles = count($files);
    for ($i = 0; $i < $nrfiles; $i++) {
      $createZip -> addFile(file_get_contents($files[$i]), my_basename($files[$i]));
    }
    $fileName = $zip_folder . '/' . $_GET['zipname'];
    $fd = fopen ($fileName, "wb");
    $out = fwrite ($fd, $createZip -> getZippedfile());
    fclose ($fd);
    */
    $nrfiles = count($files);
    if ($zip_file_pattern == '') {
        $zipName = parseInputParameterFile(trim(my_basename(' ' . $_GET['zipname'])));
        // fixes that file can be renamed to an upper dir.
        $fileName = $zip_folder . '/' . $zipName;
    } else {
        // zip file pattern can have the following patterns {folder}, {number}, {date} e.g. "download-{number}-files_{date}.zip"
        // but here I only use {number} and {date} because this is enough to be unique. The filename itself is build in the flash.
        $newName = str_replace('{number}', $nrfiles, $zip_file_pattern);
        $newName = str_replace('{date}', date("Y-m-d"), $newName);
        $fileName = $zip_folder . '/' . $newName;
    }
    if (!is_writeable($zip_folder)) {
        tfu_debug("ERROR: The folder '" . $zip_folder . "' is not writeable. Please set the permissions properly to enable the download of multiple files.");
    }
    $fd = @fopen($fileName, "wb");
    if ($fd) {
        $createZip = new TFUZipFile($fd);
        for ($i = 0; $i < $nrfiles; $i++) {
            $createZip->addFile($files[$i], my_basename($files[$i]));
        }
        $createZip->close();
        tfu_download($fileName, $enable_file_download);
        @unlink($fileName);
    } else {
        tfu_debug("ERROR: The file '" . $fileName . "' could not be created. Please set the permissions properly to enable the download of multiple files.");
    }
}