Changeset 23167


Ignore:
Timestamp:
Jun 13, 2013, 12:19:50 PM (11 years ago)
Author:
mistic100
Message:

replace readfile by readlargefile, add advanced parameter to use http redirection instead of php download

Location:
extensions/BatchDownloader
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/download.php

    r18973 r23167  
    88  $BatchDownloader = new BatchDownloader($_GET['set_id']);
    99  $file = $BatchDownloader->getArchivePath();
     10 
     11  if (isset($conf['batch_download_direct']) and $conf['batch_download_direct'])
     12  {
     13    header('Location: '.$file);
     14  }
     15  else
     16  {
     17    header('Content-Type: application/force-download; name="'.basename($file).'"');
     18    header('Content-Disposition: attachment; filename="'.basename($file).'"');
     19    header('Content-Description: File Transfer');
     20    header('Content-Transfer-Encoding: binary');
     21    header('Content-Length: '.filesize($file).'');
    1022
    11   header('Content-Type: application/force-download; name="'.basename($file).'"');
    12   header('Content-Disposition: attachment; filename="'.basename($file).'"');
    13   header('Content-Description: File Transfer');
    14   header('Content-Transfer-Encoding: binary');
    15   header('Content-Length: '.filesize($file).'');
     23    header('Cache-Control: no-cache, must-revalidate');
     24    header('Pragma: no-cache');
     25    header('Expires: 0');
    1626
    17   header('Cache-Control: no-cache, must-revalidate');
    18   header('Pragma: no-cache');
    19   header('Expires: 0');
    20 
    21   readfile($file);
     27    readlargefile($file);
     28  }
    2229}
    2330catch (Exception $e)
  • extensions/BatchDownloader/include/functions.inc.php

    r16592 r23167  
    101101}
    102102
     103// https://bugs.php.net/bug.php?id=61636
     104function readlargefile($fullfile)
     105{
     106  $fp = fopen($fullfile, 'rb');
     107
     108  if ($fp)
     109  {
     110    while (!feof($fp))
     111    {
     112      print(fread($fp, 2097152));
     113    }
     114
     115    fclose($fp);
     116  }
     117}
     118
    103119?>
  • extensions/BatchDownloader/main.inc.php

    r18973 r23167  
    88Author URI: http://www.strangeplanet.fr
    99*/
     10
     11/*
     12 * advanced config:
     13 * $conf['batch_download_max_elements']  max value of the elements slider (default 1000)
     14 * $conf['batch_download_max_size']      max value of the size slider (default 500)
     15 * $conf['batch_download_force_pclzip']  if true, force the usage of PclZip instead of ZipArchive
     16 * $conf['batch_download_direct']        if true, the download script will redirect to the zip instead of deliver it through PHP
     17 */
    1018
    1119defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
Note: See TracChangeset for help on using the changeset viewer.