Id()); $otherlinks = ''; if ( $exportFrames ) $otherlinks .= ' '.translate('Frames').','; if ( $exportImages ) $otherlinks .= ' '.translate('Images').','; $otherlinks = substr($otherlinks, 0, -1); ?>

Name()).( (!empty($otherlinks)) ? ' ('.$otherlinks.') ' : '' ) ?>

Id() ?>
Name()) ?>
Monitor()->Name()) ?> (MonitorId() ?>)
Cause()) ?>
Notes()) ?>
StartDateTime())) ?>
Length() ?>
Frames() ?>
AlarmFrames() ?>
TotScore() ?>
AvgScore() ?>
MaxScore() ?>
Archived()?'Yes':'No') ?>
Id())); ob_start(); exportHeader(translate('Frames').' '.$event->Id()); $otherlinks = ''; if ( $exportDetail ) $otherlinks .= ' '.translate('Event').','; if ( $exportImages ) $otherlinks .= ' '.translate('Images').','; $otherlinks = substr($otherlinks, 0, -1); ?>

Name()).( (!empty($otherlinks)) ? ' ('.$otherlinks.')':'') ?>

Path(); foreach ( $frames as $frame ) { $imageFile = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId']); $imagePath = $eventPath.'/'.$imageFile; $analImage = preg_replace('/capture/', 'analyse', $imagePath); if ( file_exists($analImage) ) { $imageFile = preg_replace('/capture/', 'analyse', $imageFile); } $class = strtolower($frame['Type']); ?>
Frame <?php echo $frame['FrameId'] ?>
Id()); $otherlinks = ''; if ( $exportDetail ) $otherlinks .= ' '.translate('Event').','; if ( $exportFrames ) $otherlinks .= ' '.translate('Frames').','; $otherlinks = substr($otherlinks, 0, -1); $filelist = array_keys($myfilelist); sort($filelist, SORT_NUMERIC); $slides = '"'.implode('","',$filelist).'"'; $listcount = count($filelist); ?>

Name()).( (!empty($otherlinks)) ? ' ('.$otherlinks.') ' : '' ) ?>

DefaultVideo() ) { // videojs zoomrotate only when direct recording $Zoom = 1; $Rotation = 0; $Monitor = $event->Monitor(); if ( $Monitor->VideoWriter() == '2' ) { # Passthrough $Rotation = $event->Orientation(); if ( in_array($event->Orientation(), array('ROTATE_90','ROTATE_270')) ) $Zoom = $event->Height()/$event->Width(); } # end if passthrough ?>

 
 
'; if ( $Event->SaveJPEGs() ) { $html .= ' '; if ( ZM_WEB_LIST_THUMBS ) { $html .= ''.$Event->Id().' '; } else { $html .= $Event->Id(); } $html .= '
'; } # end if has jpegs if ( $Event->DefaultVideo() ) { if ( ZM_WEB_LIST_THUMBS ) { $html .= ''; $html .= ''.$Event->Id().''; $html .= '
'; } } if ( $exportDetail ) { $html .= 'Detail '; } if ( $exportFrames ) { $html .= 'Frames '; } $html .= ' '; return $html; } // end function eventlist_html function exportEventImagesMaster($eids, $exportDetail, $exportFrames) { ob_start(); exportHeader(translate('Images').' Master'); ?>

Master

$eids)); foreach ( $events as $event ) { //get monitor id and event id $eventMonitorId[$event->Id()] = $event->MonitorId(); $eventPath[$event->Id()] = $event->Relative_Path(); } $monitors = array_values(array_flip(array_flip($eventMonitorId))); //unique monitors and reindex the array $monitorNames = array(); //* if ( !empty($monitors) ) { $tmp = dbFetchAll('SELECT Id, Name FROM Monitors WHERE Id IN ('.implode(',', $monitors).') '); foreach ( $tmp as $row ) { $monitorNames[$row['Id']] = $row['Name']; } } //*/ ?>

All

'; echo '

Monitor: '.$monitorNames[$monitor_id].'

'; foreach ( $events as $event ) { if ( $event->MonitorId() == $monitor_id ) { echo eventlist_html($event, $exportDetail, $exportFrames); } # end if its the right monitor } # end foreach event echo ''; } # end foreach monitor ?>
Path(); $eventRelativePath = $event->Relative_Path(); $files = array(); if ( $dir = opendir($eventPath) ) { while ( ($file = readdir($dir)) !== false ) { if ( is_file($eventPath.'/'.$file) ) { $files[$file] = $file; } } closedir($dir); } $exportFileList = array(); if ( $exportDetail ) { $file = 'zmEventDetail.html'; if ( $fp = fopen($eventPath.'/'.$file, 'w') ) { fwrite($fp, exportEventDetail($event, $exportFrames, $exportImages)); fclose($fp); $exportFileList[$file] = $file; } else { ZM\Error("Can't open event detail export file '$file'"); } } if ( $exportFrames ) { $file = 'zmEventFrames.html'; if ( $fp = fopen($eventPath.'/'.$file, 'w') ) { fwrite($fp, exportEventFrames($event, $exportDetail, $exportImages)); fclose($fp); $exportFileList[$file] = $file; } else { ZM\Error("Can't open event frames export file '$file'"); } } if ( $exportImages ) { $filesLeft = array(); $myfilelist = array(); foreach ( $files as $file ) { if ( preg_match('/-(?:capture|analyse).jpg$/', $file) ) { $myfilelist[$file] = $exportFileList[$file] = $file; } else { $filesLeft[$file] = $file; } } $files = $filesLeft; // create an image slider if ( !empty($myfilelist) ) { $file = 'zmEventImages.html'; if ( $fp = fopen($eventPath.'/'.$file, 'w') ) { fwrite($fp, exportEventImages($event, $exportDetail, $exportFrames, $myfilelist)); fclose($fp); $exportFileList[$file] = $file; } else { ZM\Error("Can't open event images export file '$file'"); } } } # end if exportImages if ( $exportVideo ) { $filesLeft = array(); foreach ( $files as $file ) { if ( preg_match('/\.(?:mpg|mpeg|mov|swf|mp4|mkv|avi|asf|3gp)$/', $file) ) { $exportFileList[$file] = $file; } else { $filesLeft[$file] = $file; } } $files = $filesLeft; } # end if exportVideo if ( $exportMisc ) { foreach ( $files as $file ) { $exportFileList[$file] = $file; } $files = array(); } return array_values($exportFileList); } # end exportFileList() function exportEvents( $eids, $connkey, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat, $exportCompressed, $exportStructure = false ) { if ( !canView('Events') ) { ZM\Error('You do not have permission to view events.'); return false; } else if ( empty($eids) ) { ZM\Error('Attempt to export an empty list of events.'); return false; } if ( !($exportFormat == 'tar' or $exportFormat == 'zip') ) { ZM\Error("None or invalid exportFormat specified $exportFormat."); return false; } # Ensure that we are going to be able to do this. if ( ! ( mkdir(ZM_DIR_EXPORTS) or file_exists(ZM_DIR_EXPORTS) ) ) { ZM\Fatal('Can\'t create exports dir at \''.ZM_DIR_EXPORTS.'\''); } chmod(ZM_DIR_EXPORTS, 0700); $export_dir = ZM_DIR_EXPORTS.'/zmExport_'.$connkey; # Ensure that we are going to be able to do this. if ( ! ( mkdir($export_dir) or file_exists($export_dir) ) ) { ZM\Error("Can't create exports dir at '$export_dir'"); return false; } ZM\Debug("Successfully created dir '$export_dir'"); chmod($export_dir, 0700); if ( !chdir($export_dir) ) { ZM\Error("Can't chdir to $export_dir"); return; } $export_root = 'zmExport'; $export_listFile = 'zmFileList.txt'; $exportFileList = array(); $html_eventMaster = ''; if ( !is_array($eids) ) { $eids = array($eids); } foreach ( $eids as $eid ) { $event = new ZM\Event($eid); $event_dir = $export_dir.'/'.$event->Id(); if ( !(mkdir($event_dir) or file_exists($event_dir)) ) { ZM\Error("Can't mkdir $event_dir"); } $event_exportFileList = exportFileList($event, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc); $exportFileList = array_merge($exportFileList, $event_exportFileList); foreach ( $event_exportFileList as $file ) { #if ( preg_match('/\.html$/', $file) ) #continue; $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'/'.$file. ' 2>&1'; exec($cmd, $output, $return); ZM\Debug($cmd.' return code: '.$return.' output: '.print_r($output,true)); } # end foreach event_exportFile } # end foreach event if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js', $export_dir.'/jquery.min.js') ) ZM\Error('Failed linking jquery.min.js'); //if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/video.js', $export_dir.'/video.js') ) //Error("Failed linking video.js"); $html_eventMaster_file = 'zmEventImagesMaster.html'; $html_eventMaster_path = $export_dir.'/'.$html_eventMaster_file; if ( ($fp = fopen($html_eventMaster_path, 'w')) ) { fwrite($fp, exportEventImagesMaster($eids, $exportDetail, $exportFrames)); fclose($fp); $exportFileList[] = $html_eventMaster_file; } else { ZM\Error("Can't open event images export file '$html_eventMaster_path'"); } $listFile = $export_dir.'/'.$export_listFile; if ( !($fp = fopen($listFile, 'w')) ) { ZM\Fatal("Can't open event export list file '$listFile'"); } foreach ( $exportFileList as $exportFile ) { $exportFile = 'zmExport'.$connkey.'/'.$exportFile; fwrite($fp, "$exportFile\n"); } fwrite($fp, "$listFile\n"); fclose($fp); chdir(ZM_DIR_EXPORTS); $archive = ''; if ( $exportFormat == 'tar' ) { $archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar'; $version = shell_exec('tar -v'); $command = 'tar --create --dereference'; if ( $exportCompressed ) { $archive .= '.gz'; $command .= ' --gzip'; $exportFormat .= '.gz'; } if ( $exportStructure == 'flat' ) { if ( preg_match('/BSD/i', $version) ) { $command .= ' -s \'#^.*/##\''; } else { $command .= ' --xform=\'s#^.+/##x\''; } } $command .= ' --file='.escapeshellarg($archive); } elseif ( $exportFormat == 'zip' ) { $archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.zip'; $command = 'zip '; $command .= ($exportStructure == 'flat' ? ' -j ' : ' -r ' ).escapeshellarg($archive); $command .= $exportCompressed ? ' -9' : ' -0'; } // if $exportFormat @unlink($archive); $command .= ' zmExport_' . $connkey.'/'; exec($command, $output, $status); if ( $status ) { ZM\Error("Command '$command' returned with status $status"); if ( isset($output[0]) ) { ZM\Error('First line of output is \''.$output[0].'\''); } return false; } // clean up temporary files if ( !empty($html_eventMaster) ) { unlink($monitorPath.'/'.$html_eventMaster); } return '?view=archive&type='.$exportFormat.'&connkey='.$connkey; } // end function exportEvents