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,12 +36,15 @@ 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;
|
||||||
|
@ -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']) ) {
|
||||||
|
@ -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