public function filedepot_archiver::download in filedepot 7
Same name in this branch
- 7 filedepot_archiver.class.php \filedepot_archiver::download()
- 7 filedepot_archiver.zip.class.php \filedepot_archiver::download()
Download the archive
Parameters
type $errorsInHeaders:
Return value
boolean
File
- ./
filedepot_archiver.zip.class.php, line 211 - filedepot_archiver.class.php Archiving class for filedepot
Class
- filedepot_archiver
- @file filedepot_archiver.class.php Archiving class for filedepot
Code
public function download($errorsInHeaders = FALSE) {
set_time_limit(0);
ob_end_clean();
// are you kidding me
if (file_exists($this->zipFileName) === FALSE) {
$file_exists = FALSE;
$file_size = 0;
$error_code = 1;
}
else {
$file_exists = TRUE;
$error_code = 0;
$file_size = filesize($this->zipFileName);
}
$headers = array(
'Content-Type: application/x-zip-compressed; name="filedepot_archive.zip"',
'Content-Length: ' . $file_size,
'Content-Disposition: attachment; filename="filedepot_archive.zip"',
'Cache-Control: private',
'Pragma: no-cache',
'Expires: 0',
"Content-Transfer-Encoding: binary",
'Error-Code: ' . $error_code,
'FileSize: ' . $file_size,
);
// This has to be manually done so we can still show error header information
/*foreach ($headers as $value) {
//drupal_add_http_header($name, $value);
header($value);
}*/
header('Pragma: public');
// required
header('Expires: 0');
// no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($this->zipFileName)) . ' GMT'); // commented out because fails on system for messed up reason
header('Cache-Control: private', false);
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=ziparchive.zip"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $file_size);
// provide file size
header('Connection: close');
if ($file_exists === TRUE) {
set_time_limit(0);
$file = @fopen($this->zipFileName, "rb");
while (!feof($file)) {
print @fread($file, 1024 * 8);
ob_flush();
flush();
}
exit;
}
else {
echo "";
}
drupal_exit();
}