From 57cb6bb3f26e34b2ad7b066fe88d3a522fcbae1f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 6 Nov 2017 12:03:24 -0800 Subject: [PATCH 01/27] increase height of monitor --- web/skins/classic/js/classic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/js/classic.js b/web/skins/classic/js/classic.js index 084997e3a..a3bb53de8 100644 --- a/web/skins/classic/js/classic.js +++ b/web/skins/classic/js/classic.js @@ -47,7 +47,7 @@ var popupSizes = { 'log': { 'width': 1080, 'height': 720 }, 'login': { 'width': 720, 'height': 480 }, 'logout': { 'width': 260, 'height': 150 }, - 'monitor': { 'width': 700, 'height': 640 }, + 'monitor': { 'width': 700, 'height': 680 }, 'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorselect':{ 'width': 160, 'height': 200 }, From 14e9a13c9954e3ab809030f14735349bf2d82fa9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 9 Nov 2017 11:53:04 -0800 Subject: [PATCH 02/27] wip --- ...vsocket.html => _monitor_source_nvsocket.php} | 16 ++++++++++++---- web/skins/classic/views/event.php | 1 + web/skins/classic/views/monitor.php | 13 ++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) rename web/skins/classic/views/{_monitor_source_nvsocket.html => _monitor_source_nvsocket.php} (56%) diff --git a/web/skins/classic/views/_monitor_source_nvsocket.html b/web/skins/classic/views/_monitor_source_nvsocket.php similarity index 56% rename from web/skins/classic/views/_monitor_source_nvsocket.html rename to web/skins/classic/views/_monitor_source_nvsocket.php index 2a1567dfe..ebaf93861 100644 --- a/web/skins/classic/views/_monitor_source_nvsocket.html +++ b/web/skins/classic/views/_monitor_source_nvsocket.php @@ -1,13 +1,21 @@ - + - - () - () + + + Colours() ); ?> + + () + + + + () + + Orientation() );?> diff --git a/web/skins/classic/views/event.php b/web/skins/classic/views/event.php index 263009ffe..80d29bdc0 100644 --- a/web/skins/classic/views/event.php +++ b/web/skins/classic/views/event.php @@ -178,6 +178,7 @@ if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) { outputVideoStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), ZM_MPEG_LIVE_FORMAT ); } else { $streamSrc = $Event->getStreamSrc( array( 'mode'=>'jpeg', 'frame'=>$fid, 'scale'=>$scale, 'rate'=>$rate, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'replay'=>$replayMode) ); +Warning("Streamsrc: $streamSrc"); if ( canStreamNative() ) { outputImageStream( 'evtStream', $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), validHtmlStr($Event->Name()) ); } else { diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index ef15bf1e8..b29886b1e 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -392,9 +392,9 @@ if ( ZM_HAS_V4L2 ) { } $Colours = array( - translate('8BitGrey') => 1, - translate('24BitColour') => 3, - translate('32BitColour') => 4 + '1' => translate('8BitGrey'), + '3' => translate('24BitColour'), + '4' => translate('32BitColour') ); $orientations = array( @@ -803,7 +803,10 @@ switch ( $tab ) { Method() == 'v4l1' ) { ?> - + + + + Type() == 'NVSocket' ) { -include('monitor_source_nvsocket.php'); +include("_monitor_source_nvsocket.php"); } else if ( $monitor->Type() == 'Remote' ) { ?> Protocol(), "updateMethods( this );if(this.value=='rtsp'){\$('RTSPDescribe').setStyle('display','table-row');}else{\$('RTSPDescribe').hide();}" ); ?> From 121e64a8c6c13066ca55b334ccba997185d20456 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 11:40:07 -0800 Subject: [PATCH 03/27] turn on MOnitors dropdown in filters, an debug --- web/includes/database.php | 2 +- web/skins/classic/views/filter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/includes/database.php b/web/includes/database.php index bbfd588b0..941570b38 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -134,7 +134,7 @@ function dbQuery( $sql, $params=NULL ) { } else { $result = $dbConn->query( $sql ); } -if ( 0 ) { +if ( 1 ) { if ( $params ) Warning("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() ); else diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index cb7e30087..3beae54ad 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -229,7 +229,7 @@ for ( $i = 0; $i < count($terms); $i++ ) { Date: Wed, 22 Nov 2017 12:13:28 -0800 Subject: [PATCH 04/27] only try to write timecodes if the open was successful --- src/zm_event.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 830155452..b371cd09d 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -307,7 +307,8 @@ bool Event::WriteFrameVideo( const Image *image, const struct timeval timestamp, } /* Add the frame to the timecodes file */ - fprintf(timecodes_fd, "%u\n", timeMS); + if ( timecodes_fd ) + fprintf(timecodes_fd, "%u\n", timeMS); return( true ); } From 1392c1dfc20e5ab19764054908c711ef203571df Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 12:36:04 -0800 Subject: [PATCH 05/27] put back missing test for if db is local --- distros/ubuntu1604/zoneminder.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index 43509e835..13f6fac3c 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -17,7 +17,7 @@ if [ "$1" = "configure" ]; then a2enmod cgi fi - # Ensure zoneminder is stopped + if [ "$ZM_DB_HOST" = "localhost" ]; then if [ -e "/etc/init.d/mysql" ]; then # Do this every time the package is installed or upgraded From 02ec4bdebb5cb47ebe19e9a81828a16daee0af9e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 13:49:46 -0800 Subject: [PATCH 06/27] use StartDateTime instead of DateTime in filters, and get rid of Filters button at bottom --- web/skins/classic/views/console.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 8aaef178a..126421eb0 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -47,7 +47,7 @@ $eventCounts = array( 'filter' => array( 'Query' => array( 'terms' => array( - array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-1 day' ), + array( 'attr' => 'StartDateTime', 'op' => '>=', 'val' => '-1 day' ), ) ) ), @@ -58,7 +58,7 @@ $eventCounts = array( 'filter' => array( 'Query' => array( 'terms' => array( - array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-7 day' ), + array( 'attr' => 'StartDateTime', 'op' => '>=', 'val' => '-7 day' ), ) ) ), @@ -69,7 +69,7 @@ $eventCounts = array( 'filter' => array( 'Query' => array( 'terms' => array( - array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-1 month' ), + array( 'attr' => 'StartDateTime', 'op' => '>=', 'val' => '-1 month' ), ) ) ), @@ -272,7 +272,6 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { - From 1745c83d2f570cdbde211ab304bad6c40d77a7aa Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 14:04:07 -0800 Subject: [PATCH 07/27] add eventcount columns to Monitors --- db/zm_create.sql.in | 5 ++++ db/zm_update-1.31.14.sql | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 db/zm_update-1.31.14.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 91089ff2d..ea37d9ffa 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -434,6 +434,11 @@ CREATE TABLE `Monitors` ( `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, + `HourEvents` int(10) unsigned, + `DayEvents` int(10) unsigned, + `WeekEvents` int(10) unsigned, + `MonthEvents` int(10) unsigned, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.31.14.sql b/db/zm_update-1.31.14.sql new file mode 100644 index 000000000..f6c2af314 --- /dev/null +++ b/db/zm_update-1.31.14.sql @@ -0,0 +1,65 @@ + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'TotalEvents' + ) > 0, +"SELECT 'Column TotalEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `TotalEvents` INT(10) AFTER `AnalysisFPS`" +)); + +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 = 'HourEvents' + ) > 0, +"SELECT 'Column HourEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `HourEvents` INT(10) AFTER `TotalEvents`" +)); + + +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 = 'DayEvents' + ) > 0, +"SELECT 'Column DayEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `DayEvents` INT(10) AFTER `HourEvents`" +)); + + +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 = 'WeekEvents' + ) > 0, +"SELECT 'Column WeekEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `WeekEvents` INT(10) AFTER `DayEvents`" +)); + + +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 = 'WeekEvents' + ) > 0, +"SELECT 'Column MonthEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `MonthEvents` INT(10) AFTER `WeekEvents`" +)); + + +PREPARE stmt FROM @s; +EXECUTE stmt; + From 1fe421ed9d1b540c8a23b430ec7f4582cc98c774 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 14:22:12 -0800 Subject: [PATCH 08/27] add DiskSpace columns to Monitors --- db/zm_create.sql.in | 5 ++++ db/zm_update-1.31.14.sql | 59 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index ea37d9ffa..7a394c7be 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -435,10 +435,15 @@ CREATE TABLE `Monitors` ( `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, + `HourEventDiskSpace` bigint unsigned, `DayEvents` int(10) unsigned, + `DayEventDiskSpace` bigint unsigned, `WeekEvents` int(10) unsigned, + `WeekEventDiskSpace` bigint unsigned, `MonthEvents` int(10) unsigned, + `MonthEventDiskSpace` bigint unsigned, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.31.14.sql b/db/zm_update-1.31.14.sql index f6c2af314..859b28162 100644 --- a/db/zm_update-1.31.14.sql +++ b/db/zm_update-1.31.14.sql @@ -11,6 +11,18 @@ SET @s = (SELECT IF( 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 = 'TotalEventDiskSpace' + ) > 0, +"SELECT 'Column TotalEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `TotalEventDiskSpace` BIGINT AFTER `TotalEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' @@ -21,6 +33,18 @@ SET @s = (SELECT IF( )); +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 = 'HourEventDiskSpace' + ) > 0, +"SELECT 'Column HourEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `HourEventDiskSpace` BIGINT AFTER `HourEvents`" +)); + PREPARE stmt FROM @s; EXECUTE stmt; @@ -37,6 +61,17 @@ SET @s = (SELECT IF( 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 = 'DayEventDiskSpace' + ) > 0, +"SELECT 'Column DayEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `DayEventDiskSpace` BIGINT AFTER `DayEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' @@ -53,7 +88,18 @@ EXECUTE stmt; SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' - AND column_name = 'WeekEvents' + AND column_name = 'WeekEventDiskSpace' + ) > 0, +"SELECT 'Column WeekEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `WeekEventDiskSpace` BIGINT AFTER `WeekEvents`" +)); + +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 = 'MonthEvents' ) > 0, "SELECT 'Column MonthEvents already exists in Monitors'", "ALTER TABLE `Monitors` ADD `MonthEvents` INT(10) AFTER `WeekEvents`" @@ -63,3 +109,14 @@ SET @s = (SELECT IF( 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 = 'MonthEventDiskSpace' + ) > 0, +"SELECT 'Column MonthEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `MonthEventDiskSpace` BIGINT AFTER `MonthEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; From 9d6b417b60c2952480be56689943cb0de8ee7b5e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 17:03:37 -0800 Subject: [PATCH 09/27] make zmwatch.pl update columns in the Monitors table for Event And DiskSpace counts --- db/zm_create.sql.in | 2 ++ db/zm_update-1.31.14.sql | 26 +++++++++++++++++++ scripts/zmwatch.pl.in | 23 ++++++++++++++++- web/skins/classic/views/console.php | 40 +++++++++++++---------------- 4 files changed, 68 insertions(+), 23 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 7a394c7be..46e0dad63 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -444,6 +444,8 @@ CREATE TABLE `Monitors` ( `WeekEventDiskSpace` bigint unsigned, `MonthEvents` int(10) unsigned, `MonthEventDiskSpace` bigint unsigned, + `ArchivedEvents` int(10) unsigned, + `ArchivedEventDiskSpace` bigint unsigned, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.31.14.sql b/db/zm_update-1.31.14.sql index 859b28162..29e0f4a42 100644 --- a/db/zm_update-1.31.14.sql +++ b/db/zm_update-1.31.14.sql @@ -96,6 +96,7 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; + SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' @@ -120,3 +121,28 @@ SET @s = (SELECT IF( 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 = 'ArchivedEvents' + ) > 0, +"SELECT 'Column ArchivedEvents already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `ArchivedEvents` INT(10) AFTER `MonthEvents`" +)); + + +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 = 'ArchivedEventDiskSpace' + ) > 0, +"SELECT 'Column ArchivedEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `ArchivedEventDiskSpace` BIGINT AFTER `ArchivedEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index c1a2d78e7..575dee560 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -79,6 +79,23 @@ my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'S my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $eventcounts_sql = q`UPDATE Monitors SET +TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id), + TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL), + HourEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 hour) ), + HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL), + DayEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day)), + DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day) AND DiskSpace IS NOT NULL), + WeekEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week)), + WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week) AND DiskSpace IS NOT NULL), + MonthEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 month)), + MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 month) AND DiskSpace IS NOT NULL), + ArchivedEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1), + ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL) + WHERE Id=?`; + + my $eventcounts_sth = $dbh->prepare_cached( $eventcounts_sql ); + while( 1 ) { my $now = time(); my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () ) @@ -175,9 +192,13 @@ while( 1 ) { } # end if check analysis daemon # Prevent open handles building up if we have connect to shared memory zmMemInvalidate( $monitor ); # Close our file handle to the zmc process we are about to end + $eventcounts_sth->execute( $$monitor{Id} ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); + } # end foreach monitor + $eventcounts_sth->finish(); + my $diskspace_sql = 'UPDATE Storage SET DiskSpace =(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL)'; - my $diskspace_sth = $dbh->prepare_cached( $sql ) + my $diskspace_sth = $dbh->prepare_cached( $diskspace_sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); foreach my $Storage ( ZoneMinder::Storage->find() ) { Error("Updating disk space for $$Storage{Name}"); diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 126421eb0..570f44112 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -22,7 +22,7 @@ if ( $running == null ) $running = daemonCheck(); $eventCounts = array( - array( +'Total'=> array( 'title' => translate('Events'), 'filter' => array( 'Query' => array( @@ -31,7 +31,7 @@ $eventCounts = array( ), 'total' => 0, ), - array( + 'Hour'=>array( 'title' => translate('Hour'), 'filter' => array( 'Query' => array( @@ -42,7 +42,7 @@ $eventCounts = array( ), 'total' => 0, ), - array( + 'Day'=>array( 'title' => translate('Day'), 'filter' => array( 'Query' => array( @@ -53,7 +53,7 @@ $eventCounts = array( ), 'total' => 0, ), - array( + 'Week'=>array( 'title' => translate('Week'), 'filter' => array( 'Query' => array( @@ -64,7 +64,7 @@ $eventCounts = array( ), 'total' => 0, ), - array( + 'Month'=>array( 'title' => translate('Month'), 'filter' => array( 'Query' => array( @@ -75,7 +75,7 @@ $eventCounts = array( ), 'total' => 0, ), - array( + 'Archived'=>array( 'title' => translate('Archived'), 'filter' => array( 'Query' => array( @@ -113,22 +113,16 @@ for ( $i = 0; $i < count($displayMonitors); $i++ ) { $zoneCount += $monitor['ZoneCount']; $counts = array(); - for ( $j = 0; $j < count($eventCounts); $j += 1 ) { + foreach ( array_keys( $eventCounts ) as $j ) { $filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['Query']['terms']), array( 'cnj' => 'and', 'attr' => 'MonitorId', 'op' => '=', 'val' => $monitor['Id'] ) ); parseFilter( $filter ); - $counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) AS EventCount$j, SUM(if(1".$filter['sql'].",DiskSpace,NULL)) As DiskSpace$j"; + #$counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) AS EventCount$j, SUM(if(1".$filter['sql'].",DiskSpace,NULL)) As DiskSpace$j"; $monitor['eventCounts'][$j]['filter'] = $filter; - } - $sql = 'SELECT '.join($counts,', ').' FROM Events as E where MonitorId = ?'; - $counts = dbFetchOne( $sql, NULL, array($monitor['Id']) ); - if ( $counts ) - $monitor = array_merge( $monitor, $counts ); - for ( $j = 0; $j < count($eventCounts); $j += 1 ) { - $eventCounts[$j]['total'] += $monitor['EventCount'.$j]; + $eventCounts[$j]['total'] = $monitor[$j.'Events']; } unset($monitor); } // end foreach display monitor @@ -169,9 +163,11 @@ xhtmlHeaders( __FILE__, translate('Console') ); - - - + + + + + disabled="disabled"/> @@ -242,10 +238,10 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { ' . human_filesize($monitor['DiskSpace'.$i]), canView( 'Events' ) ) ?> + $monitor[$i.'Events'] . '
' . human_filesize($monitor[$i.'EventDiskSpace']), canView( 'Events' ) ) ?> @@ -276,8 +272,8 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { Date: Thu, 23 Nov 2017 09:02:09 -0500 Subject: [PATCH 10/27] bump up to 1.31.14 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 623203d2d..f5e39ba92 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.12 +1.31.14 From 485567349d99e7d6b4539f913e9d663cbf1e48f3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 23 Nov 2017 07:29:05 -0800 Subject: [PATCH 11/27] Don't calc DiskSpace if it is already defined --- scripts/zmwatch.pl.in | 17 +++++++++++------ web/includes/Storage.php | 30 ++++++++++++++++-------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 575dee560..aff7d1fc7 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -79,8 +79,9 @@ my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'S my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $eventcounts_sql = q`UPDATE Monitors SET -TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id), +my $eventcounts_sql = q` +UPDATE Monitors SET + TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id), TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL), HourEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 hour) ), HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL), @@ -94,13 +95,13 @@ TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id), ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL) WHERE Id=?`; - my $eventcounts_sth = $dbh->prepare_cached( $eventcounts_sql ); +my $eventcounts_sth = $dbh->prepare_cached( $eventcounts_sql ); while( 1 ) { - my $now = time(); my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () ) or Fatal( "Can't execute: ".$sth->errstr() ); while( my $monitor = $sth->fetchrow_hashref() ) { + my $now = time(); next if $monitor->{Function} eq 'None'; my $restart = 0; if ( zmMemVerify( $monitor ) ) { @@ -192,6 +193,8 @@ while( 1 ) { } # end if check analysis daemon # Prevent open handles building up if we have connect to shared memory zmMemInvalidate( $monitor ); # Close our file handle to the zmc process we are about to end + + $eventcounts_sth->execute( $$monitor{Id} ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); } # end foreach monitor @@ -199,10 +202,12 @@ while( 1 ) { my $diskspace_sql = 'UPDATE Storage SET DiskSpace =(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL)'; my $diskspace_sth = $dbh->prepare_cached( $diskspace_sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + or Fatal( "Can't prepare '$diskspace_sql': ".$dbh->errstr() ); foreach my $Storage ( ZoneMinder::Storage->find() ) { - Error("Updating disk space for $$Storage{Name}"); + Debug("Updating disk space for $$Storage{Name} was $$Storage{DiskSpace}"); $diskspace_sth->execute( $$Storage{Id} ) or Error( "Can't execute: ".$diskspace_sth->errstr() ); + $Storage->load(); + Debug("Updated disk space for $$Storage{Name} to $$Storage{DiskSpace}"); } $diskspace_sth->finish(); sleep( $Config{ZM_WATCH_CHECK_INTERVAL} ); diff --git a/web/includes/Storage.php b/web/includes/Storage.php index cc52b5c65..a227f2652 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -110,23 +110,25 @@ class Storage { } public function disk_used_space() { # This isn't a function like this in php, so we have to add up the space used in each event. - if ( ! array_key_exists( 'disk_used_space', $this ) ) { - $used = 0; - if ( $this->{'Type'} == 's3fs' ) { - $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); + if ( ! array_key_exists( 'DiskSpace', $this ) ) { + $used = $this->{'DiskSpace'}; + if ( ! $used ) { + if ( $this->{'Type'} == 's3fs' ) { + $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); - foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) { - $Event->Storage( $this ); // Prevent further db hit - $used += $Event->DiskSpace(); - } - } else { - $path = $this->Path(); - $used = disk_total_space( $path ) - disk_free_space( $path );; - } - $this->{'disk_used_space'} = $used; + foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) { + $Event->Storage( $this ); // Prevent further db hit + $used += $Event->DiskSpace(); + } + } else { + $path = $this->Path(); + $used = disk_total_space( $path ) - disk_free_space( $path );; + } + } # end if + $this->{'DiskSpace'} = $used; } - return $this->{'disk_used_space'}; + return $this->{'DiskSpace'}; } } ?> From 900fbe1e0fa6b9ebd1b3d277cd5de215fb7baffb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 23 Nov 2017 08:26:55 -0800 Subject: [PATCH 12/27] update save to a button tag, and add a saveas functionality --- web/includes/actions.php | 4 ++-- web/skins/classic/views/filter.php | 7 ++++--- web/skins/classic/views/js/filter.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 24184d7db..d081d5c11 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -151,7 +151,7 @@ Warning("Addterm"); if ( ! empty($_REQUEST['Id']) ) { dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['Id'] ) ); } - } else if ( ( $action == 'save' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) { + } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) { $sql = ''; $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); @@ -175,7 +175,7 @@ Warning("Addterm"); $sql .= ', Background = '. ( !empty($_REQUEST['filter']['Background']) ? 1 : 0); $sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0); - if ( $_REQUEST['Id'] ) { + if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { dbQuery( 'UPDATE Filters SET ' . $sql. ' WHERE Id=?', array($_REQUEST['Id']) ); } else { dbQuery( 'INSERT INTO Filters SET' . $sql ); diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 3beae54ad..002a08823 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -403,7 +403,8 @@ if ( ZM_OPT_MESSAGE ) { - + + Id() ) { ?> @@ -415,6 +416,6 @@ if ( canEdit( 'Events' ) ) { - - + + diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index ff93716c5..eed12a7f0 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -63,7 +63,7 @@ function saveFilter( element ) { //form.target = 'zmFilter'; form.target = window.name; - form.elements['action'].value = 'save'; + form.elements['action'].value = element.value; form.action = thisUrl + '?view=filter'; form.submit(); } From 07907b5c1c79169e7d1acf2c62f45354fbee3b4f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 09:28:24 -0500 Subject: [PATCH 13/27] Change from Warning to Debug --- scripts/zmwatch.pl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 575dee560..2abd8bba8 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -201,7 +201,7 @@ while( 1 ) { my $diskspace_sth = $dbh->prepare_cached( $diskspace_sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); foreach my $Storage ( ZoneMinder::Storage->find() ) { - Error("Updating disk space for $$Storage{Name}"); + Debug("Updating disk space for $$Storage{Name}"); $diskspace_sth->execute( $$Storage{Id} ) or Error( "Can't execute: ".$diskspace_sth->errstr() ); } $diskspace_sth->finish(); From 7e3328fbb8d7debd572ef1fd474e3f173e28412c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 09:36:45 -0500 Subject: [PATCH 14/27] add styles to the html5 button element --- web/skins/classic/css/dark/skin.css | 3 +++ web/skins/classic/css/flat/skin.css | 3 +++ 2 files changed, 6 insertions(+) diff --git a/web/skins/classic/css/dark/skin.css b/web/skins/classic/css/dark/skin.css index 1cef117e2..f34898393 100644 --- a/web/skins/classic/css/dark/skin.css +++ b/web/skins/classic/css/dark/skin.css @@ -459,6 +459,7 @@ th.table-th-sort-rev span.table-th-sort-span { margin: 8px auto; } +button, input[type=button], input[type=submit] { background-color: #3498db; @@ -470,6 +471,7 @@ input[type=submit] { cursor: pointer; } +button:hover, input[type=button]:hover, input[type=submit]:hover { background-color: #34a2ee; @@ -479,6 +481,7 @@ input[type=submit]:hover { /* PP - make it easy to identify disabled buttons */ +button:disabled, input[type=button]:disabled, input[type=submit]:disabled { background-color: #aaaaaa; diff --git a/web/skins/classic/css/flat/skin.css b/web/skins/classic/css/flat/skin.css index e60653a41..2752d0056 100644 --- a/web/skins/classic/css/flat/skin.css +++ b/web/skins/classic/css/flat/skin.css @@ -459,6 +459,7 @@ th.table-th-sort-rev span.table-th-sort-span { margin: 8px auto; } +button, input[type=button], input[type=submit] { background-color: #3498db; @@ -470,6 +471,7 @@ input[type=submit] { cursor: pointer; } +button:hover, input[type=button]:hover, input[type=submit]:hover { background-color: #34a2ee; @@ -479,6 +481,7 @@ input[type=submit]:hover { /* PP - make it easy to identify disabled buttons */ +button:disabled, input[type=button]:disabled, input[type=submit]:disabled { background-color: #aaaaaa; From 4b92a788f7b28213767e46cb6a66f6225d4af27d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 15:37:50 -0500 Subject: [PATCH 15/27] fix filter execute --- db/zm_create.sql.in | 1 + scripts/zmwatch.pl.in | 16 +++---- src/zm_monitor.cpp | 25 ++++++----- web/includes/Monitor.php | 1 + web/includes/actions.php | 15 +++++-- web/index.php | 4 +- web/skins/classic/css/classic/skin.css | 45 ++++++++++++++++--- .../classic/css/classic/views/filter.css | 4 ++ web/skins/classic/css/dark/skin.css | 28 ++++++------ web/skins/classic/css/flat/views/console.css | 4 -- web/skins/classic/views/console.php | 1 - web/skins/classic/views/events.php | 3 -- web/skins/classic/views/filter.php | 8 ++-- web/skins/classic/views/js/filter.js | 7 +++ 14 files changed, 105 insertions(+), 57 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 46e0dad63..2685e27d1 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -446,6 +446,7 @@ CREATE TABLE `Monitors` ( `MonthEventDiskSpace` bigint unsigned, `ArchivedEvents` int(10) unsigned, `ArchivedEventDiskSpace` bigint unsigned, + `ZoneCount` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index aff7d1fc7..67e47f6a6 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -106,15 +106,15 @@ while( 1 ) { my $restart = 0; if ( zmMemVerify( $monitor ) ) { # Check we have got an image recently - my $image_time = zmGetLastWriteTime( $monitor ); - if ( !defined($image_time) ) { + my $capture_time = zmGetLastWriteTime( $monitor ); + if ( !defined($capture_time) ) { # Can't read from shared data Debug( "LastWriteTime is not defined." ); zmMemInvalidate( $monitor ); next; } - Debug( "LastWriteTime is = $image_time." ); - if ( !$image_time ) { + Debug( "LastWriteTime is = $capture_time." ); + if ( !$capture_time ) { my $startup_time = zmGetStartupTime( $monitor ); if ( $now - $startup_time > $Config{ZM_WATCH_MAX_DELAY} ) { Info( "Restarting capture daemon for ".$monitor->{Name}.", no image since startup. Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}\n" ); @@ -122,7 +122,7 @@ while( 1 ) { } else { # We can't get the last capture time so can't be sure it's died, it might just be starting up. zmMemInvalidate( $monitor ); - next; + next; } } if ( ! $restart ) { @@ -132,11 +132,11 @@ while( 1 ) { ) ? (3/$monitor->{MaxFPS}) : $Config{ZM_WATCH_MAX_DELAY} ; - my $image_delay = $now-$image_time; + my $image_delay = $now-$capture_time; Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" ); if ( $image_delay > $max_image_delay ) { Info( "Restarting capture daemon for " - .$monitor->{Name}.", time since last capture $image_delay seconds ($now-$image_time)\n" + .$monitor->{Name}.", time since last capture $image_delay seconds ($now-$capture_time)\n" ); $restart = 1; } @@ -166,7 +166,7 @@ while( 1 ) { } elsif ( !$image_time ) { # We can't get the last capture time so can't be sure it's died. $restart = 1; - Error( "Error getting last capture time for $$monitor{Id} $$monitor{Name}\n"); + Error( "Error getting last analyse time for $$monitor{Id} $$monitor{Name}\n"); } else { my $max_image_delay = ( $monitor->{MaxFPS} diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 4933bd0fc..977f2da49 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -605,7 +605,7 @@ Monitor::~Monitor() { } if ( mem_ptr ) { if ( event ) { - Info( "%s: %03d - Closing event %d, shutting down", name, image_count, event->Id() ); + Info( "%s: image_count:%d - Closing event %d, shutting down", name, image_count, event->Id() ); closeEvent(); } @@ -775,26 +775,29 @@ unsigned int Monitor::GetLastEvent() const { return( shared_data->last_event ); } +// This function is crap. double Monitor::GetFPS() const { int index1 = shared_data->last_write_index; if ( index1 == image_buffer_count ) { - return( 0.0 ); + // last_write_index only has this value on startup before capturing anything. + return 0.0; } Snapshot *snap1 = &image_buffer[index1]; if ( !snap1->timestamp || !snap1->timestamp->tv_sec ) { - return( 0.0 ); + // This should be impossible + return 0.0; } struct timeval time1 = *snap1->timestamp; int image_count = image_buffer_count; int index2 = (index1+1)%image_buffer_count; - if ( index2 == image_buffer_count ) { - return( 0.0 ); - } Snapshot *snap2 = &image_buffer[index2]; + // the timestamp pointers are initialized on connection, so that's redundant + // tv_sec is probably only zero during the first loop of capturing, so this basically just counts the unused images. while ( !snap2->timestamp || !snap2->timestamp->tv_sec ) { if ( index1 == index2 ) { - return( 0.0 ); + // We didn't find any initialized images + return 0.0; } index2 = (index2+1)%image_buffer_count; snap2 = &image_buffer[index2]; @@ -807,10 +810,10 @@ double Monitor::GetFPS() const { double curr_fps = image_count/time_diff; if ( curr_fps < 0.0 ) { - //Error( "Negative FPS %f, time_diff = %lf (%d:%ld.%ld - %d:%ld.%ld), ibc: %d", curr_fps, time_diff, index2, time2.tv_sec, time2.tv_usec, index1, time1.tv_sec, time1.tv_usec, image_buffer_count ); - return( 0.0 ); + Error( "Negative FPS %f, time_diff = %lf (%d:%ld.%ld - %d:%ld.%ld), ibc: %d", curr_fps, time_diff, index2, time2.tv_sec, time2.tv_usec, index1, time1.tv_sec, time1.tv_usec, image_buffer_count ); + return 0.0; } - return( curr_fps ); + return curr_fps; } useconds_t Monitor::GetAnalysisRate() { @@ -2983,7 +2986,7 @@ Debug(4, "Return from Capture (%d)", captureResult); fps = double(fps_report_interval)/(now-last_fps_time); Info( "%d -> %d -> %d", fps_report_interval, now, last_fps_time ); //Info( "%d -> %d -> %lf -> %lf", now-last_fps_time, fps_report_interval/(now-last_fps_time), double(fps_report_interval)/(now-last_fps_time), fps ); - Info( "%s: %d - Capturing at %.2lf fps", name, image_count, fps ); + 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 ); diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index edc946c0c..157088e83 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -17,6 +17,7 @@ private $defaults = array( 'AnalysisFPSLimit' => null, 'AnalysisFPS' => null, 'CaptureFPS' => null, +'ZoneCount' => 0, ); private $control_fields = array( 'Name' => '', diff --git a/web/includes/actions.php b/web/includes/actions.php index d081d5c11..1a2a13d56 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -151,14 +151,16 @@ Warning("Addterm"); if ( ! empty($_REQUEST['Id']) ) { dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['Id'] ) ); } - } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) { + } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) { + # or ( $action == 'submit' ) ) { $sql = ''; $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); $_REQUEST['filter']['Query']['sort_asc'] = validStr($_REQUEST['filter']['Query']['sort_asc']); $_REQUEST['filter']['Query']['limit'] = validInt($_REQUEST['filter']['Query']['limit']); - if ( $action == 'execute' or $action == 'submit' ) { - $sql .= ' Name = \'_TempFilter'.time().'\''; + if ( $action == 'execute' ) { + $tempFilterName = '_TempFilter'.time(); + $sql .= ' Name = \''.$tempFilterName.'\''; } else { $sql .= ' Name = '.dbEscape($_REQUEST['filter']['Name']); } @@ -181,6 +183,9 @@ Warning("Addterm"); dbQuery( 'INSERT INTO Filters SET' . $sql ); $_REQUEST['Id'] = dbInsertId(); } + if ( $action == 'execute' ) { + executeFilter( $tempFilterName ); + } } // end if save or execute } // end if canEdit(Events) @@ -370,6 +375,7 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) { dbQuery( "UPDATE Zones SET ".implode( ", ", $changes )." WHERE MonitorId=? AND Id=?", array( $mid, $zid) ); } else { dbQuery( "INSERT INTO Zones SET MonitorId=?, ".implode( ", ", $changes ), array( $mid ) ); + dbQuery( 'UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id) WHERE Id=?', array($mid)); } //if ( $cookies ) session_write_close(); if ( daemonCheck() ) { @@ -422,6 +428,7 @@ if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) { foreach( $_REQUEST['markZids'] as $markZid ) { $zone = dbFetchOne( 'select * from Zones where Id=?', NULL, array($markZid) ); dbQuery( 'delete from Zones WHERE MonitorId=? AND Id=?', array( $mid, $markZid) ); + dbQuery( 'UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id) WHERE Id=?', array($mid)); $deletedZid = 1; } if ( $deletedZid ) { @@ -601,10 +608,10 @@ if ( canEdit( 'Monitors' ) ) { } // end if ZM_OPT_FAST_DELETE // This is the important stuff - dbQuery( 'DELETE FROM Monitors WHERE Id = ?', array($markMid) ); dbQuery( 'DELETE FROM Zones WHERE MonitorId = ?', array($markMid) ); if ( ZM_OPT_X10 ) dbQuery( 'DELETE FROM TriggersX10 WHERE MonitorId=?', array($markMid) ); + dbQuery( 'DELETE FROM Monitors WHERE Id = ?', array($markMid) ); fixSequences(); diff --git a/web/index.php b/web/index.php index 1829f289b..c554542b3 100644 --- a/web/index.php +++ b/web/index.php @@ -34,14 +34,14 @@ if ( version_compare( phpversion(), '4.1.0', '<') ) { } // Useful debugging lines for mobile devices -if ( true ) { +//if ( true ) { ob_start(); phpinfo( INFO_VARIABLES ); $fp = fopen( '/tmp/env.html', 'w' ); fwrite( $fp, ob_get_contents() ); fclose( $fp ); ob_end_clean(); -} +//} require_once( 'includes/config.php' ); require_once( 'includes/logger.php' ); diff --git a/web/skins/classic/css/classic/skin.css b/web/skins/classic/css/classic/skin.css index 1d5af9a16..218f42e7a 100644 --- a/web/skins/classic/css/classic/skin.css +++ b/web/skins/classic/css/classic/skin.css @@ -95,9 +95,6 @@ input.noborder { border: 0; } -input[disabled] { - color: #888888; -} img { display: inline-block; @@ -407,11 +404,15 @@ th.table-th-sort-rev span.table-th-sort-span { } */ -#content > input[type=submit], #content > input[type=button], #content > button { +#content > input[type=submit], +#content > input[type=button], +#content > button { margin-top: 8px; } -#content table input[type=submit], #content table input[type=button], #content table button { +#content table input[type=submit], +#content table input[type=button], +#content table button { margin-top: 0; } @@ -420,6 +421,7 @@ th.table-th-sort-rev span.table-th-sort-span { float: right; } +#contentButtons button, #contentButtons input { margin-left: 8px; margin-bottom: 4px; @@ -487,3 +489,36 @@ margin-left: 0px; .nav-pills > li > a { border-radius: 0; } + +button, +input[type=button], +input[type=submit] { + padding: 1px 6px; + /* + background-color: #3498db; + color: #fff; + border-color: #3498db; + font-weight: 200; + padding: 5px 10px; + cursor: pointer; + */ +} + +button:hover, +input[type=button]:hover, +input[type=submit]:hover { + /* + background-color: #34a2ee; + */ +} + +button:disabled, +input[disabled], +input[type=button]:disabled, +input[type=submit]:disabled { + color: #888888; + /* + background-color: #aaaaaa; + */ + border-color: #bbbbbb; +} diff --git a/web/skins/classic/css/classic/views/filter.css b/web/skins/classic/css/classic/views/filter.css index 35bab224d..b392d1573 100644 --- a/web/skins/classic/css/classic/views/filter.css +++ b/web/skins/classic/css/classic/views/filter.css @@ -31,3 +31,7 @@ table.filterTable { width: 300px; text-align: right; } + +input#filter\[Name\] { + width: 400px; +} diff --git a/web/skins/classic/css/dark/skin.css b/web/skins/classic/css/dark/skin.css index f34898393..799a2ba7c 100644 --- a/web/skins/classic/css/dark/skin.css +++ b/web/skins/classic/css/dark/skin.css @@ -108,9 +108,6 @@ input.noborder { border: 0; } -input[disabled] { - color: #777777; -} img { display: inline-block; @@ -449,6 +446,7 @@ th.table-th-sort-rev span.table-th-sort-span { float: right; } +#contentButtons button, #contentButtons input { margin-left: 8px; margin-bottom: 4px; @@ -462,31 +460,31 @@ th.table-th-sort-rev span.table-th-sort-span { button, input[type=button], input[type=submit] { - background-color: #3498db; - color: #fff; - border-color: #3498db; - text-transform: uppercase; - font-weight: 200; - padding: 5px 10px; - cursor: pointer; + background-color: #3498db; + color: #fff; + border-color: #3498db; + text-transform: uppercase; + font-weight: 200; + padding: 5px 10px; + cursor: pointer; } button:hover, input[type=button]:hover, input[type=submit]:hover { - background-color: #34a2ee; - + background-color: #34a2ee; } /* PP - make it easy to identify disabled buttons */ button:disabled, +input[disabled], input[type=button]:disabled, input[type=submit]:disabled { - background-color: #aaaaaa; - border-color: #bbbbbb; - + color: #ffffff; + background-color: #aaaaaa; + border-color: #bbbbbb; } /* diff --git a/web/skins/classic/css/flat/views/console.css b/web/skins/classic/css/flat/views/console.css index fdf1cfb63..db84313d0 100644 --- a/web/skins/classic/css/flat/views/console.css +++ b/web/skins/classic/css/flat/views/console.css @@ -90,7 +90,3 @@ #consoleTable .colLeftButtons { text-align: left; } - -#consoleTable .colLeftButtons input { - margin-right: 24px; -} diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 570f44112..d1403cb54 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -109,7 +109,6 @@ for ( $i = 0; $i < count($displayMonitors); $i++ ) { } $monitor['zmc'] = zmcStatus( $monitor ); $monitor['zma'] = zmaStatus( $monitor ); - $monitor['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitor['Id']) ); $zoneCount += $monitor['ZoneCount']; $counts = array(); diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index d2dfa1f1d..0166fb6b1 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -25,9 +25,6 @@ if ( !canView( 'Events' ) || (!empty($_REQUEST['execute']) && !canEdit('Events') require_once( 'includes/Event.php' ); -if ( !empty($_REQUEST['execute']) ) { - executeFilter( $tempFilterName ); -} $countSql = 'SELECT count(E.Id) AS EventCount FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE'; $eventsSql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultScale FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE'; diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 002a08823..8b8961f8b 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -148,7 +148,7 @@ if ( (null !== $filter->Concurrent()) and $filter->Concurrent() )
-

+

@@ -398,13 +398,13 @@ if ( ZM_OPT_MESSAGE ) {
- + - - + + Id() ) { ?> diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index eed12a7f0..2a525d1b2 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -23,6 +23,13 @@ function updateButtons( element ) { canExecute = true; form.elements['executeButton'].disabled = !canExecute; } + if ( form.elements['filter[Name]'].value ) { + form.elements['Save'].disabled = false; + form.elements['SaveAs'].disabled = false; + } else { + form.elements['Save'].disabled = true; + form.elements['SaveAs'].disabled = true; + } } function clearValue( element, line ) { From c0e49b65efe931760168403b1412bb826d296a1c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 15:38:07 -0500 Subject: [PATCH 16/27] stop writing env to /tmp/env --- web/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/index.php b/web/index.php index c554542b3..845540327 100644 --- a/web/index.php +++ b/web/index.php @@ -34,14 +34,14 @@ if ( version_compare( phpversion(), '4.1.0', '<') ) { } // Useful debugging lines for mobile devices -//if ( true ) { +if ( false ) { ob_start(); phpinfo( INFO_VARIABLES ); $fp = fopen( '/tmp/env.html', 'w' ); fwrite( $fp, ob_get_contents() ); fclose( $fp ); ob_end_clean(); -//} +} require_once( 'includes/config.php' ); require_once( 'includes/logger.php' ); From 8a40a613bfb86e1ceb7378d831bc05e868e6fd79 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 15:42:20 -0500 Subject: [PATCH 17/27] bump version --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index f5e39ba92..604636091 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.14 +1.31.15 From b1bb0020d3c7c25ef22d7525972751041a278f4f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 24 Nov 2017 15:42:44 -0500 Subject: [PATCH 18/27] turn off database debug --- web/includes/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/database.php b/web/includes/database.php index a1bcf66c3..227de8132 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -134,7 +134,7 @@ function dbQuery( $sql, $params=NULL ) { } else { $result = $dbConn->query( $sql ); } -if ( 1 ) { +if ( 0 ) { if ( $params ) Warning("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() ); else From d6bc727c9cb2131bbf9b5cbf11a7d5362cef831b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 11:12:00 -0500 Subject: [PATCH 19/27] use htmlSelect to create the Colours dropdown, which fixes a problem caused when I inverted the Colours array --- web/skins/classic/views/monitor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 7202a430d..7e240092b 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -868,7 +868,8 @@ include('_monitor_source_nvsocket.php'); } if ( $monitor->Type() != 'NVSocket' ) { ?> - + Colours() ); ?> + () () From 4a884afecb70f89fdf8b00feab54d68f60c3c1f3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 15:08:12 -0500 Subject: [PATCH 20/27] need the update file --- db/zm_update-1.31.15.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 db/zm_update-1.31.15.sql diff --git a/db/zm_update-1.31.15.sql b/db/zm_update-1.31.15.sql new file mode 100644 index 000000000..4c017aa52 --- /dev/null +++ b/db/zm_update-1.31.15.sql @@ -0,0 +1,14 @@ + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'ZoneCount' + ) > 0, +"SELECT 'Column ZoneCount already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `ZoneCount` TINYINT NOT NULL DEFAULT 0 AFTER `ArchivedEventDiskSpace`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id); From dd3f9492ba35acc5893f76db8110875d130a6f8a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 15:12:35 -0500 Subject: [PATCH 21/27] fix dulicate logic --- web/includes/Storage.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/web/includes/Storage.php b/web/includes/Storage.php index a227f2652..e14d00e92 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -111,20 +111,18 @@ class Storage { public function disk_used_space() { # This isn't a function like this in php, so we have to add up the space used in each event. if ( ! array_key_exists( 'DiskSpace', $this ) ) { - $used = $this->{'DiskSpace'}; - if ( ! $used ) { - if ( $this->{'Type'} == 's3fs' ) { - $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); + $used = 0; + if ( $this->{'Type'} == 's3fs' ) { + $used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) ); - foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) { - $Event->Storage( $this ); // Prevent further db hit - $used += $Event->DiskSpace(); - } - } else { - $path = $this->Path(); - $used = disk_total_space( $path ) - disk_free_space( $path );; + foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) { + $Event->Storage( $this ); // Prevent further db hit + $used += $Event->DiskSpace(); } - } # end if + } else { + $path = $this->Path(); + $used = disk_total_space( $path ) - disk_free_space( $path );; + } $this->{'DiskSpace'} = $used; } From 4fbdacef05ea37b444f5082c18aafec898e98e24 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 17:03:36 -0500 Subject: [PATCH 22/27] fix event counts --- web/skins/classic/views/console.php | 45 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index d1403cb54..584fe6c62 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -22,14 +22,15 @@ if ( $running == null ) $running = daemonCheck(); $eventCounts = array( -'Total'=> array( + 'Total'=> array( 'title' => translate('Events'), 'filter' => array( 'Query' => array( 'terms' => array() ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), 'Hour'=>array( 'title' => translate('Hour'), @@ -40,7 +41,8 @@ $eventCounts = array( ) ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), 'Day'=>array( 'title' => translate('Day'), @@ -51,7 +53,8 @@ $eventCounts = array( ) ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), 'Week'=>array( 'title' => translate('Week'), @@ -62,7 +65,8 @@ $eventCounts = array( ) ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), 'Month'=>array( 'title' => translate('Month'), @@ -73,7 +77,8 @@ $eventCounts = array( ) ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), 'Archived'=>array( 'title' => translate('Archived'), @@ -84,7 +89,8 @@ $eventCounts = array( ) ) ), - 'total' => 0, + 'totalevents' => 0, + 'totaldiskspace' => 0, ), ); @@ -121,7 +127,8 @@ for ( $i = 0; $i < count($displayMonitors); $i++ ) { parseFilter( $filter ); #$counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) AS EventCount$j, SUM(if(1".$filter['sql'].",DiskSpace,NULL)) As DiskSpace$j"; $monitor['eventCounts'][$j]['filter'] = $filter; - $eventCounts[$j]['total'] = $monitor[$j.'Events']; + $eventCounts[$j]['totalevents'] += $monitor[$j.'Events']; + $eventCounts[$j]['totaldiskspace'] += $monitor[$j.'EventDiskSpace']; } unset($monitor); } // end foreach display monitor @@ -161,12 +168,11 @@ xhtmlHeaders( __FILE__, translate('Console') ); - - - - - - +'. $j .''; + } +?> disabled="disabled"/> @@ -237,7 +243,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { ' . human_filesize($monitor[$i.'EventDiskSpace']), canView( 'Events' ) ) ?> @@ -271,10 +277,13 @@ foreach ( array('Total','Hour','Day','Week','Month') as $i ) { - + +'.human_filesize($eventCounts[$i]['totaldiskspace']), canView( 'Events' ) ) ?> + From 39e490e5e59721c5681b924aac278253e6985c47 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 17:32:41 -0500 Subject: [PATCH 23/27] fix monitor dropdown --- web/skins/classic/views/_monitor_filters.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index b81634fd4..40eeaf6d5 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -87,6 +87,7 @@ $groupSql = Group::get_group_sql( $group_id ); $displayMonitors = array(); $monitors_dropdown = array(''=>'All'); + # Check to see if the selected monitor_id is in the results. if ( $monitor_id ) { $found_selected_monitor = false; @@ -94,7 +95,6 @@ $groupSql = Group::get_group_sql( $group_id ); if ( !visibleMonitor( $monitors[$i]['Id'] ) ) { continue; } - $monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name']; if ( $monitors[$i]['Id'] == $monitor_id ) { $found_selected_monitor = true; } @@ -106,8 +106,10 @@ $groupSql = Group::get_group_sql( $group_id ); for ( $i = 0; $i < count($monitors); $i++ ) { if ( !visibleMonitor( $monitors[$i]['Id'] ) ) { + Warning("Monitor " . $monitors[$i]['Id'] . ' is not visible' ); continue; } + $monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name']; if ( $monitor_id and ( $monitors[$i]['Id'] != $monitor_id ) ) { continue; From 428d9238748f4714183f13c3cfd9686b3fa8cd0f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 17:39:49 -0500 Subject: [PATCH 24/27] make StatusFIlter do something --- web/skins/classic/views/_monitor_filters.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index 40eeaf6d5..89ff4e3eb 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -114,6 +114,11 @@ $groupSql = Group::get_group_sql( $group_id ); if ( $monitor_id and ( $monitors[$i]['Id'] != $monitor_id ) ) { continue; } + if ( isset($_SESSION['StatusFilter']) ) { + if ( $monitors[$i]['Status'] != $_SESSION['StatusFilter'] ) { + continue; + } + } $displayMonitors[] = $monitors[$i]; } echo htmlSelect( 'MonitorId', $monitors_dropdown, $monitor_id, array('onchange'=>'changeFilter(this);') ); From fc27674d765dd9974515cfd31afa31d5d17ffc97 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 17:50:57 -0500 Subject: [PATCH 25/27] can't do init in the if statement --- src/zm_ffmpeg.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index ce0cd0eff..1d7e25ec3 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -116,7 +116,8 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, flags &= ~(AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); while (*str) { - if ((int ret = parse_key_value_pair(pm, &str, key_val_sep, pairs_sep, flags)) < 0) + int ret; + if ( (ret = parse_key_value_pair(pm, &str, key_val_sep, pairs_sep, flags)) < 0) return ret; if (*str) From 7c491bf62e47741bea5453ea720b657f9129f700 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Nov 2017 18:06:12 -0500 Subject: [PATCH 26/27] make compile on trusty --- src/zm_videostore.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index e6c4769b1..12d8aecf6 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -226,7 +226,11 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, Debug(3, "Got AAC"); audio_out_stream = +#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avformat_new_stream(oc, (const AVCodec *)(audio_in_ctx->codec)); +#else + avformat_new_stream(oc, audio_in_ctx->codec); +#endif if (!audio_out_stream) { Error("Unable to create audio out stream\n"); audio_out_stream = NULL; From 03c9f88d55f0161cc51bcac4b7ce544cbdf0fb82 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 27 Nov 2017 08:24:14 -0500 Subject: [PATCH 27/27] fix build on trusty --- src/zm_videostore.cpp | 5 +- web/api/app/Console/cake.bat | 62 +++++++++---------- .../Console/Templates/skel/Console/cake.bat | 60 +++++++++--------- web/api/lib/Cake/Console/cake.bat | 56 ++++++++--------- 4 files changed, 92 insertions(+), 91 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 12d8aecf6..5285a0526 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -125,7 +125,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, #else video_out_stream = - avformat_new_stream(oc,(const AVCodec *)(video_in_ctx->codec)); + avformat_new_stream(oc,(AVCodec *)(video_in_ctx->codec)); + //avformat_new_stream(oc,(const AVCodec *)(video_in_ctx->codec)); if (!video_out_stream) { Fatal("Unable to create video out stream\n"); } else { @@ -229,7 +230,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avformat_new_stream(oc, (const AVCodec *)(audio_in_ctx->codec)); #else - avformat_new_stream(oc, audio_in_ctx->codec); + avformat_new_stream(oc, (AVCodec *)audio_in_ctx->codec); #endif if (!audio_out_stream) { Error("Unable to create audio out stream\n"); diff --git a/web/api/app/Console/cake.bat b/web/api/app/Console/cake.bat index 919ecac49..c33bf22f8 100644 --- a/web/api/app/Console/cake.bat +++ b/web/api/app/Console/cake.bat @@ -1,31 +1,31 @@ -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Bake is a shell script for running CakePHP bake script -:: -:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) -:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: -:: Licensed under The MIT License -:: Redistributions of files must retain the above copyright notice. -:: -:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: @link http://cakephp.org CakePHP(tm) Project -:: @package app.Console -:: @since CakePHP(tm) v 2.0 -:: @license http://www.opensource.org/licenses/mit-license.php MIT License -:: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:: In order for this script to work as intended, the cake\console\ folder must be in your PATH - -@echo. -@echo off - -SET app=%0 -SET lib=%~dp0 - -php -q "%lib%cake.php" -working "%CD% " %* - -echo. - -exit /B %ERRORLEVEL% +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Bake is a shell script for running CakePHP bake script +:: +:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) +:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: +:: Licensed under The MIT License +:: Redistributions of files must retain the above copyright notice. +:: +:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: @link http://cakephp.org CakePHP(tm) Project +:: @package app.Console +:: @since CakePHP(tm) v 2.0 +:: @license http://www.opensource.org/licenses/mit-license.php MIT License +:: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: In order for this script to work as intended, the cake\console\ folder must be in your PATH + +@echo. +@echo off + +SET app=%0 +SET lib=%~dp0 + +php -q "%lib%cake.php" -working "%CD% " %* + +echo. + +exit /B %ERRORLEVEL% diff --git a/web/api/lib/Cake/Console/Templates/skel/Console/cake.bat b/web/api/lib/Cake/Console/Templates/skel/Console/cake.bat index 0aa43c024..e37d4a524 100644 --- a/web/api/lib/Cake/Console/Templates/skel/Console/cake.bat +++ b/web/api/lib/Cake/Console/Templates/skel/Console/cake.bat @@ -1,30 +1,30 @@ -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Bake is a shell script for running CakePHP bake script -:: -:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) -:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: -:: Licensed under The MIT License -:: Redistributions of files must retain the above copyright notice. -:: -:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: @link http://cakephp.org CakePHP(tm) Project -:: @package app.Console -:: @since CakePHP(tm) v 2.0 -:: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:: In order for this script to work as intended, the cake\console\ folder must be in your PATH - -@echo. -@echo off - -SET app=%0 -SET lib=%~dp0 - -php -q "%lib%cake.php" -working "%CD% " %* - -echo. - -exit /B %ERRORLEVEL% +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Bake is a shell script for running CakePHP bake script +:: +:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) +:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: +:: Licensed under The MIT License +:: Redistributions of files must retain the above copyright notice. +:: +:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: @link http://cakephp.org CakePHP(tm) Project +:: @package app.Console +:: @since CakePHP(tm) v 2.0 +:: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: In order for this script to work as intended, the cake\console\ folder must be in your PATH + +@echo. +@echo off + +SET app=%0 +SET lib=%~dp0 + +php -q "%lib%cake.php" -working "%CD% " %* + +echo. + +exit /B %ERRORLEVEL% diff --git a/web/api/lib/Cake/Console/cake.bat b/web/api/lib/Cake/Console/cake.bat index 905cc39fb..34429cb24 100644 --- a/web/api/lib/Cake/Console/cake.bat +++ b/web/api/lib/Cake/Console/cake.bat @@ -1,28 +1,28 @@ -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Bake is a shell script for running CakePHP bake script -:: -:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) -:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: -:: Licensed under The MIT License -:: Redistributions of files must retain the above copyright notice. -:: -:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) -:: @link http://cakephp.org CakePHP(tm) Project -:: @package Cake.Console -:: @since CakePHP(tm) v 1.2.0.5012 -:: @license http://www.opensource.org/licenses/mit-license.php MIT License -:: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -@echo off - -SET app=%0 -SET lib=%~dp0 - -php -q "%lib%cake.php" -working "%CD% " %* - -echo. - -exit /B %ERRORLEVEL% +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Bake is a shell script for running CakePHP bake script +:: +:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) +:: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: +:: Licensed under The MIT License +:: Redistributions of files must retain the above copyright notice. +:: +:: @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) +:: @link http://cakephp.org CakePHP(tm) Project +:: @package Cake.Console +:: @since CakePHP(tm) v 1.2.0.5012 +:: @license http://www.opensource.org/licenses/mit-license.php MIT License +:: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +@echo off + +SET app=%0 +SET lib=%~dp0 + +php -q "%lib%cake.php" -working "%CD% " %* + +echo. + +exit /B %ERRORLEVEL%