source: extensions/BatchDownloader/download.php @ 28145

Last change on this file since 28145 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
Line 
1<?php
2define('PHPWG_ROOT_PATH', '../../');
3include(PHPWG_ROOT_PATH.'include/common.inc.php');
4
5check_status(ACCESS_GUEST);
6
7try {
8  $BatchDownloader = new BatchDownloader($_GET['set_id']);
9
10  if ($conf['batch_download']['one_archive'] and $_GET['zip'] == $BatchDownloader->getParam('last_zip'))
11  {
12    $file = $BatchDownloader->getArchivePath();
13  }
14  else if (!$conf['batch_download']['one_archive'])
15  {
16    $file = $BatchDownloader->getArchivePath($_GET['zip']);
17  }
18
19  if (empty($file) || !file_exists($file))
20  {
21    throw new Exception('Unable to locate file.');
22  }
23
24  if ($conf['batch_download']['direct'])
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).'');
35
36    header('Cache-Control: no-cache, must-revalidate');
37    header('Pragma: no-cache');
38    header('Expires: 0');
39
40    readlargefile($file);
41  }
42}
43catch (Exception $e)
44{
45  echo $e->getMessage();
46}
47
48exit(0);
Note: See TracBrowser for help on using the repository browser.