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 ?>

 
 
SaveJPEGs()) { $html .= ' '; if ( ZM_WEB_LIST_THUMBS ) { $html .= ''.$Event->Id().' '; } $html .= '
'; } # end if has jpegs if ($Event->DefaultVideo()) { $html .= ''; $html .= ''.$Event->Id().''; $html .= '
'.PHP_EOL; } if ($exportDetail) { $html .= 'Detail '; } if ( $exportFrames ) { $html .= 'Frames '; } if (!$html) $html = $Event->Id(); $html = '
'.PHP_EOL.$html.PHP_EOL.'
'.PHP_EOL; return $html; } // end function eventlist_html function exportEventImagesMaster($eids, $exportDetail, $exportFrames, $exportStructure) { 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, $exportStructure); } # end if its the right monitor } # end foreach event echo ''; } # end foreach monitor ?>
canView()) { ZM\Error('Can\'t view event '.$event->Id()); return; } $eventPath = $event->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); } ZM\Debug('All available files: '.print_r($files, true)); $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 '$eventPath/$file'"); } } else { ZM\Debug('Not including detail'); } 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 '$eventPath/$file' is writable? ".is_writable($eventPath)); } } else { ZM\Debug('Not including frames'); } if ($exportImages) { $filesLeft = array(); $myfilelist = array(); foreach ($files as $file) { if (preg_match('/-(?:capture|analyse).jpg$/', $file)) { $myfilelist[$file] = $exportFileList[$file] = $file; } else if ($exportVideo and preg_match('/\.(?:mpg|mpeg|mov|swf|mp4|mkv|avi|asf|3gp)$/', $file)) { $exportFileList[$file] = $file; } else { $filesLeft[$file] = $file; } } $files = $filesLeft; // create an image slider $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'"); } } else { ZM\Debug('Not including frame images'); } # 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; } if ($exportMisc) { foreach ($files as $file) { $exportFileList[$file] = $file; } $files = array(); } else { ZM\Debug('Not including misc'); } ZM\Debug(print_r($exportFileList, true)); return array_values($exportFileList); } # end exportFileList() function exportEvents( $eids, $connkey, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat, $exportCompressed, $exportStructure = false, $export_root = 'zmExport' ) { if (!(canView('Events') or canView('Snapshots'))) { 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.'/'.$export_root.($connkey?'_'.$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; } chmod($export_dir, 0700); if (!chdir($export_dir)) { ZM\Error("Can't chdir to $export_dir"); return; } $export_listFile = 'zmFileList.txt'; $exportFileList = array(); $html_eventMaster = ''; if (!is_array($eids)) { $eids = array($eids); } foreach ($eids as $eid) { $event = new ZM\Event($eid); if (!$event->canView()) { global $user; ZM\Warning('User '.($user?$user['Username']:'').' cannot view event '.$event->Id()); continue; } $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; if ($exportStructure == 'flat') { $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'_'.$file. ' 2>&1'; } else { $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') or file_exists($export_dir.'/jquery.min.js') )) { ZM\Error('Failed linking '.ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js to '.$export_dir.'/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, $exportStructure)); 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\Error("Can't open event export list file '$listFile'"); return false; } foreach ($exportFileList as $exportFile) { $exportFile = $export_root.$connkey.'/'.$exportFile; fwrite($fp, $exportFile.PHP_EOL); } fwrite($fp, $listFile.PHP_EOL); fclose($fp); chdir(ZM_DIR_EXPORTS); $archive = ''; if ($exportFormat == 'tar') { $archive = $export_root.($connkey?'_'.$connkey:'').'.tar'; $version = @shell_exec('tar --version'); ZM\Debug("Version $version"); $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\''; } } $archive_path = ZM_DIR_EXPORTS.'/'.$archive; $command .= ' --file='.escapeshellarg($archive_path); } else if ($exportFormat == 'zip') { $archive = $export_root.($connkey?'_'.$connkey:'').'.zip'; $archive_path = ZM_DIR_EXPORTS.'/'.$archive; $command = 'zip -r '; $command .= ($exportStructure == 'flat' ? ' -j ' : '').escapeshellarg($archive_path); $command .= $exportCompressed ? ' -9' : ' -0'; } // if $exportFormat @unlink($archive_path); $command .= ' '.$export_root.($connkey?'_'.$connkey:'').'/'; ZM\Debug($command); 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.'&file='.$archive; } // end function exportEvents