From fff54e4086fc5a071edd7c6a7770edf434ea8581 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 18 May 2016 09:02:14 -0400 Subject: [PATCH] update export to use event object, which automatically fixes storage path issues. Include mp4's in the list of video files to include --- .../classic/includes/export_functions.php | 92 ++++++++----------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index 686d0174e..44ae1d0b0 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -104,7 +104,7 @@ html ul.tabs li.active, html ul.tabs li.active a:hover { function exportEventDetail( $event, $exportFrames, $exportImages ) { ob_start(); - exportHeader( translate('Event')." ".$event['Id'] ); + exportHeader( translate('Event')." ".$event->Id() ); $otherlinks = ''; if( $exportFrames ) $otherlinks .= ''.translate('Frames').','; @@ -116,21 +116,21 @@ function exportEventDetail( $event, $exportFrames, $exportImages )
-

: ()

+

: Name()) ?> ()

- - - - - - - - - - - - - + + + + + + + + + + + + +
()
Id() ?>
Name()) ?>
MonitorName()) ?> (MonitorId() ?>)
Cause()) ?>
Notes()) ?>
StartTime()) ) ?>
Length() ?>
Frames() ?>
AlarmFrames() ?>
TotScore() ?>
AvgScore() ?>
MaxScore() ?>
Archived()?translate('Yes'):translate('No') ?>
@@ -145,10 +145,10 @@ function exportEventFrames( $event, $exportDetail, $exportImages ) global $SLANG; $sql = "SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId"; - $frames = dbFetchAll( $sql, NULL, array( $event['Id'] ) ); + $frames = dbFetchAll( $sql, NULL, array( $event->Id() ) ); ob_start(); - exportHeader( translate('Frames')." ".$event['Id'] ); + exportHeader( translate('Frames')." ".$event->Id() ); $otherlinks = ''; if( $exportDetail ) $otherlinks .= ''.translate('Event').','; @@ -159,7 +159,7 @@ function exportEventFrames( $event, $exportDetail, $exportImages )
-

: ()

+

: Name()) ?> ()

@@ -179,7 +179,7 @@ function exportEventFrames( $event, $exportDetail, $exportImages ) Path(); foreach ( $frames as $frame ) { $imageFile = sprintf( "%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg", $frame['FrameId'] ); @@ -233,7 +233,7 @@ function exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist ) global $SLANG; ob_start(); - exportHeader( translate('Images')." ".$event['Id'] ); + exportHeader( translate('Images')." ".$event->Id() ); $otherlinks = ''; if( $exportDetail ) $otherlinks .= ''.translate('Event').','; @@ -247,9 +247,9 @@ function exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist ) ?> -

: ()

+

: Name()) ?> ()

@@ -275,7 +275,7 @@ function exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist )
 
 
+ onmousedown="slide(event,'horizontal', Width()-20)?>, 1, , ,0, 'imageslider_display_id');" > 
@@ -288,8 +288,8 @@ function exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist ) * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ -var eventWidth = ; -var eventHeight = ; +var eventWidth = Width()?>; +var eventHeight = Height()?>; var variableslide=[]; //configure the below 3 variables to set the dimension/background color of the slideshow @@ -595,15 +595,12 @@ function exportEventImagesMaster( $eids )

Master

MonitorId(); + $eventPath[$eid] = $event->Relative_Path(); } $monitors = array_values(array_flip(array_flip($eventMonitorId))); //unique monitors and reindex the array @@ -762,9 +759,8 @@ function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exp if ( canView( 'Events' ) && $eid ) { - $sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?'; - $event = dbFetchOne( $sql, NULL, array( $eid ) ); - $eventPath = ZM_DIR_EVENTS.'/'.mygetEventPath( $event ); + $event = new Event( $eid ); + $eventPath = $event->Path(); $files = array(); if ( $dir = opendir( $eventPath ) ) { @@ -805,7 +801,7 @@ function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exp if ( $exportImages ) { $filesLeft = array(); - $myfilelist = array(); + $myfilelist = array(); foreach ( $files as $file ) { if ( preg_match( "/-(?:capture|analyse).jpg$/", $file ) ) @@ -838,7 +834,7 @@ function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exp $filesLeft = array(); foreach ( $files as $file ) { - if ( preg_match( "/\.(?:mpg|mpeg|avi|asf|3gp)$/", $file ) ) + if ( preg_match( "/\.(?:mpg|mpeg|mp4|avi|asf|3gp)$/", $file ) ) { $exportFileList[$file] = $eventPath."/".$file; } @@ -864,14 +860,12 @@ function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exp function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat ) { - if ( canView( 'Events' ) && !empty($eids) ) { $export_root = "zmExport"; $export_listFile = "zmFileList.txt"; $exportFileList = array(); - $html_eventMaster = ''; - + $html_eventMaster = ''; if ( is_array( $eids ) ) { @@ -946,19 +940,11 @@ function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $expo } } - //clean up temporary files - if(!empty($html_eventMaster)) { - unlink($monitorPath.'/'.$html_eventMaster); - } + //clean up temporary files + if(!empty($html_eventMaster)) { + unlink($monitorPath.'/'.$html_eventMaster); + } } return( $archive ); } -function mygetEventPath( $event ) -{ - if ( ZM_USE_DEEP_STORAGE ) - $eventPath = $event['MonitorId'].'/'.strftime( "%y/%m/%d/%H/%M/%S", strtotime($event['StartTime']) ); - else - $eventPath = $event['MonitorId'].'/'.$event['Id']; - return( $eventPath ); -}