Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into tesla
commit
fb50f6f996
|
@ -608,9 +608,6 @@ CREATE TABLE `Monitors` (
|
|||
`WebColour` varchar(32) NOT NULL default 'red',
|
||||
`Exif` tinyint(1) unsigned NOT NULL default '0',
|
||||
`Sequence` smallint(5) unsigned default NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
`TotalEvents` int(10) unsigned,
|
||||
`TotalEventDiskSpace` bigint unsigned,
|
||||
`HourEvents` int(10) unsigned,
|
||||
|
@ -629,6 +626,14 @@ CREATE TABLE `Monitors` (
|
|||
|
||||
CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`);
|
||||
|
||||
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`Id` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=MEMORY;
|
||||
--
|
||||
-- Table structure for table `States`
|
||||
-- PP - Added IsActive to track custom run states
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitor_Status'
|
||||
) > 0
|
||||
,
|
||||
"SELECT 'Monitor_Status Already exists'",
|
||||
"
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`Id` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=MEMORY"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitors'
|
||||
AND column_name = 'Status'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN Status",
|
||||
"SELECT 'Monitor Status already removed.'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitors'
|
||||
AND column_name = 'CaptureFPS'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN CaptureFPS",
|
||||
"SELECT 'Monitor CaptureFPS already removed.'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitors'
|
||||
AND column_name = 'AnalysisFPS'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN AnalysisFPS",
|
||||
"SELECT 'Monitor AnalysisFPS already removed.'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -350,6 +350,9 @@ sub delete {
|
|||
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n" );
|
||||
$ZoneMinder::Database::dbh->ping();
|
||||
|
||||
$ZoneMinder::Database::dbh->begin_work();
|
||||
$event->lock_and_load();
|
||||
|
||||
if ( ! $Config{ZM_OPT_FAST_DELETE} ) {
|
||||
my $sql = 'DELETE FROM Frames WHERE EventId=?';
|
||||
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
|
||||
|
@ -357,6 +360,10 @@ sub delete {
|
|||
my $res = $sth->execute( $event->{Id} )
|
||||
or Error( "Can't execute '$sql': ".$sth->errstr() );
|
||||
$sth->finish();
|
||||
if ( $ZoneMinder::Database::dbh->errstr() ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM Stats WHERE EventId=?';
|
||||
$sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
|
||||
|
@ -364,6 +371,10 @@ sub delete {
|
|||
$res = $sth->execute( $event->{Id} )
|
||||
or Error( "Can't execute '$sql': ".$sth->errstr() );
|
||||
$sth->finish();
|
||||
if ( $ZoneMinder::Database::dbh->errstr() ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return;
|
||||
}
|
||||
|
||||
$event->delete_files( );
|
||||
} else {
|
||||
|
@ -376,6 +387,7 @@ sub delete {
|
|||
my $res = $sth->execute( $event->{Id} )
|
||||
or Error( "Can't execute '$sql': ".$sth->errstr() );
|
||||
$sth->finish();
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
} # end sub delete
|
||||
|
||||
sub delete_files {
|
||||
|
@ -514,7 +526,10 @@ sub MoveTo {
|
|||
}
|
||||
}
|
||||
}
|
||||
return $error if $error;
|
||||
if ( $error ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return $error;
|
||||
}
|
||||
my @files = glob("$OldPath/*");
|
||||
|
||||
for my $file (@files) {
|
||||
|
|
|
@ -140,7 +140,7 @@ sub Sql {
|
|||
M.DefaultScale
|
||||
FROM Events as E
|
||||
INNER JOIN Monitors as M on M.Id = E.MonitorId
|
||||
INNER JOIN Storage as S on S.Id = E.StorageId
|
||||
LEFT JOIN Storage as S on S.Id = E.StorageId
|
||||
';
|
||||
$self->{Sql} = '';
|
||||
|
||||
|
|
|
@ -395,11 +395,11 @@ MAIN: while( $loop ) {
|
|||
while ( my ( $db_event, $age ) = each( %$db_events ) ) {
|
||||
if ( ! defined( $fs_events->{$db_event} ) ) {
|
||||
my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
|
||||
Debug("Event $db_event is not in fs. Should have been at ".$Event->Path());
|
||||
if ( ! $Event ) {
|
||||
Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing.");
|
||||
next;
|
||||
}
|
||||
Debug("Event $db_event is not in fs. Should have been at ".$Event->Path());
|
||||
if ( ! $Event->StartTime() ) {
|
||||
Info("Event $$Event{Id} has no start time. deleting it.");
|
||||
if ( confirm() ) {
|
||||
|
|
|
@ -738,7 +738,8 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
int ret;
|
||||
static char errbuf[AV_ERROR_MAX_STRING_SIZE];
|
||||
|
||||
// If the reopen thread has a value, but mCanCapture != 0, then we have just reopened the connection to the ffmpeg device, and we can clean up the thread.
|
||||
// If the reopen thread has a value, but mCanCapture != 0, then we have just reopened
|
||||
// the connection to the ffmpeg device, and we can clean up the thread.
|
||||
if ( mReopenThread != 0 ) {
|
||||
void *retval = 0;
|
||||
|
||||
|
@ -751,7 +752,6 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
mReopenThread = 0;
|
||||
}
|
||||
|
||||
|
||||
int frameComplete = false;
|
||||
while ( ! frameComplete ) {
|
||||
av_init_packet( &packet );
|
||||
|
@ -774,7 +774,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
}
|
||||
|
||||
int keyframe = packet.flags & AV_PKT_FLAG_KEY;
|
||||
dumpPacket(&packet);
|
||||
dumpPacket(&packet);
|
||||
|
||||
//Video recording
|
||||
if ( recording.tv_sec ) {
|
||||
|
@ -836,6 +836,7 @@ dumpPacket(&packet);
|
|||
startTime,
|
||||
this->getMonitor());
|
||||
} // end if record_audio
|
||||
|
||||
if ( ! videoStore->open() ) {
|
||||
delete videoStore;
|
||||
videoStore = NULL;
|
||||
|
|
|
@ -1205,7 +1205,7 @@ bool Monitor::Analyse() {
|
|||
fps = double(fps_report_interval)/(now.tv_sec - last_fps_time);
|
||||
Info( "%s: %d - Analysing at %.2f fps", name, image_count, fps );
|
||||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "UPDATE Monitors SET AnalysisFPS = '%.2lf' WHERE Id = '%d'", fps, id );
|
||||
snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,AnalysisFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE AnalysisFPS = %.2lf", id, fps, fps );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
}
|
||||
|
@ -3022,7 +3022,7 @@ Debug(4, "Return from Capture (%d)", captureResult);
|
|||
Info( "%s: images:%d - Capturing at %.2lf fps", name, image_count, fps );
|
||||
last_fps_time = now;
|
||||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "UPDATE Monitors SET CaptureFPS='%.2lf' WHERE Id=%d", fps, id );
|
||||
snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,CaptureFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf", id, fps, fps );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ int main(int argc, char *argv[]) {
|
|||
Info("Starting Capture version %s", ZM_VERSION);
|
||||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
for ( int i = 0; i < n_monitors; i ++ ) {
|
||||
snprintf( sql, sizeof(sql), "UPDATE Monitors SET Status = 'Running' WHERE Id = '%d'", monitors[i]->Id() );
|
||||
snprintf( sql, sizeof(sql), "REPLACE INTO Monitor_Status (Id, Status ) VALUES ('%d','Running')", monitors[i]->Id() );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ function getAuthUser( $auth ) {
|
|||
} // end getAuthUser($auth)
|
||||
|
||||
function generateAuthHash( $useRemoteAddr ) {
|
||||
if ( ZM_OPT_USE_AUTH and ZM_AUTH_HASH_LOGINS and ZM_AUTH_RELAY == 'hashed' and isset($_SESSION['username']) and $_SESSION['passwordHash'] ) {
|
||||
if ( ZM_OPT_USE_AUTH and ZM_AUTH_RELAY == 'hashed' and isset($_SESSION['username']) and $_SESSION['passwordHash'] ) {
|
||||
# regenerate a hash at half the liftetime of a hash, an hour is 3600 so half is 1800
|
||||
$time = time();
|
||||
if ( ( ! isset($_SESSION['AuthHash']) ) or ( $_SESSION['AuthHashGeneratedAt'] < ( $time - ( ZM_AUTH_HASH_TTL * 1800 ) ) ) ) {
|
||||
|
@ -1236,31 +1236,38 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {
|
|||
case 'ServerId':
|
||||
if ( $value == 'ZM_SERVER_ID' ) {
|
||||
$value = ZM_SERVER_ID;
|
||||
} else if ( $value == 'NULL' ) {
|
||||
|
||||
} else {
|
||||
$value = dbEscape($value);
|
||||
}
|
||||
break;
|
||||
case 'StorageId':
|
||||
$StorageArea = new Storage( $value );
|
||||
$value = dbEscape($value);
|
||||
if ( $value != 'NULL' )
|
||||
$value = dbEscape($value);
|
||||
break;
|
||||
case 'DateTime':
|
||||
case 'StartDateTime':
|
||||
case 'EndDateTime':
|
||||
$value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'";
|
||||
if ( $value != 'NULL' )
|
||||
$value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'";
|
||||
break;
|
||||
case 'Date':
|
||||
case 'StartDate':
|
||||
case 'EndDate':
|
||||
$value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
|
||||
if ( $value != 'NULL' )
|
||||
$value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
|
||||
break;
|
||||
case 'Time':
|
||||
case 'StartTime':
|
||||
case 'EndTime':
|
||||
if ( $value != 'NULL' )
|
||||
$value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
|
||||
break;
|
||||
default :
|
||||
$value = dbEscape($value);
|
||||
if ( $value != 'NULL' )
|
||||
$value = dbEscape($value);
|
||||
break;
|
||||
}
|
||||
$valueList[] = $value;
|
||||
|
|
|
@ -174,17 +174,13 @@ foreach ( getSkinIncludes( 'skin.php' ) as $includeFile )
|
|||
require_once $includeFile;
|
||||
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) {
|
||||
Logger::Debug("Useing hash");
|
||||
if ( empty($user) && ! empty($_REQUEST['auth']) ) {
|
||||
if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) {
|
||||
userLogin( $authUser['Username'], $authUser['Password'], true );
|
||||
}
|
||||
} else if ( ! empty($user) ) {
|
||||
Logger::Debug("generating hash");
|
||||
// generate it once here, while session is open. Value will be cached in session and return when called later on
|
||||
generateAuthHash( ZM_AUTH_HASH_IPS );
|
||||
} else {
|
||||
Logger::Debug(" not generating hash");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,9 @@ html ul.tabs li.active, html ul.tabs li.active a:hover {
|
|||
}
|
||||
-->
|
||||
</style>
|
||||
<script type="text/javascript" src="<?php echo ZM_SKIN_PATH; ?>/js/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
<?php include(ZM_SKIN_PATH.'/js/jquery.js'
|
||||
</script>
|
||||
<script type="text/javascript" language="javascript" charset="utf-8">
|
||||
|
||||
/*==========[tab code]==========*/
|
||||
|
@ -579,14 +581,9 @@ else if (document.layers) window.onload=start_slider;
|
|||
return( ob_get_clean() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function exportEventImagesMaster( $eids )
|
||||
{
|
||||
ob_start();
|
||||
exportHeader( translate('Images').' Master' );
|
||||
function exportEventImagesMaster( $eids ) {
|
||||
ob_start();
|
||||
exportHeader( translate('Images').' Master' );
|
||||
?>
|
||||
<body>
|
||||
<h2><?php echo translate('Images') ?> Master</h2>
|
||||
|
@ -611,32 +608,27 @@ function exportEventImagesMaster( $eids )
|
|||
//trigger_error(print_r($monitorNames,1));
|
||||
|
||||
?>
|
||||
<div id= 'tabs'>
|
||||
<ul class= 'tabs'>
|
||||
<li class = 'active' ><a href='#all' > All </a></li>
|
||||
<div id="tabs">
|
||||
<ul class="tabs">
|
||||
<li class="active"><a href="#all"> All </a></li>
|
||||
<?php
|
||||
|
||||
foreach ($monitors as $monitor) {
|
||||
# code...
|
||||
echo "<li><a href='#tab$monitor'>" . $monitorNames[$monitor] . "</a></li>";
|
||||
echo "<li><a href='#tab$monitor'>" . $monitorNames[$monitor] . '</a></li>';
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<table width="100%" height="100%" ><tr>
|
||||
<td valign="top" bgcolor="#dddddd" style="padding:10px;">
|
||||
<div class='tab_content' id='all'>
|
||||
<h2> All </h2>
|
||||
<?php
|
||||
if (!is_array($eids))
|
||||
{
|
||||
if (!is_array($eids)) {
|
||||
echo "<div><a href=\"javascript:switchevent('$eids/zm/EventImages.html');\"> $eids </div>";
|
||||
}
|
||||
?>
|
||||
<?php foreach($eids as $eid)
|
||||
{
|
||||
<?php foreach($eids as $eid) {
|
||||
?>
|
||||
<div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?>/zmEventImages.html');"><?php echo$eid?></a></div>
|
||||
<?php
|
||||
|
@ -644,15 +636,11 @@ function exportEventImagesMaster( $eids )
|
|||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
foreach ($monitors as $monitor)
|
||||
{
|
||||
foreach ($monitors as $monitor) {
|
||||
echo "<div class='tab_content' id='tab$monitor'>";
|
||||
echo "<h2>Monitor: " . $monitorNames[$monitor] . " </h2>";
|
||||
foreach ($eids as $eid)
|
||||
{
|
||||
if ($eventMonitorId[$eid] == $monitor)
|
||||
{
|
||||
foreach ($eids as $eid) {
|
||||
if ($eventMonitorId[$eid] == $monitor) {
|
||||
?>
|
||||
<div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?>/zmEventImages.html');"><?php echo$eid?></a></div>
|
||||
<?php
|
||||
|
@ -660,7 +648,6 @@ function exportEventImagesMaster( $eids )
|
|||
}
|
||||
echo'</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</td><td>
|
||||
|
@ -750,204 +737,168 @@ function loadintoIframe(iframeid, url){
|
|||
|
||||
|
||||
|
||||
function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc )
|
||||
{
|
||||
function exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc ) {
|
||||
|
||||
if ( canView( 'Events' ) && $eid )
|
||||
{
|
||||
$event = new Event( $eid );
|
||||
$eventPath = $event->Path();
|
||||
$files = array();
|
||||
if ( $dir = opendir( $eventPath ) )
|
||||
{
|
||||
while ( ($file = readdir( $dir )) !== false )
|
||||
{
|
||||
if ( is_file( $eventPath."/".$file ) )
|
||||
{
|
||||
$files[$file] = $file;
|
||||
}
|
||||
}
|
||||
closedir( $dir );
|
||||
}
|
||||
if ( (!canView('Events')) or ! $eid ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$exportFileList = array();
|
||||
|
||||
if ( $exportDetail )
|
||||
{
|
||||
$file = "zmEventDetail.html";
|
||||
if ( !($fp = fopen( $eventPath."/".$file, "w" )) )
|
||||
{
|
||||
Fatal( "Can't open event detail export file '$file'" );
|
||||
}
|
||||
fwrite( $fp, exportEventDetail( $event, $exportFrames, $exportImages ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
if ( $exportFrames )
|
||||
{
|
||||
$file = "zmEventFrames.html";
|
||||
if ( !($fp = fopen( $eventPath."/".$file, "w" )) )
|
||||
{
|
||||
Fatal( "Can't open event frames export file '$file'" );
|
||||
}
|
||||
fwrite( $fp, exportEventFrames( $event, $exportDetail, $exportImages ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
if ( $exportImages )
|
||||
{
|
||||
$filesLeft = array();
|
||||
$myfilelist = array();
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
if ( preg_match( "/-(?:capture|analyse).jpg$/", $file ) )
|
||||
{
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
$myfilelist[$file] = $eventPath."/".$file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filesLeft[$file] = $file;
|
||||
}
|
||||
}
|
||||
$files = $filesLeft;
|
||||
|
||||
|
||||
|
||||
// create an image slider
|
||||
if(!empty($myfilelist)) {
|
||||
$file = "zmEventImages.html";
|
||||
if ( !($fp = fopen( $eventPath."/".$file, "w" )) ) Fatal( "Can't open event images export file '$file'" );
|
||||
fwrite( $fp, exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ( $exportVideo )
|
||||
{
|
||||
$filesLeft = array();
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
if ( preg_match( "/\.(?:mpg|mpeg|mp4|avi|asf|3gp)$/", $file ) )
|
||||
{
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filesLeft[$file] = $file;
|
||||
}
|
||||
}
|
||||
$files = $filesLeft;
|
||||
}
|
||||
if ( $exportMisc )
|
||||
{
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
$files = array();
|
||||
}
|
||||
$event = new Event($eid);
|
||||
$eventPath = $event->Path();
|
||||
$files = array();
|
||||
if ( $dir = opendir($eventPath) ) {
|
||||
while ( ($file = readdir($dir)) !== false ) {
|
||||
if ( is_file($eventPath.'/'.$file) ) {
|
||||
$files[$file] = $file;
|
||||
}
|
||||
}
|
||||
return( array_values( $exportFileList ) );
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
$exportFileList = array();
|
||||
|
||||
if ( $exportDetail ) {
|
||||
$file = 'zmEventDetail.html';
|
||||
if ( !($fp = fopen( $eventPath.'/'.$file, 'w' )) ) {
|
||||
Fatal( "Can't open event detail export file '$file'" );
|
||||
}
|
||||
fwrite( $fp, exportEventDetail( $event, $exportFrames, $exportImages ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
if ( $exportFrames ) {
|
||||
$file = 'zmEventFrames.html';
|
||||
if ( !($fp = fopen( $eventPath.'/'.$file, 'w' )) ) {
|
||||
Fatal( "Can't open event frames export file '$file'" );
|
||||
}
|
||||
fwrite( $fp, exportEventFrames( $event, $exportDetail, $exportImages ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
if ( $exportImages ) {
|
||||
$filesLeft = array();
|
||||
$myfilelist = array();
|
||||
foreach ( $files as $file ) {
|
||||
if ( preg_match( '/-(?:capture|analyse).jpg$/', $file ) ) {
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
$myfilelist[$file] = $eventPath."/".$file;
|
||||
} else {
|
||||
$filesLeft[$file] = $file;
|
||||
}
|
||||
}
|
||||
$files = $filesLeft;
|
||||
|
||||
// create an image slider
|
||||
if ( !empty($myfilelist) ) {
|
||||
$file = 'zmEventImages.html';
|
||||
if ( !($fp = fopen($eventPath.'/'.$file, 'w')) ) Fatal( "Can't open event images export file '$file'" );
|
||||
fwrite( $fp, exportEventImages( $event, $exportDetail, $exportFrames, $myfilelist ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[$file] = $eventPath."/".$file;
|
||||
}
|
||||
} # end if exportImages
|
||||
|
||||
if ( $exportVideo ) {
|
||||
$filesLeft = array();
|
||||
foreach ( $files as $file ) {
|
||||
if ( preg_match( '/\.(?:mpg|mpeg|mp4|mkv|avi|asf|3gp)$/', $file ) ) {
|
||||
$exportFileList[$file] = $eventPath.'/'.$file;
|
||||
} else {
|
||||
$filesLeft[$file] = $file;
|
||||
}
|
||||
}
|
||||
$files = $filesLeft;
|
||||
} # end if exportVideo
|
||||
|
||||
if ( $exportMisc ) {
|
||||
foreach ( $files as $file ) {
|
||||
$exportFileList[$file] = $eventPath.'/'.$file;
|
||||
}
|
||||
$files = array();
|
||||
}
|
||||
return( array_values( $exportFileList ) );
|
||||
}
|
||||
|
||||
function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat, $exportStructure = false )
|
||||
{
|
||||
|
||||
if ( canView( 'Events' ) && !empty($eids) )
|
||||
{
|
||||
$export_root = "zmExport";
|
||||
$export_listFile = "zmFileList.txt";
|
||||
$exportFileList = array();
|
||||
$html_eventMaster = '';
|
||||
function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat, $exportStructure = false ) {
|
||||
|
||||
if ( is_array( $eids ) )
|
||||
{
|
||||
foreach ( $eids as $eid )
|
||||
{
|
||||
$exportFileList = array_merge( $exportFileList, exportFileList( $eid , $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc ) );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$eid = $eids;
|
||||
$exportFileList = exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc );
|
||||
}
|
||||
|
||||
// create an master image slider
|
||||
if($exportImages)
|
||||
{
|
||||
if ( !is_array($eids) )
|
||||
{
|
||||
$eids = array($eids);
|
||||
}
|
||||
$monitorPath = ZM_DIR_EVENTS."/";
|
||||
$html_eventMaster = 'zmEventImagesMaster_'.date('Ymd_His'). '.html';
|
||||
if ( !($fp = fopen( $monitorPath."/".$html_eventMaster, "w" )) ) Fatal( "Can't open event images export file '$html_eventMaster'" );
|
||||
fwrite( $fp, exportEventImagesMaster( $eids ) );
|
||||
fclose( $fp );
|
||||
$exportFileList[] = $monitorPath."/".$html_eventMaster;
|
||||
}
|
||||
|
||||
$listFile = ZM_DIR_EXPORTS."/".$export_listFile;
|
||||
if ( !($fp = fopen( $listFile, "w" )) )
|
||||
{
|
||||
Fatal( "Can't open event export list file '$listFile'" );
|
||||
}
|
||||
foreach ( $exportFileList as $exportFile )
|
||||
{
|
||||
fwrite( $fp, "$exportFile\n" );
|
||||
}
|
||||
fclose( $fp );
|
||||
$archive = "";
|
||||
if ( $exportFormat == "tar" )
|
||||
{
|
||||
$archive = ZM_DIR_EXPORTS."/".$export_root.".tar.gz";
|
||||
@unlink( $archive );
|
||||
if ($exportStructure == 'flat') { //strip file paths if we choose
|
||||
$command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile)." --xform='s#^.+/##x'";
|
||||
} else {
|
||||
$command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile);
|
||||
}
|
||||
exec( $command, $output, $status );
|
||||
if ( $status )
|
||||
{
|
||||
Error( "Command '$command' returned with status $status" );
|
||||
if ( $output[0] )
|
||||
Error( "First line of output is '".$output[0]."'" );
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
elseif ( $exportFormat == "zip" )
|
||||
{
|
||||
$archive = ZM_DIR_EXPORTS."/".$export_root.".zip";
|
||||
@unlink( $archive );
|
||||
if ($exportStructure == 'flat') {
|
||||
$command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q -j ".escapeshellarg($archive)." -@";
|
||||
} else {
|
||||
$command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q ".escapeshellarg($archive)." -@";
|
||||
}
|
||||
//cat zmFileList.txt | zip -q zm_export.zip -@
|
||||
//-bash: zip: command not found
|
||||
|
||||
exec( $command, $output, $status );
|
||||
if ( $status )
|
||||
{
|
||||
Error( "Command '$command' returned with status $status" );
|
||||
if ( $output[0] )
|
||||
Error( "First line of output is '".$output[0]."'" );
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
|
||||
//clean up temporary files
|
||||
if(!empty($html_eventMaster)) {
|
||||
unlink($monitorPath.'/'.$html_eventMaster);
|
||||
}
|
||||
if ( (!canView('Events')) || empty($eids) ) {
|
||||
return false;
|
||||
}
|
||||
$export_root = 'zmExport';
|
||||
$export_listFile = 'zmFileList.txt';
|
||||
$exportFileList = array();
|
||||
$html_eventMaster = '';
|
||||
|
||||
if ( is_array($eids) ) {
|
||||
foreach ( $eids as $eid ) {
|
||||
$exportFileList = array_merge( $exportFileList, exportFileList( $eid , $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc ) );
|
||||
}
|
||||
return( '?view=archive%26type='.$exportFormat );
|
||||
} else {
|
||||
$eid = $eids;
|
||||
$exportFileList = exportFileList( $eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc );
|
||||
}
|
||||
|
||||
// create an master image slider
|
||||
if ( $exportImages ) {
|
||||
if ( !is_array($eids) ) {
|
||||
$eids = array($eids);
|
||||
}
|
||||
$monitorPath = ZM_DIR_EVENTS.'/';
|
||||
$html_eventMaster = 'zmEventImagesMaster_'.date('Ymd_His'). '.html';
|
||||
if ( !($fp = fopen( $monitorPath.'/'.$html_eventMaster, 'w' )) ) Fatal( "Can't open event images export file '$html_eventMaster'" );
|
||||
fwrite($fp, exportEventImagesMaster($eids));
|
||||
fclose($fp);
|
||||
$exportFileList[] = $monitorPath.'/'.$html_eventMaster;
|
||||
}
|
||||
|
||||
$listFile = ZM_DIR_EXPORTS.'/'.$export_listFile;
|
||||
if ( !($fp = fopen($listFile, 'w')) ) {
|
||||
Fatal( "Can't open event export list file '$listFile'" );
|
||||
}
|
||||
foreach ( $exportFileList as $exportFile ) {
|
||||
fwrite( $fp, "$exportFile\n" );
|
||||
}
|
||||
fclose( $fp );
|
||||
$archive = '';
|
||||
if ( $exportFormat == 'tar' ) {
|
||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.'.tar.gz';
|
||||
@unlink( $archive );
|
||||
if ( $exportStructure == 'flat' ) { //strip file paths if we choose
|
||||
$command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile)." --xform='s#^.+/##x'";
|
||||
} else {
|
||||
$command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile);
|
||||
}
|
||||
exec( $command, $output, $status );
|
||||
if ( $status ) {
|
||||
Error( "Command '$command' returned with status $status" );
|
||||
if ( $output[0] )
|
||||
Error( "First line of output is '".$output[0]."'" );
|
||||
return( false );
|
||||
}
|
||||
} elseif ( $exportFormat == 'zip' ) {
|
||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.'.zip';
|
||||
@unlink( $archive );
|
||||
if ($exportStructure == 'flat') {
|
||||
$command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q -j ".escapeshellarg($archive)." -@";
|
||||
} else {
|
||||
$command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q ".escapeshellarg($archive)." -@";
|
||||
}
|
||||
//cat zmFileList.txt | zip -q zm_export.zip -@
|
||||
//-bash: zip: command not found
|
||||
|
||||
exec( $command, $output, $status );
|
||||
if ( $status ) {
|
||||
Error("Command '$command' returned with status $status");
|
||||
if ( $output[0] )
|
||||
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%26type='.$exportFormat );
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ if ( ! is_array( $selected_monitor_ids ) ) {
|
|||
$values += $ids;
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
$sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON S.Id=M.Id ' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||
$monitors = dbFetchAll( $sql, null, $values );
|
||||
$displayMonitors = array();
|
||||
$monitors_dropdown = array();
|
||||
|
|
|
@ -215,7 +215,18 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
|||
<td class="colName"><a <?php echo (canView('Stream') && $monitor['Function'] != 'None' ? 'href="?view=watch&mid='.$monitor['Id'].'">' : '>') . $monitor['Name'] ?></a></td>
|
||||
<td class="colFunction">
|
||||
<?php echo makePopupLink( '?view=function&mid='.$monitor['Id'], 'zmFunction', 'function', '<span class="'.$fclass.'">'.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'</span>', canEdit( 'Monitors' ) ) ?><br/>
|
||||
<?php echo $monitor['CaptureFPS'] . ( ( $monitor['Function'] == 'Mocord' or $monitor['Function'] == 'Modect' ) ? ' / ' . $monitor['AnalysisFPS'] : '' ) . ' FPS' ?>
|
||||
<?php
|
||||
$fps_string = '';
|
||||
if ( isset($monitor['CaptureFPS']) ) {
|
||||
$fps_string .= $monitor['CaptureFPS'];
|
||||
}
|
||||
|
||||
if ( isset($monitor['AnalysisFPS']) and ( $monitor['Function'] == 'Mocord' or $monitor['Function'] == 'Modect' ) ) {
|
||||
$fps_string .= ' / ' . $monitor['AnalysisFPS'];
|
||||
}
|
||||
if ($fps_string) $fps_string .= ' FPS';
|
||||
echo $fps_string;
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
if ( count($servers) ) { ?>
|
||||
|
|
|
@ -24,18 +24,18 @@ if ( !canView( 'Events' ) ) {
|
|||
}
|
||||
|
||||
if ( isset($_SESSION['export']) ) {
|
||||
if ( isset($_SESSION['export']['detail']) )
|
||||
$_REQUEST['exportDetail'] = $_SESSION['export']['detail'];
|
||||
if ( isset($_SESSION['export']['frames']) )
|
||||
$_REQUEST['exportFrames'] = $_SESSION['export']['frames'];
|
||||
if ( isset($_SESSION['export']['images']) )
|
||||
$_REQUEST['exportImages'] = $_SESSION['export']['images'];
|
||||
if ( isset($_SESSION['export']['video']) )
|
||||
$_REQUEST['exportVideo'] = $_SESSION['export']['video'];
|
||||
if ( isset($_SESSION['export']['misc']) )
|
||||
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
|
||||
if ( isset($_SESSION['export']['format']) )
|
||||
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
|
||||
if ( isset($_SESSION['export']['detail']) )
|
||||
$_REQUEST['exportDetail'] = $_SESSION['export']['detail'];
|
||||
if ( isset($_SESSION['export']['frames']) )
|
||||
$_REQUEST['exportFrames'] = $_SESSION['export']['frames'];
|
||||
if ( isset($_SESSION['export']['images']) )
|
||||
$_REQUEST['exportImages'] = $_SESSION['export']['images'];
|
||||
if ( isset($_SESSION['export']['video']) )
|
||||
$_REQUEST['exportVideo'] = $_SESSION['export']['video'];
|
||||
if ( isset($_SESSION['export']['misc']) )
|
||||
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
|
||||
if ( isset($_SESSION['export']['format']) )
|
||||
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
|
||||
}
|
||||
|
||||
$focusWindow = true;
|
||||
|
@ -101,24 +101,20 @@ elseif ( !empty($_REQUEST['eids']) )
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="button" id="exportButton" name="exportButton" value="<?php echo translate('Export') ?>" onclick="exportEvent( this.form );" disabled="disabled"/>
|
||||
<button id="exportButton" name="exportButton" value="Export" onclick="exportEvent(this.form);" disabled="disabled"><?php echo translate('Export') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
if ( isset($_REQUEST['generated']) )
|
||||
{
|
||||
if ( isset($_REQUEST['generated']) ) {
|
||||
?>
|
||||
<h2 id="exportProgress" class="<?php echo $_REQUEST['generated']?'infoText':'errorText' ?>"><span id="exportProgressText"><?php echo $_REQUEST['generated']?translate('ExportSucceeded'):translate('ExportFailed') ?></span><span id="exportProgressTicker"></span></h2>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
?>
|
||||
<h2 id="exportProgress" class="hidden warnText"><span id="exportProgressText"><?php echo translate('Exporting') ?></span><span id="exportProgressTicker"></span></h2>
|
||||
<?php
|
||||
}
|
||||
if ( !empty($_REQUEST['generated']) )
|
||||
{
|
||||
if ( !empty($_REQUEST['generated']) ) {
|
||||
?>
|
||||
<h3 id="downloadLink"><a href="<?php echo validHtmlStr($_REQUEST['exportFile']) ?>"><?php echo translate('Download') ?></a></h3>
|
||||
<?php
|
||||
|
|
|
@ -334,7 +334,7 @@ echo htmlSelect( 'filter[Query][sort_asc]', $sort_dirns, $filter->sort_asc() );
|
|||
</td>
|
||||
<td>
|
||||
<label for="filter[Query][limit]"><?php echo translate('LimitResultsPre') ?></label>
|
||||
<input type="text" id="filter[Query][limit]" name="filter[Query][limit]" value="<?php echo (null !== $filter->limit())?validInt($filter->limit()):'' ?>"/><?php echo translate('LimitResultsPost') ?>
|
||||
<input type="number" id="filter[Query][limit]" name="filter[Query][limit]" value="<?php echo (null !== $filter->limit())?validInt($filter->limit()):'' ?>"/><?php echo translate('LimitResultsPost') ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -16,6 +16,11 @@ function validateForm ( form ) {
|
|||
alert( errorBrackets );
|
||||
return false;
|
||||
}
|
||||
var numbers_reg = /\D/;
|
||||
if ( numbers_reg.test( form.elements['filter[Query][limit]'].value ) ) {
|
||||
alert( "There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty." );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ controlOptions[<?php echo $row['Id'] ?>][<?php echo $i ?>] = '<?php echo transla
|
|||
|
||||
var monitorNames = new Object();
|
||||
<?php
|
||||
$query = empty($_REQUEST['mid']) ? dbQuery('SELECT Name FROM Monitor') : dbQuery('SELECT Name FROM Monitors WHERE Id != ?', array($_REQUEST['mid']) );
|
||||
$query = empty($_REQUEST['mid']) ? dbQuery('SELECT Name FROM Monitors') : dbQuery('SELECT Name FROM Monitors WHERE Id != ?', array($_REQUEST['mid']) );
|
||||
if ( $query ) {
|
||||
while ( $name = dbFetchNext($query, 'Name') ) {
|
||||
?>
|
||||
|
|
|
@ -18,45 +18,44 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
if ( !canView( 'Events' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
if ( !canView( 'Events' ) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
$archivetype = $_REQUEST['type'];
|
||||
|
||||
if ( $archivetype ) {
|
||||
switch ($archivetype) {
|
||||
case "tar":
|
||||
$mimetype = "gzip";
|
||||
$file_ext = "tar.gz";
|
||||
break;
|
||||
case "zip":
|
||||
$mimetype = "zip";
|
||||
$file_ext = "zip";
|
||||
break;
|
||||
default:
|
||||
$mimetype = NULL;
|
||||
$file_ext = NULL;
|
||||
}
|
||||
switch ($archivetype) {
|
||||
case 'tar':
|
||||
$mimetype = 'gzip';
|
||||
$file_ext = 'tar.gz';
|
||||
break;
|
||||
case 'zip':
|
||||
$mimetype = 'zip';
|
||||
$file_ext = 'zip';
|
||||
break;
|
||||
default:
|
||||
$mimetype = NULL;
|
||||
$file_ext = NULL;
|
||||
}
|
||||
|
||||
if ( $mimetype ) {
|
||||
$filename = "zmExport.$file_ext";
|
||||
$filename_path = ZM_DIR_TEMP."/".$filename;
|
||||
if ( is_readable($filename_path) ) {
|
||||
header( "Content-type: application/$mimetype" );
|
||||
header( "Content-Disposition: attachment; filename=$filename");
|
||||
set_time_limit(0);
|
||||
readfile( $filename_path );
|
||||
} else {
|
||||
Error("$filename_path does not exist or is not readable.");
|
||||
}
|
||||
if ( $mimetype ) {
|
||||
$filename = "zmExport.$file_ext";
|
||||
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
||||
if ( is_readable($filename_path) ) {
|
||||
header( "Content-type: application/$mimetype" );
|
||||
header( "Content-Disposition: attachment; filename=$filename");
|
||||
set_time_limit(0);
|
||||
readfile( $filename_path );
|
||||
} else {
|
||||
Error("Unsupported archive type specified. Supported archives are tar and zip");
|
||||
Error("$filename_path does not exist or is not readable.");
|
||||
}
|
||||
} else {
|
||||
Error("Unsupported archive type specified. Supported archives are tar and zip");
|
||||
}
|
||||
} else {
|
||||
Error("No archive type given to archive.php. Please specify a tar or zip archive.");
|
||||
Error("No archive type given to archive.php. Please specify a tar or zip archive.");
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue