2017-05-17 23:30:39 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder file view file, $Date: 2008-09-29 14:15:13 +0100 (Mon, 29 Sep 2008) $, $Revision: 2640 $
|
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
|
2018-05-18 21:52:30 +08:00
|
|
|
if ( !canView('Events') ) {
|
2018-01-25 05:21:43 +08:00
|
|
|
$view = 'error';
|
|
|
|
return;
|
2017-05-17 23:30:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$archivetype = $_REQUEST['type'];
|
2018-07-10 00:02:05 +08:00
|
|
|
$connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
2017-05-17 23:30:39 +08:00
|
|
|
|
|
|
|
if ( $archivetype ) {
|
2018-01-25 05:21:43 +08:00
|
|
|
switch ($archivetype) {
|
2018-09-07 21:08:33 +08:00
|
|
|
case 'tar.gz':
|
2018-01-25 05:21:43 +08:00
|
|
|
$mimetype = 'gzip';
|
|
|
|
$file_ext = 'tar.gz';
|
|
|
|
break;
|
2018-09-07 21:08:33 +08:00
|
|
|
case 'tar':
|
|
|
|
$mimetype = 'tar';
|
|
|
|
$file_ext = 'tar';
|
|
|
|
break;
|
2018-01-25 05:21:43 +08:00
|
|
|
case 'zip':
|
|
|
|
$mimetype = 'zip';
|
|
|
|
$file_ext = 'zip';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$mimetype = NULL;
|
|
|
|
$file_ext = NULL;
|
|
|
|
}
|
2017-05-17 23:30:39 +08:00
|
|
|
|
2018-01-25 05:21:43 +08:00
|
|
|
if ( $mimetype ) {
|
2018-07-10 00:02:05 +08:00
|
|
|
$filename = "zmExport_$connkey.$file_ext";
|
2018-01-25 05:21:43 +08:00
|
|
|
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
2018-05-18 21:52:30 +08:00
|
|
|
Logger::Debug("downloading archive from $filename_path");
|
2018-01-25 05:21:43 +08:00
|
|
|
if ( is_readable($filename_path) ) {
|
2018-09-21 02:41:13 +08:00
|
|
|
ob_clean();
|
2018-05-18 21:52:30 +08:00
|
|
|
header("Content-type: application/$mimetype" );
|
|
|
|
header("Content-Disposition: inline; filename=$filename");
|
|
|
|
header('Content-Length: ' . filesize($filename_path) );
|
2018-01-25 05:21:43 +08:00
|
|
|
set_time_limit(0);
|
2018-07-10 00:02:05 +08:00
|
|
|
if ( ! @readfile($filename_path) ) {
|
2018-05-18 21:52:30 +08:00
|
|
|
Error("Error sending $filename_path");
|
|
|
|
}
|
2017-05-17 23:30:39 +08:00
|
|
|
} else {
|
2018-01-25 05:21:43 +08:00
|
|
|
Error("$filename_path does not exist or is not readable.");
|
2017-05-17 23:30:39 +08:00
|
|
|
}
|
2018-01-25 05:21:43 +08:00
|
|
|
} else {
|
|
|
|
Error("Unsupported archive type specified. Supported archives are tar and zip");
|
|
|
|
}
|
2017-05-17 23:30:39 +08:00
|
|
|
} else {
|
2018-01-25 05:21:43 +08:00
|
|
|
Error("No archive type given to archive.php. Please specify a tar or zip archive.");
|
2017-05-17 23:30:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|