reorganize to reduce code depth
This commit is contained in:
parent
bdfdc2a20c
commit
d99ec696b4
|
@ -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) ) {
|
|
||||||
|
$connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
||||||
|
$filename = "zmExport_$connkey.$file_ext";
|
||||||
|
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
||||||
|
ZM\Logger::Debug("downloading archive from $filename_path");
|
||||||
|
if ( is_readable($filename_path) ) {
|
||||||
while (ob_get_level()) {
|
while (ob_get_level()) {
|
||||||
ZM\Logger::Debug('Clearing ob');
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
header("Content-type: application/$mimetype" );
|
header("Content-type: application/$mimetype");
|
||||||
header("Content-Disposition: inline; filename=$filename");
|
header("Content-Disposition: inline; filename=$filename");
|
||||||
header('Content-Length: '.filesize($filename_path));
|
header('Content-Length: '.filesize($filename_path));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
if ( ! @readfile($filename_path) ) {
|
if ( !@readfile($filename_path) ) {
|
||||||
ZM\Error("Error sending $filename_path");
|
ZM\Error("Error sending $filename_path");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ZM\Error("$filename_path does not exist or is not readable.");
|
|
||||||
}
|
|
||||||
} 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