source: extensions/BatchDownloader/download.php @ 27075

Last change on this file since 27075 was 25932, checked in by mistic100, 11 years ago

update for Piwigo 2.6 + code cleaning + fix unable to cancel set during generation

File size: 1.2 KB
RevLine 
[16379]1<?php
2define('PHPWG_ROOT_PATH', '../../');
3include(PHPWG_ROOT_PATH.'include/common.inc.php');
4
[16948]5check_status(ACCESS_GUEST);
[16379]6
[16609]7try {
8  $BatchDownloader = new BatchDownloader($_GET['set_id']);
[25932]9
[23383]10  if ($conf['batch_download']['one_archive'] and $_GET['zip'] == $BatchDownloader->getParam('last_zip'))
[23291]11  {
[23383]12    $file = $BatchDownloader->getArchivePath();
13  }
14  else if (!$conf['batch_download']['one_archive'])
15  {
16    $file = $BatchDownloader->getArchivePath($_GET['zip']);
17  }
[25932]18
[23383]19  if (empty($file) || !file_exists($file))
20  {
[23291]21    throw new Exception('Unable to locate file.');
22  }
[25932]23
[23383]24  if ($conf['batch_download']['direct'])
[23167]25  {
26    header('Location: '.$file);
27  }
28  else
29  {
30    header('Content-Type: application/force-download; name="'.basename($file).'"');
31    header('Content-Disposition: attachment; filename="'.basename($file).'"');
32    header('Content-Description: File Transfer');
33    header('Content-Transfer-Encoding: binary');
34    header('Content-Length: '.filesize($file).'');
[16379]35
[23167]36    header('Cache-Control: no-cache, must-revalidate');
37    header('Pragma: no-cache');
38    header('Expires: 0');
[16379]39
[23167]40    readlargefile($file);
41  }
[16609]42}
43catch (Exception $e)
44{
45  echo $e->getMessage();
46}
[18973]47
[16379]48exit(0);
Note: See TracBrowser for help on using the repository browser.