reorganize to reduce code depth
This commit is contained in:
parent
775b0d1ccd
commit
496fd6b15a
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// ZoneMinder file view file, $Date: 2008-09-29 14:15:13 +0100 (Mon, 29 Sep 2008) $, $Revision: 2640 $
|
// ZoneMinder file view file
|
||||||
// Copyright (C) 2001-2008 Philip Coombes
|
// Copyright (C) 2001-2008 Philip Coombes
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
|
@ -23,11 +23,13 @@ if ( !canView('Events') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$archivetype = $_REQUEST['type'];
|
$archivetype = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
|
||||||
$connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
if ( !$archivetype ) {
|
||||||
|
ZM\Error('No archive type given to archive.php. Please specify a tar or zip archive.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $archivetype ) {
|
switch ($archivetype) {
|
||||||
switch ($archivetype) {
|
|
||||||
case 'tar.gz':
|
case 'tar.gz':
|
||||||
$mimetype = 'gzip';
|
$mimetype = 'gzip';
|
||||||
$file_ext = 'tar.gz';
|
$file_ext = 'tar.gz';
|
||||||
|
@ -43,31 +45,29 @@ if ( $archivetype ) {
|
||||||
default:
|
default:
|
||||||
$mimetype = NULL;
|
$mimetype = NULL;
|
||||||
$file_ext = NULL;
|
$file_ext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $mimetype ) {
|
if ( !$mimetype ) {
|
||||||
$filename = "zmExport_$connkey.$file_ext";
|
ZM\Error('Unsupported archive type specified. Supported archives are tar and zip');
|
||||||
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
return;
|
||||||
ZM\Logger::Debug("downloading archive from $filename_path");
|
}
|
||||||
if ( is_readable($filename_path) ) {
|
|
||||||
while (ob_get_level()) {
|
$connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
||||||
ZM\Logger::Debug('Clearing ob');
|
$filename = "zmExport_$connkey.$file_ext";
|
||||||
ob_end_clean();
|
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
||||||
}
|
ZM\Logger::Debug("downloading archive from $filename_path");
|
||||||
header("Content-type: application/$mimetype" );
|
if ( is_readable($filename_path) ) {
|
||||||
header("Content-Disposition: inline; filename=$filename");
|
while (ob_get_level()) {
|
||||||
header('Content-Length: '.filesize($filename_path));
|
ob_end_clean();
|
||||||
set_time_limit(0);
|
}
|
||||||
if ( ! @readfile($filename_path) ) {
|
header("Content-type: application/$mimetype");
|
||||||
ZM\Error("Error sending $filename_path");
|
header("Content-Disposition: inline; filename=$filename");
|
||||||
}
|
header('Content-Length: '.filesize($filename_path));
|
||||||
} else {
|
set_time_limit(0);
|
||||||
ZM\Error("$filename_path does not exist or is not readable.");
|
if ( !@readfile($filename_path) ) {
|
||||||
}
|
ZM\Error("Error sending $filename_path");
|
||||||
} else {
|
|
||||||
ZM\Error('Unsupported archive type specified. Supported archives are tar and zip');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ZM\Error('No archive type given to archive.php. Please specify a tar or zip archive.');
|
ZM\Error($filename_path.' does not exist or is not readable.');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue