Merge branch 'add_export_to_filter' of github.com:/connortechnology/ZoneMinder into add_export_to_filter
commit
6aaa0fe39f
|
@ -39,7 +39,8 @@ if ( canView('Events') ) {
|
||||||
{
|
{
|
||||||
require_once(ZM_SKIN_PATH.'/includes/export_functions.php');
|
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();
|
session_start();
|
||||||
|
|
||||||
if ( !empty($_REQUEST['exportDetail']) )
|
if ( !empty($_REQUEST['exportDetail']) )
|
||||||
|
@ -72,6 +73,11 @@ if ( canView('Events') ) {
|
||||||
else
|
else
|
||||||
$exportFormat = '';
|
$exportFormat = '';
|
||||||
|
|
||||||
|
if ( !empty($_REQUEST['exportCompress']) )
|
||||||
|
$exportCompress = $_SESSION['export']['compress'] = $_REQUEST['exportCompress'];
|
||||||
|
else
|
||||||
|
$exportCompress = false;
|
||||||
|
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
|
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
|
||||||
|
@ -83,7 +89,8 @@ if ( canView('Events') ) {
|
||||||
$exportImages,
|
$exportImages,
|
||||||
$exportVideo,
|
$exportVideo,
|
||||||
$exportMisc,
|
$exportMisc,
|
||||||
$exportFormat
|
$exportFormat,
|
||||||
|
$exportCompress
|
||||||
) )
|
) )
|
||||||
ajaxResponse(array('exportFile'=>$exportFile));
|
ajaxResponse(array('exportFile'=>$exportFile));
|
||||||
else
|
else
|
||||||
|
@ -100,7 +107,8 @@ if ( canView('Events') ) {
|
||||||
if ( $exportFile = exportEvents(
|
if ( $exportFile = exportEvents(
|
||||||
$exportIds,
|
$exportIds,
|
||||||
(isset($_REQUEST['connkey'])?$_REQUEST['connkey']:''),
|
(isset($_REQUEST['connkey'])?$_REQUEST['connkey']:''),
|
||||||
false,false, false, $exportVideo, false, $exportFormat, $exportStructure ) )
|
false,false, false,
|
||||||
|
$exportVideo, false, $exportFormat, $exportStructure ) )
|
||||||
ajaxResponse(array('exportFile'=>$exportFile));
|
ajaxResponse(array('exportFile'=>$exportFile));
|
||||||
else
|
else
|
||||||
ajaxError('Export Failed');
|
ajaxError('Export Failed');
|
||||||
|
|
|
@ -323,6 +323,7 @@ $SLANG = array(
|
||||||
'Events' => 'Events',
|
'Events' => 'Events',
|
||||||
'Exclude' => 'Exclude',
|
'Exclude' => 'Exclude',
|
||||||
'Execute' => 'Execute',
|
'Execute' => 'Execute',
|
||||||
|
'ExportCompress' => 'Use Compression',
|
||||||
'ExportDetails' => 'Export Event Details',
|
'ExportDetails' => 'Export Event Details',
|
||||||
'ExportMatches' => 'Export Matches',
|
'ExportMatches' => 'Export Matches',
|
||||||
'Exif' => 'Embed EXIF data into image',
|
'Exif' => 'Embed EXIF data into image',
|
||||||
|
|
|
@ -826,6 +826,7 @@ function exportEvents(
|
||||||
$exportVideo,
|
$exportVideo,
|
||||||
$exportMisc,
|
$exportMisc,
|
||||||
$exportFormat,
|
$exportFormat,
|
||||||
|
$exportCompressed,
|
||||||
$exportStructure = false
|
$exportStructure = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -912,28 +913,30 @@ function exportEvents(
|
||||||
chdir(ZM_DIR_EXPORTS);
|
chdir(ZM_DIR_EXPORTS);
|
||||||
$archive = '';
|
$archive = '';
|
||||||
if ( $exportFormat == 'tar' ) {
|
if ( $exportFormat == 'tar' ) {
|
||||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar.gz';
|
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar';
|
||||||
@unlink($archive);
|
$command = 'tar --create --dereference';
|
||||||
$command = 'nice -10 tar --create --gzip --dereference --file='.escapeshellarg($archive).' zmExport_'.$connkey.'/';
|
if ( $exportCompressed ) {
|
||||||
#$command = 'nice -10 tar --create --gzip --file='.escapeshellarg($archive).' --files-from='.escapeshellarg($listFile);
|
$archive .= '.gz';
|
||||||
|
$command .= ' --gzip';
|
||||||
|
$exportFormat .= '.gz';
|
||||||
|
}
|
||||||
if ( $exportStructure == 'flat' ) {
|
if ( $exportStructure == 'flat' ) {
|
||||||
//strip file paths if we
|
//strip file paths if we
|
||||||
$command .= " --xform='s#^.+/##x'";
|
$command .= " --xform='s#^.+/##x'";
|
||||||
}
|
}
|
||||||
|
$command .= ' --file='.escapeshellarg($archive);
|
||||||
} elseif ( $exportFormat == 'zip' ) {
|
} elseif ( $exportFormat == 'zip' ) {
|
||||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.zip';
|
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.zip';
|
||||||
@unlink($archive);
|
$command = 'zip ';
|
||||||
if ( $exportStructure == 'flat' ) {
|
$command = ($exportStructure == 'flat' ? ' -j ' : ' -r ' ).escapeshellarg($archive);
|
||||||
$command = 'nice -10 zip -j '.escapeshellarg($archive).' zmExport_'.$connkey.'/';
|
$command .= $exportCompressed ? ' -9' : ' -0';
|
||||||
#$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).' -@';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Error("No exportFormat specified.");
|
Error("No exportFormat specified.");
|
||||||
return false;
|
return false;
|
||||||
} // if $exportFormat
|
} // if $exportFormat
|
||||||
|
|
||||||
|
@unlink($archive);
|
||||||
|
$command .= ' zmExport_' . $connkey.'/';
|
||||||
Logger::Debug("Command is $command");
|
Logger::Debug("Command is $command");
|
||||||
exec($command, $output, $status);
|
exec($command, $output, $status);
|
||||||
if ( $status ) {
|
if ( $status ) {
|
||||||
|
|
|
@ -36,18 +36,21 @@ if ( isset($_SESSION['export']) ) {
|
||||||
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
|
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
|
||||||
if ( isset($_SESSION['export']['format']) )
|
if ( isset($_SESSION['export']['format']) )
|
||||||
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
|
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
|
||||||
|
if ( isset($_SESSION['export']['compress']) )
|
||||||
|
$_REQUEST['exportCompress'] = $_SESSION['export']['compress'];
|
||||||
} else {
|
} else {
|
||||||
$_REQUEST['exportDetail'] =
|
$_REQUEST['exportDetail'] =
|
||||||
$_REQUEST['exportFrames'] =
|
$_REQUEST['exportFrames'] =
|
||||||
$_REQUEST['exportImages'] =
|
$_REQUEST['exportImages'] =
|
||||||
$_REQUEST['exportVideo'] =
|
$_REQUEST['exportVideo'] =
|
||||||
$_REQUEST['exportMisc'] = 1;
|
$_REQUEST['exportMisc'] = 1;
|
||||||
|
$_REQUEST['exportCompress'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
$connkey = isset($_REQUEST['connkey']) ? $_REQUEST['connkey'] : generateConnKey();
|
$connkey = isset($_REQUEST['connkey']) ? $_REQUEST['connkey'] : generateConnKey();
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Export') );
|
xhtmlHeaders(__FILE__, translate('Export'));
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
|
@ -74,11 +77,11 @@ if ( $user['MonitorIds'] ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_REQUEST['eid']) and $_REQUEST['eid'] ) {
|
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=?';
|
$eventsSql .= ' AND E.Id=?';
|
||||||
$eventsValues[] = $_REQUEST['eid'];
|
$eventsValues[] = $_REQUEST['eid'];
|
||||||
} elseif ( isset($_REQUEST['eids']) and count($_REQUEST['eids']) > 0 ) {
|
} 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'])). ')';
|
$eventsSql .= ' AND E.Id IN ('.implode(',', array_map(function(){return '?';}, $_REQUEST['eids'])). ')';
|
||||||
$eventsValues += $_REQUEST['eids'];
|
$eventsValues += $_REQUEST['eids'];
|
||||||
} else if ( isset($_REQUEST['filter']) ) {
|
} else if ( isset($_REQUEST['filter']) ) {
|
||||||
|
@ -100,17 +103,17 @@ $disk_space_total = 0;
|
||||||
<table id="contentTable" class="major">
|
<table id="contentTable" class="major">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="colId"><a href="<?php echo sortHeader('Id') ?>"><?php echo translate('Id') ?><?php echo sortTag( 'Id' ) ?></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="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="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="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="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="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="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="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="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="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="colMaxScore"><a href="<?php echo sortHeader('MaxScore') ?>"><?php echo translate('MaxBrScore') ?><?php echo sortTag('MaxScore') ?></a></th>
|
||||||
<?php
|
<?php
|
||||||
if ( ZM_WEB_EVENT_DISK_SPACE ) {
|
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>
|
<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>
|
</td>
|
||||||
</tr>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<button type="button" id="exportButton" name="exportButton" value="Export" onclick="exportEvent(this.form);" disabled="disabled"><?php echo translate('Export') ?></button>
|
<button type="button" id="exportButton" name="exportButton" value="Export" onclick="exportEvent(this.form);" disabled="disabled"><?php echo translate('Export') ?></button>
|
||||||
|
|
|
@ -28,10 +28,14 @@ $connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
||||||
|
|
||||||
if ( $archivetype ) {
|
if ( $archivetype ) {
|
||||||
switch ($archivetype) {
|
switch ($archivetype) {
|
||||||
case 'tar':
|
case 'tar.gz':
|
||||||
$mimetype = 'gzip';
|
$mimetype = 'gzip';
|
||||||
$file_ext = 'tar.gz';
|
$file_ext = 'tar.gz';
|
||||||
break;
|
break;
|
||||||
|
case 'tar':
|
||||||
|
$mimetype = 'tar';
|
||||||
|
$file_ext = 'tar';
|
||||||
|
break;
|
||||||
case 'zip':
|
case 'zip':
|
||||||
$mimetype = 'zip';
|
$mimetype = 'zip';
|
||||||
$file_ext = 'zip';
|
$file_ext = 'zip';
|
||||||
|
|
Loading…
Reference in New Issue