Merge branch 'add_export_to_filter' of github.com:/connortechnology/ZoneMinder into add_export_to_filter

pull/2158/head
Isaac Connor 2018-09-25 14:57:13 -04:00
commit 6aaa0fe39f
5 changed files with 58 additions and 30 deletions

View File

@ -39,7 +39,8 @@ if ( canView('Events') ) {
{
require_once(ZM_SKIN_PATH.'/includes/export_functions.php');
# We use session vars in here, so we need to restart the session because we stopped it in index.php to improve concurrency.
# We use session vars in here, so we need to restart the session
# because we stopped it in index.php to improve concurrency.
session_start();
if ( !empty($_REQUEST['exportDetail']) )
@ -72,6 +73,11 @@ if ( canView('Events') ) {
else
$exportFormat = '';
if ( !empty($_REQUEST['exportCompress']) )
$exportCompress = $_SESSION['export']['compress'] = $_REQUEST['exportCompress'];
else
$exportCompress = false;
session_write_close();
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
@ -83,7 +89,8 @@ if ( canView('Events') ) {
$exportImages,
$exportVideo,
$exportMisc,
$exportFormat
$exportFormat,
$exportCompress
) )
ajaxResponse(array('exportFile'=>$exportFile));
else
@ -100,7 +107,8 @@ if ( canView('Events') ) {
if ( $exportFile = exportEvents(
$exportIds,
(isset($_REQUEST['connkey'])?$_REQUEST['connkey']:''),
false,false, false, $exportVideo, false, $exportFormat, $exportStructure ) )
false,false, false,
$exportVideo, false, $exportFormat, $exportStructure ) )
ajaxResponse(array('exportFile'=>$exportFile));
else
ajaxError('Export Failed');

View File

@ -323,6 +323,7 @@ $SLANG = array(
'Events' => 'Events',
'Exclude' => 'Exclude',
'Execute' => 'Execute',
'ExportCompress' => 'Use Compression',
'ExportDetails' => 'Export Event Details',
'ExportMatches' => 'Export Matches',
'Exif' => 'Embed EXIF data into image',

View File

@ -826,6 +826,7 @@ function exportEvents(
$exportVideo,
$exportMisc,
$exportFormat,
$exportCompressed,
$exportStructure = false
) {
@ -912,28 +913,30 @@ function exportEvents(
chdir(ZM_DIR_EXPORTS);
$archive = '';
if ( $exportFormat == 'tar' ) {
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar.gz';
@unlink($archive);
$command = 'nice -10 tar --create --gzip --dereference --file='.escapeshellarg($archive).' zmExport_'.$connkey.'/';
#$command = 'nice -10 tar --create --gzip --file='.escapeshellarg($archive).' --files-from='.escapeshellarg($listFile);
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar';
$command = 'tar --create --dereference';
if ( $exportCompressed ) {
$archive .= '.gz';
$command .= ' --gzip';
$exportFormat .= '.gz';
}
if ( $exportStructure == 'flat' ) {
//strip file paths if we
$command .= " --xform='s#^.+/##x'";
}
$command .= ' --file='.escapeshellarg($archive);
} elseif ( $exportFormat == 'zip' ) {
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.zip';
@unlink($archive);
if ( $exportStructure == 'flat' ) {
$command = 'nice -10 zip -j '.escapeshellarg($archive).' zmExport_'.$connkey.'/';
#$command = 'cat '.escapeshellarg($listFile).' | nice -10 zip -q -j '.escapeshellarg($archive).' -@';
} else {
$command = 'nice -10 zip -r '.escapeshellarg($archive).' zmExport_' . $connkey.'/';
#$command = 'cat '.escapeshellarg($listFile).' | nice -10 zip -q '.escapeshellarg($archive).' -@';
}
$command = 'zip ';
$command = ($exportStructure == 'flat' ? ' -j ' : ' -r ' ).escapeshellarg($archive);
$command .= $exportCompressed ? ' -9' : ' -0';
} else {
Error("No exportFormat specified.");
return false;
} // if $exportFormat
@unlink($archive);
$command .= ' zmExport_' . $connkey.'/';
Logger::Debug("Command is $command");
exec($command, $output, $status);
if ( $status ) {

View File

@ -36,18 +36,21 @@ if ( isset($_SESSION['export']) ) {
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
if ( isset($_SESSION['export']['format']) )
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
if ( isset($_SESSION['export']['compress']) )
$_REQUEST['exportCompress'] = $_SESSION['export']['compress'];
} else {
$_REQUEST['exportDetail'] =
$_REQUEST['exportFrames'] =
$_REQUEST['exportImages'] =
$_REQUEST['exportVideo'] =
$_REQUEST['exportMisc'] = 1;
$_REQUEST['exportCompress'] = 0;
}
$focusWindow = true;
$connkey = isset($_REQUEST['connkey']) ? $_REQUEST['connkey'] : generateConnKey();
xhtmlHeaders(__FILE__, translate('Export') );
xhtmlHeaders(__FILE__, translate('Export'));
?>
<body>
<div id="page">
@ -74,11 +77,11 @@ if ( $user['MonitorIds'] ) {
}
if ( isset($_REQUEST['eid']) and $_REQUEST['eid'] ) {
Logger::Debug("Loading events by single eid");
Logger::Debug('Loading events by single eid');
$eventsSql .= ' AND E.Id=?';
$eventsValues[] = $_REQUEST['eid'];
} elseif ( isset($_REQUEST['eids']) and count($_REQUEST['eids']) > 0 ) {
Logger::Debug("Loading events by eids");
Logger::Debug('Loading events by eids');
$eventsSql .= ' AND E.Id IN ('.implode(',', array_map(function(){return '?';}, $_REQUEST['eids'])). ')';
$eventsValues += $_REQUEST['eids'];
} else if ( isset($_REQUEST['filter']) ) {
@ -100,17 +103,17 @@ $disk_space_total = 0;
<table id="contentTable" class="major">
<thead>
<tr>
<th class="colId"><a href="<?php echo sortHeader('Id') ?>"><?php echo translate('Id') ?><?php echo sortTag( 'Id' ) ?></a></th>
<th class="colName"><a href="<?php echo sortHeader('Name') ?>"><?php echo translate('Name') ?><?php echo sortTag( 'Name' ) ?></a></th>
<th class="colMonitor"><a href="<?php echo sortHeader('MonitorName') ?>"><?php echo translate('Monitor') ?><?php echo sortTag( 'MonitorName' ) ?></a></th>
<th class="colCause"><a href="<?php echo sortHeader('Cause') ?>"><?php echo translate('Cause') ?><?php echo sortTag( 'Cause' ) ?></a></th>
<th class="colTime"><a href="<?php echo sortHeader('StartTime') ?>"><?php echo translate('Time') ?><?php echo sortTag( 'StartTime' ) ?></a></th>
<th class="colDuration"><a href="<?php echo sortHeader('Length') ?>"><?php echo translate('Duration') ?><?php echo sortTag( 'Length' ) ?></a></th>
<th class="colFrames"><a href="<?php echo sortHeader('Frames') ?>"><?php echo translate('Frames') ?><?php echo sortTag( 'Frames' ) ?></a></th>
<th class="colAlarmFrames"><a href="<?php echo sortHeader('AlarmFrames') ?>"><?php echo translate('AlarmBrFrames') ?><?php echo sortTag( 'AlarmFrames' ) ?></a></th>
<th class="colTotScore"><a href="<?php echo sortHeader('TotScore') ?>"><?php echo translate('TotalBrScore') ?><?php echo sortTag( 'TotScore' ) ?></a></th>
<th class="colAvgScore"><a href="<?php echo sortHeader('AvgScore') ?>"><?php echo translate('AvgBrScore') ?><?php echo sortTag( 'AvgScore' ) ?></a></th>
<th class="colMaxScore"><a href="<?php echo sortHeader('MaxScore') ?>"><?php echo translate('MaxBrScore') ?><?php echo sortTag( 'MaxScore' ) ?></a></th>
<th class="colId"><a href="<?php echo sortHeader('Id') ?>"><?php echo translate('Id') ?><?php echo sortTag('Id') ?></a></th>
<th class="colName"><a href="<?php echo sortHeader('Name') ?>"><?php echo translate('Name') ?><?php echo sortTag('Name') ?></a></th>
<th class="colMonitor"><a href="<?php echo sortHeader('MonitorName') ?>"><?php echo translate('Monitor') ?><?php echo sortTag('MonitorName') ?></a></th>
<th class="colCause"><a href="<?php echo sortHeader('Cause') ?>"><?php echo translate('Cause') ?><?php echo sortTag('Cause') ?></a></th>
<th class="colTime"><a href="<?php echo sortHeader('StartTime') ?>"><?php echo translate('Time') ?><?php echo sortTag('StartTime') ?></a></th>
<th class="colDuration"><a href="<?php echo sortHeader('Length') ?>"><?php echo translate('Duration') ?><?php echo sortTag('Length') ?></a></th>
<th class="colFrames"><a href="<?php echo sortHeader('Frames') ?>"><?php echo translate('Frames') ?><?php echo sortTag('Frames') ?></a></th>
<th class="colAlarmFrames"><a href="<?php echo sortHeader('AlarmFrames') ?>"><?php echo translate('AlarmBrFrames') ?><?php echo sortTag('AlarmFrames') ?></a></th>
<th class="colTotScore"><a href="<?php echo sortHeader('TotScore') ?>"><?php echo translate('TotalBrScore') ?><?php echo sortTag('TotScore') ?></a></th>
<th class="colAvgScore"><a href="<?php echo sortHeader('AvgScore') ?>"><?php echo translate('AvgBrScore') ?><?php echo sortTag('AvgScore') ?></a></th>
<th class="colMaxScore"><a href="<?php echo sortHeader('MaxScore') ?>"><?php echo translate('MaxBrScore') ?><?php echo sortTag('MaxScore') ?></a></th>
<?php
if ( ZM_WEB_EVENT_DISK_SPACE ) {
?>
@ -185,6 +188,15 @@ while ( $event_row = dbFetchNext($results) ) {
<input type="radio" id="exportFormatZip" name="exportFormat" value="zip"<?php if ( isset($_REQUEST['exportFormat']) && $_REQUEST['exportFormat'] == "zip" ) { ?> checked="checked"<?php } ?> onclick="configureExportButton( this )"/><label for="exportFormatZip"><?php echo translate('ExportFormatZip') ?></label>
</td>
</tr>
<tr>
<th scope="row"><?php echo translate('ExportCompress') ?></th>
<td>
<input type="radio" id="exportCompress1" name="exportCompress" value="1"<?php echo ( isset($_REQUEST['exportCompress']) && $_REQUEST['exportCompress'] ) ? ' checked="checked"' : '' ?> onclick="configureExportButton(this)"/>
<label for="exportCompress1"><?php echo translate('Yes') ?></label>
<input type="radio" id="exportCompress0" name="exportCompress" value="0"<?php echo ( isset($_REQUEST['exportCompress']) && $_REQUEST['exportCompress'] ) ? '' : ' checked="checked"' ?> onclick="configureExportButton(this)"/>
<label for="exportCompress0"><?php echo translate('No') ?></label>
</td>
</tr>
</tbody>
</table>
<button type="button" id="exportButton" name="exportButton" value="Export" onclick="exportEvent(this.form);" disabled="disabled"><?php echo translate('Export') ?></button>

View File

@ -28,10 +28,14 @@ $connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
if ( $archivetype ) {
switch ($archivetype) {
case 'tar':
case 'tar.gz':
$mimetype = 'gzip';
$file_ext = 'tar.gz';
break;
case 'tar':
$mimetype = 'tar';
$file_ext = 'tar';
break;
case 'zip':
$mimetype = 'zip';
$file_ext = 'zip';