From b12d72c68f2d580f014a764de8655f799f1a5957 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 9 Jul 2015 11:44:27 -0400 Subject: [PATCH 001/178] fix monitor popup size --- web/skins/classic/js/flat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/js/flat.js b/web/skins/classic/js/flat.js index 4e43ce170..7a6947d60 100644 --- a/web/skins/classic/js/flat.js +++ b/web/skins/classic/js/flat.js @@ -48,7 +48,7 @@ var popupSizes = { 'log': { 'width': 1080, 'height': 720 }, 'login': { 'width': 720, 'height': 480 }, 'logout': { 'width': 260, 'height': 100 }, - 'monitor': { 'width': 450, 'height': 440 }, + 'monitor': { 'width': 550, 'height': 630 }, 'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorselect':{ 'width': 160, 'height': 200 }, From 69e1fd8b182f0ffc1b3af8d049ac50738b216758 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 9 Jul 2015 11:45:19 -0400 Subject: [PATCH 002/178] add code to convert the human readable config entry ZM_SERVER_NAME into ZM_SERVER_ID --- web/includes/config.php.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index fbcb0e7b3..7fdba34a7 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -166,4 +166,15 @@ function loadConfig( $defineConsts=true ) //print_r( $configCats ); } +// For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID +if ( ! defined(ZM_SERVER_ID) and defined(ZM_SERVER) ) { + $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME)); + if ( ! $server_id ) { + Error("ZM_SERVER_NAME set in config, but not found in Servers table."); + } else { + define( ZM_SERVER_ID, $server_id ); + } +} + + ?> From 7fa2d51277d5ff7582161e9cf3f7b5ff5a951575 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 09:42:29 -0400 Subject: [PATCH 003/178] snapshot releases --- distros/ubuntu1504/changelog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/distros/ubuntu1504/changelog b/distros/ubuntu1504/changelog index 2dfc8b63c..e53dd0203 100644 --- a/distros/ubuntu1504/changelog +++ b/distros/ubuntu1504/changelog @@ -1,3 +1,21 @@ +zoneminder (1.28.1+1-vivid-SNAPSHOT2015070402) vivid; urgency=medium + + * Correct PRIMARY KEY update code on States table + + -- Isaac Connor Tue, 07 Jul 2015 15:40:21 -0400 + +zoneminder (1.28.1+1-vivid-SNAPSHOT2015070401) vivid; urgency=medium + + * Bump actual version # so that db upgrade scripts run + + -- Isaac Connor Tue, 07 Jul 2015 12:44:55 -0400 + +zoneminder (1.28.1+1-vivid-SNAPSHOT2015070301) vivid; urgency=medium + + * initial merge of api. Various other small fixes/improvements. + + -- Isaac Connor Mon, 06 Jul 2015 15:59:08 -0400 + zoneminder (1.28.1+1-trusty-SNAPSHOT2015030201) trusty; urgency=medium * maybe fix for RTSP Basic Auth From e318c3bf3746e7cca71a8ed8decd6e95cb63864c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 16:12:35 -0400 Subject: [PATCH 004/178] Add ServerId as a filter option --- scripts/zmfilter.pl.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 54f372262..4280f4e48 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -349,6 +349,10 @@ sub getFilters my ( $temp_attr_name ) = $filter_expr->{terms}[$i]->{attr} =~ /^Monitor(.+)$/; $db_filter->{Sql} .= "M.".$temp_attr_name; } + elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) + { + $db_filter->{Sql} .= "M.ServerId"; + } elsif ( $filter_expr->{terms}[$i]->{attr} eq 'DateTime' ) { $db_filter->{Sql} .= "E.StartTime"; @@ -392,6 +396,13 @@ sub getFilters { $value = "'$temp_value'"; } + elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) { + if ( $temp_value eq 'ZM_SERVER_ID' ) { + $value = "'$Config{ZM_SERVER_ID}'"; + } else { + $value = "'$temp_value'"; + } + } elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Name' || $filter_expr->{terms}[$i]->{attr} eq 'Cause' || $filter_expr->{terms}[$i]->{attr} eq 'Notes' From 51af432468c278a667652352a3ad57fa76e08b23 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 16:18:05 -0400 Subject: [PATCH 005/178] Only load monitors for our server if ZM_SERVER_ID is specified --- scripts/zmpkg.pl.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 46ea825c4..c5a1d489d 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -119,10 +119,10 @@ my $retval = 0; if ( $command eq "state" ) { Info( "Updating DB: $state->{Name}\n" ); - my $sql = "select * from Monitors order by Id asc"; + my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=? ORDER BY Id ASC' : 'SELECT * FROM Monitors ORDER BY Id ASC'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute() + 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() ) { @@ -228,10 +228,10 @@ if ( $command =~ /^(?:start|restart)$/ ) zmMemTidy(); runCommand( "zmdc.pl startup" ); - my $sql = "select * from Monitors"; + my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute() + 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() ) { From b8888b9d5536b51e66331ec49c60ce1d6b40ad74 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 16:22:43 -0400 Subject: [PATCH 006/178] Only load triggers for our Server if ZM_SERVER_ID is set --- scripts/zmtrigger.pl.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/zmtrigger.pl.in b/scripts/zmtrigger.pl.in index e43b00bbb..0dc18562d 100644 --- a/scripts/zmtrigger.pl.in +++ b/scripts/zmtrigger.pl.in @@ -358,11 +358,12 @@ sub loadMonitors my %new_monitors = (); my $sql = "SELECT * FROM Monitors - WHERE find_in_set( Function, 'Modect,Mocord,Nodect' )" + WHERE find_in_set( Function, 'Modect,Mocord,Nodect' )". + ( $Config{ZM_SERVER_ID} ? 'AND ServerId=?' : '' ) ; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute() + 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() ) { From ca9a391d6216cc17b48298af7d1d78b661357a11 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 16:24:01 -0400 Subject: [PATCH 007/178] Only load the monitors for our server --- scripts/zmwatch.pl.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 01d15e815..3e97733a1 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -74,14 +74,14 @@ sleep( START_DELAY ); my $dbh = zmDbConnect(); -my $sql = "select * from Monitors"; +my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); while( 1 ) { my $now = time(); - my $res = $sth->execute() + 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() ) { From 34813685742ed08aa918ac1f42363ba0985d470e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Jul 2015 16:44:16 -0400 Subject: [PATCH 008/178] given SERVER_NAME populate SERVER_ID and vice versa --- src/zm_config.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/zm_config.cpp b/src/zm_config.cpp index a25f7a39a..27a8365e4 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -91,17 +91,82 @@ void zmLoadConfig() staticConfig.DB_PASS = std::string(val_ptr); else if ( strcasecmp( name_ptr, "ZM_PATH_WEB" ) == 0 ) staticConfig.PATH_WEB = std::string(val_ptr); + else if ( strcasecmp( name_ptr, "ZM_SERVER_HOST" ) == 0 ) + staticConfig.SERVER_NAME = std::string(val_ptr); + else if ( strcasecmp( name_ptr, "ZM_SERVER_NAME" ) == 0 ) + staticConfig.SERVER_NAME = std::string(val_ptr); + else if ( strcasecmp( name_ptr, "ZM_SERVER_ID" ) == 0 ) + staticConfig.SERVER_ID = atoi(val_ptr); else { // We ignore this now as there may be more parameters than the // c/c++ binaries are bothered about // Warning( "Invalid parameter '%s' in %s", name_ptr, ZM_CONFIG ); } - } - fclose( cfg); + } // end foreach line of the config + fclose( cfg ); zmDbConnect(); config.Load(); config.Assign(); + + // Populate the server config entries + if ( ! staticConfig.SERVER_ID ) { + if ( staticConfig.SERVER_NAME && ! staticConfig.SERVER_NAME.empty() ) { + + std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME ); + if ( mysql_query( &dbconn, sql.c_str() ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + } + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + } + int n_rows = mysql_num_rows( result ); + if ( n_rows != 1 ) + { + Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + } + + if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) ) + { + staticConfig.SERVER_ID = atoi(dbrow[0]); + } + mysql_free_result( result ); + + } // end if has SERVER_NAME + } else if ( ! staticConfig.SERVER_NAME ) { + std::string sql = stringtf("SELECT Name FROM Servers WHERE Id='%d'", staticConfig.SERVER_ID ); + if ( mysql_query( &dbconn, sql.c_str() ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); + } + int n_rows = mysql_num_rows( result ); + if ( n_rows != 1 ) + { + Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows ); + Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); + } + + if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) ) + { + staticConfig.SERVER_NAME = std::string(dbrow[0]); + } + mysql_free_result( result ); + + } } StaticConfig staticConfig; From 50b333fb28321fca9e2cba017294f5380622b25c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Jul 2015 10:04:56 -0400 Subject: [PATCH 009/178] Add SERVER_NAME and SERVER_ID loading to config --- src/zm_config.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/zm_config.cpp b/src/zm_config.cpp index 27a8365e4..f8ae0c271 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -25,6 +25,8 @@ #include #include +#include "zm_utils.h" + void zmLoadConfig() { FILE *cfg; @@ -111,25 +113,25 @@ void zmLoadConfig() // Populate the server config entries if ( ! staticConfig.SERVER_ID ) { - if ( staticConfig.SERVER_NAME && ! staticConfig.SERVER_NAME.empty() ) { + if ( ! staticConfig.SERVER_NAME.empty() ) { - std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME ); + std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() ); if ( mysql_query( &dbconn, sql.c_str() ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); } MYSQL_RES *result = mysql_store_result( &dbconn ); if ( !result ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); } int n_rows = mysql_num_rows( result ); if ( n_rows != 1 ) { Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME ); + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); } if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) ) @@ -139,7 +141,7 @@ void zmLoadConfig() mysql_free_result( result ); } // end if has SERVER_NAME - } else if ( ! staticConfig.SERVER_NAME ) { + } else if ( staticConfig.SERVER_NAME.empty() ) { std::string sql = stringtf("SELECT Name FROM Servers WHERE Id='%d'", staticConfig.SERVER_ID ); if ( mysql_query( &dbconn, sql.c_str() ) ) { From 4ed248e5a5d00fad62fb43ead3e297a9c0bd165c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Jul 2015 10:05:21 -0400 Subject: [PATCH 010/178] Add SERVER_NAME and SERVER_ID loading to config --- src/zm_config.h.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_config.h.in b/src/zm_config.h.in index 1df1edf16..83aa19210 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -65,6 +65,8 @@ struct StaticConfig std::string DB_USER; std::string DB_PASS; std::string PATH_WEB; + std::string SERVER_NAME; + unsigned int SERVER_ID; }; extern StaticConfig staticConfig; From 60410c98d6c20988a012da7f68995be7889f3b2c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Jul 2015 16:44:09 -0400 Subject: [PATCH 011/178] use new db functions in zm_config.cpp --- src/zm_config.cpp | 25 ++++--------------------- src/zm_db.cpp | 3 ++- src/zm_db.h | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/zm_config.cpp b/src/zm_config.cpp index f8ae0c271..e9c54b943 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -115,30 +115,13 @@ void zmLoadConfig() if ( ! staticConfig.SERVER_ID ) { if ( ! staticConfig.SERVER_NAME.empty() ) { + std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() ); - if ( mysql_query( &dbconn, sql.c_str() ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); - } - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); - } - int n_rows = mysql_num_rows( result ); - if ( n_rows != 1 ) - { - Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows ); - Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); - } - - if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) ) - { + if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) { staticConfig.SERVER_ID = atoi(dbrow[0]); + } else { + Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() ); } - mysql_free_result( result ); } // end if has SERVER_NAME } else if ( staticConfig.SERVER_NAME.empty() ) { diff --git a/src/zm_db.cpp b/src/zm_db.cpp index 0065488f5..a342ca14b 100644 --- a/src/zm_db.cpp +++ b/src/zm_db.cpp @@ -95,7 +95,7 @@ MYSQL_RES * zmDbFetch( const char * query ) { return result; } // end MYSQL_RES * zmDbFetch( const char * query ); -MYSQL_ROW zmDBFetchOne( const char *query ) { +MYSQL_ROW zmDbFetchOne( const char *query ) { MYSQL_RES *result = zmDbFetch( query ); int n_rows = mysql_num_rows( result ); if ( n_rows != 1 ) { @@ -104,6 +104,7 @@ MYSQL_ROW zmDBFetchOne( const char *query ) { } MYSQL_ROW dbrow = mysql_fetch_row( result ); + mysql_free_result( result ); if ( ! dbrow ) { Error("Error getting row from query %s. Error is %s", query, mysql_error( &dbconn ) ); return NULL; diff --git a/src/zm_db.h b/src/zm_db.h index de1a81340..6ec1b5e4e 100644 --- a/src/zm_db.h +++ b/src/zm_db.h @@ -33,7 +33,7 @@ void zmDbConnect(); void zmDbClose(); MYSQL_RES * zmDbFetch( const char *query ); -MYSQL_ROW zmDBFetchOne( const char *query ); +MYSQL_ROW zmDbFetchOne( const char *query ); #ifdef __cplusplus } /* extern "C" */ From 633a6e2df9fbdfee6768c53784df441b7191a080 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Jul 2015 16:53:30 -0400 Subject: [PATCH 012/178] use zmDbFetchOne more --- src/zm_config.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/zm_config.cpp b/src/zm_config.cpp index e9c54b943..5521b5a14 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -115,7 +115,6 @@ void zmLoadConfig() if ( ! staticConfig.SERVER_ID ) { if ( ! staticConfig.SERVER_NAME.empty() ) { - std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() ); if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) { staticConfig.SERVER_ID = atoi(dbrow[0]); @@ -126,30 +125,12 @@ void zmLoadConfig() } // end if has SERVER_NAME } else if ( staticConfig.SERVER_NAME.empty() ) { std::string sql = stringtf("SELECT Name FROM Servers WHERE Id='%d'", staticConfig.SERVER_ID ); - if ( mysql_query( &dbconn, sql.c_str() ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); - } - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); - } - int n_rows = mysql_num_rows( result ); - if ( n_rows != 1 ) - { - Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows ); - Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); - } - - if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) ) - { + if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) { staticConfig.SERVER_NAME = std::string(dbrow[0]); + } else { + Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); } - mysql_free_result( result ); } } From 441a82e611e73c4e5da899093a0fee1e85772550 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 17 Jul 2015 10:12:44 -0400 Subject: [PATCH 013/178] fixup loading SERVER_ID from SERVER_NAME --- web/includes/config.php.in | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index 7fdba34a7..efe9d2bce 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -167,13 +167,22 @@ function loadConfig( $defineConsts=true ) } // For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID -if ( ! defined(ZM_SERVER_ID) and defined(ZM_SERVER) ) { - $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME)); - if ( ! $server_id ) { - Error("ZM_SERVER_NAME set in config, but not found in Servers table."); - } else { - define( ZM_SERVER_ID, $server_id ); - } +if ( ! defined('ZM_SERVER_ID') ) { + if ( defined('ZM_SERVER_NAME') ) { + $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME)); + if ( ! $server_id ) { + Error("ZM_SERVER_NAME set in config, but not found in Servers table."); + } else { + define( 'ZM_SERVER_ID', $server_id ); + } + } else if ( defined('ZM_SERVER_HOST') ) { + $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST)); + if ( ! $server_id ) { + Error("ZM_SERVER_HOST set in config, but not found in Servers table."); + } else { + define( 'ZM_SERVER_ID', $server_id ); + } + } } From dfd3d2c4cde6a2867b4b53983811d9d7d5d424ba Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 20 Jul 2015 16:28:21 -0400 Subject: [PATCH 014/178] use std::string to build sql for loading monitors. ALso use new ZmDbFetch functions --- src/zm_monitor.cpp | 660 ++++++++++++++++++++++----------------------- src/zm_monitor.h | 5 +- 2 files changed, 321 insertions(+), 344 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 906ca68f6..e233b0790 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -263,6 +263,7 @@ bool Monitor::MonitorLink::hasAlarmed() Monitor::Monitor( int p_id, const char *p_name, + const unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, @@ -292,6 +293,7 @@ Monitor::Monitor( int p_n_zones, Zone *p_zones[] ) : id( p_id ), + server_id( p_server_id ), function( (Function)p_function ), enabled( p_enabled ), width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), @@ -1860,25 +1862,22 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) #if ZM_HAS_V4L int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose ) { - static char sql[ZM_SQL_MED_BUFSIZ]; - if ( !device[0] ) - { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) ); - } - else - { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device ); - } - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local'"; +; + if ( device[0] ) { + sql += " AND Device='"; + sql += device; + sql += "'"; + } + if ( staticConfig.SERVER_ID ) { + sql += " AND ServerId='"; + sql += staticConfig.SERVER_ID; + sql += "'"; + } - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + MYSQL_RES *result = zmDbFetch( sql.c_str() ); + if ( !result ) { + Error( "Can't load local monitors: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } int n_monitors = mysql_num_rows( result ); @@ -1891,6 +1890,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -1988,6 +1988,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); monitors[i] = new Monitor( id, name, + server_id, function, enabled, linked_monitors, @@ -2036,24 +2037,19 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose ) { - static char sql[ZM_SQL_MED_BUFSIZ]; - if ( !protocol ) - { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) ); - } - else - { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); - } - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'"; + if ( staticConfig.SERVER_ID ) { + sql += " AND ServerId='"; + sql += staticConfig.SERVER_ID; + sql += "'"; } - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { + if ( protocol ) { + sql += stringtf(" AND Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); + } + + MYSQL_RES *result = zmDbFetch( sql.c_str() ); + if ( !result ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } @@ -2067,6 +2063,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int id = atoi(dbrow[col]); col++; std::string name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2161,6 +2158,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c monitors[i] = new Monitor( id, name.c_str(), + server_id, function, enabled, linked_monitors, @@ -2209,22 +2207,18 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose ) { - static char sql[ZM_SQL_MED_BUFSIZ]; - if ( !file[0] ) - { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) ); + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'"; + if ( file[0] ) { + sql += " AND Path='"; + sql += file; + sql += "'"; } - else - { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file ); + if ( staticConfig.SERVER_ID ) { + sql += " AND ServerId='"; + sql += staticConfig.SERVER_ID; + sql += "'"; } - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); + MYSQL_RES *result = zmDbFetch( sql.c_str() ); if ( !result ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); @@ -2240,6 +2234,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2298,6 +2293,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu monitors[i] = new Monitor( id, name, + server_id, function, enabled, linked_monitors, @@ -2346,27 +2342,23 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu #if HAVE_LIBAVFORMAT int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose ) { - static char sql[ZM_SQL_MED_BUFSIZ]; - if ( !file[0] ) - { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) ); + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'"; + if ( file[0] ) { + sql += " AND Path = '"; + sql += file; + sql += "'"; } - else - { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file ); + if ( staticConfig.SERVER_ID ) { + sql += " AND ServerId='"; + sql += staticConfig.SERVER_ID; + sql += "'"; } - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); + MYSQL_RES *result = zmDbFetch( sql.c_str() ); + if ( ! result ) { + Error( "Cannot load FfmpegMonitors" ); exit( mysql_errno( &dbconn ) ); } - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } int n_monitors = mysql_num_rows( result ); Debug( 1, "Got %d monitors", n_monitors ); delete[] monitors; @@ -2377,6 +2369,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2439,6 +2432,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose monitors[i] = new Monitor( id, name, + server_id, function, enabled, linked_monitors, @@ -2485,321 +2479,303 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose } #endif // HAVE_LIBAVFORMAT -Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) +Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) { - static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } + std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", p_id ); - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { + MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ); + if ( ! dbrow ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } - int n_monitors = mysql_num_rows( result ); - Debug( 1, "Got %d monitors", n_monitors ); Monitor *monitor = 0; - for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) - { - int col = 0; + unsigned int col = 0; - int id = atoi(dbrow[col]); col++; - std::string name = dbrow[col]; col++; - std::string type = dbrow[col]; col++; - int function = atoi(dbrow[col]); col++; - int enabled = atoi(dbrow[col]); col++; - std::string linked_monitors = dbrow[col]; col++; + unsigned int id = atoi(dbrow[col]); col++; + std::string name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; + std::string type = dbrow[col]; col++; + int function = atoi(dbrow[col]); col++; + int enabled = atoi(dbrow[col]); col++; + std::string linked_monitors = dbrow[col]; col++; - std::string device = dbrow[col]; col++; - int channel = atoi(dbrow[col]); col++; - int format = atoi(dbrow[col]); col++; + std::string device = dbrow[col]; col++; + int channel = atoi(dbrow[col]); col++; + int format = atoi(dbrow[col]); col++; - bool v4l_multi_buffer; - if ( dbrow[col] ) { - if (*dbrow[col] == '0' ) { - v4l_multi_buffer = false; - } else if ( *dbrow[col] == '1' ) { - v4l_multi_buffer = true; - } - } else { - v4l_multi_buffer = config.v4l_multi_buffer; - } - col++; + bool v4l_multi_buffer; + if ( dbrow[col] ) { + if (*dbrow[col] == '0' ) { + v4l_multi_buffer = false; + } else if ( *dbrow[col] == '1' ) { + v4l_multi_buffer = true; + } + } else { + v4l_multi_buffer = config.v4l_multi_buffer; + } + col++; - int v4l_captures_per_frame = 0; - if ( dbrow[col] ) { - v4l_captures_per_frame = atoi(dbrow[col]); - } else { - v4l_captures_per_frame = config.captures_per_frame; - } + int v4l_captures_per_frame = 0; + if ( dbrow[col] ) { + v4l_captures_per_frame = atoi(dbrow[col]); + } else { + v4l_captures_per_frame = config.captures_per_frame; + } Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); - col++; + col++; - std::string protocol = dbrow[col]; col++; - std::string method = dbrow[col]; col++; - std::string host = dbrow[col]; col++; - std::string port = dbrow[col]; col++; - std::string path = dbrow[col]; col++; - std::string options = dbrow[col]; col++; - std::string user = dbrow[col]; col++; - std::string pass = dbrow[col]; col++; + std::string protocol = dbrow[col]; col++; + std::string method = dbrow[col]; col++; + std::string host = dbrow[col]; col++; + std::string port = dbrow[col]; col++; + std::string path = dbrow[col]; col++; + std::string options = dbrow[col]; col++; + std::string user = dbrow[col]; col++; + std::string pass = dbrow[col]; col++; - int width = atoi(dbrow[col]); col++; - int height = atoi(dbrow[col]); col++; - int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; - Orientation orientation = (Orientation)atoi(dbrow[col]); col++; - unsigned int deinterlacing = atoi(dbrow[col]); col++; - int brightness = atoi(dbrow[col]); col++; - int contrast = atoi(dbrow[col]); col++; - int hue = atoi(dbrow[col]); col++; - int colour = atoi(dbrow[col]); col++; + int width = atoi(dbrow[col]); col++; + int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; + int palette = atoi(dbrow[col]); col++; + Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; + int brightness = atoi(dbrow[col]); col++; + int contrast = atoi(dbrow[col]); col++; + int hue = atoi(dbrow[col]); col++; + int colour = atoi(dbrow[col]); col++; - std::string event_prefix = dbrow[col]; col++; - std::string label_format = dbrow[col]; col++; + std::string event_prefix = dbrow[col]; col++; + std::string label_format = dbrow[col]; col++; - int label_x = atoi(dbrow[col]); col++; - int label_y = atoi(dbrow[col]); col++; + int label_x = atoi(dbrow[col]); col++; + int label_y = atoi(dbrow[col]); col++; - int image_buffer_count = atoi(dbrow[col]); col++; - int warmup_count = atoi(dbrow[col]); col++; - int pre_event_count = atoi(dbrow[col]); col++; - int post_event_count = atoi(dbrow[col]); col++; - int stream_replay_buffer = atoi(dbrow[col]); col++; - int alarm_frame_count = atoi(dbrow[col]); col++; - int section_length = atoi(dbrow[col]); col++; - int frame_skip = atoi(dbrow[col]); col++; - int motion_frame_skip = atoi(dbrow[col]); col++; - int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int fps_report_interval = atoi(dbrow[col]); col++; - int ref_blend_perc = atoi(dbrow[col]); col++; - int alarm_ref_blend_perc = atoi(dbrow[col]); col++; - int track_motion = atoi(dbrow[col]); col++; + int image_buffer_count = atoi(dbrow[col]); col++; + int warmup_count = atoi(dbrow[col]); col++; + int pre_event_count = atoi(dbrow[col]); col++; + int post_event_count = atoi(dbrow[col]); col++; + int stream_replay_buffer = atoi(dbrow[col]); col++; + int alarm_frame_count = atoi(dbrow[col]); col++; + int section_length = atoi(dbrow[col]); col++; + int frame_skip = atoi(dbrow[col]); col++; + int motion_frame_skip = atoi(dbrow[col]); col++; + int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; + int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; + int fps_report_interval = atoi(dbrow[col]); col++; + int ref_blend_perc = atoi(dbrow[col]); col++; + int alarm_ref_blend_perc = atoi(dbrow[col]); col++; + int track_motion = atoi(dbrow[col]); col++; - int signal_check_colour; - if ( dbrow[col][0] == '#' ) - signal_check_colour = strtol(dbrow[col]+1,0,16); - else - signal_check_colour = strtol(dbrow[col],0,16); + int signal_check_colour; + if ( dbrow[col][0] == '#' ) + signal_check_colour = strtol(dbrow[col]+1,0,16); + else + signal_check_colour = strtol(dbrow[col],0,16); - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); + int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); + int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - int extras = (deinterlacing>>24)&0xff; + int extras = (deinterlacing>>24)&0xff; - Camera *camera = 0; - if ( type == "Local" ) - { + Camera *camera = 0; + if ( type == "Local" ) + { #if ZM_HAS_V4L - camera = new LocalCamera( - id, - device.c_str(), - channel, - format, - v4l_multi_buffer, - v4l_captures_per_frame, - method, - cam_width, - cam_height, - colours, - palette, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE, - extras - ); + camera = new LocalCamera( + id, + device.c_str(), + channel, + format, + v4l_multi_buffer, + v4l_captures_per_frame, + method, + cam_width, + cam_height, + colours, + palette, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE, + extras + ); #else // ZM_HAS_V4L - Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); + Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); #endif // ZM_HAS_V4L - } - else if ( type == "Remote" ) - { - if ( protocol == "http" ) - { - camera = new RemoteCameraHttp( - id, - method.c_str(), - host.c_str(), - port.c_str(), - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); - } - else if ( protocol == "rtsp" ) - { + } + else if ( type == "Remote" ) + { + if ( protocol == "http" ) + { + camera = new RemoteCameraHttp( + id, + method.c_str(), + host.c_str(), + port.c_str(), + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); + } + else if ( protocol == "rtsp" ) + { #if HAVE_LIBAVFORMAT - camera = new RemoteCameraRtsp( - id, - method.c_str(), - host.c_str(), - port.c_str(), - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new RemoteCameraRtsp( + id, + method.c_str(), + host.c_str(), + port.c_str(), + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBAVFORMAT - Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); + Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); #endif // HAVE_LIBAVFORMAT - } - else - { - Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); - } - } - else if ( type == "File" ) - { - camera = new FileCamera( - id, - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); - } - else if ( type == "Ffmpeg" ) - { + } + else + { + Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); + } + } + else if ( type == "File" ) + { + camera = new FileCamera( + id, + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); + } + else if ( type == "Ffmpeg" ) + { #if HAVE_LIBAVFORMAT - camera = new FfmpegCamera( - id, - path.c_str(), - method, - options, - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new FfmpegCamera( + id, + path.c_str(), + method, + options, + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBAVFORMAT - Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id ); + Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id ); #endif // HAVE_LIBAVFORMAT - } - else if (type == "Libvlc") - { + } + else if (type == "Libvlc") + { #if HAVE_LIBVLC - camera = new LibvlcCamera( - id, - path.c_str(), - method, - options, - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new LibvlcCamera( + id, + path.c_str(), + method, + options, + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBVLC - Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id ); + Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id ); #endif // HAVE_LIBVLC - } - else if ( type == "cURL" ) - { + } + else if ( type == "cURL" ) + { #if HAVE_LIBCURL - camera = new cURLCamera( - id, - path.c_str(), - user.c_str(), - pass.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new cURLCamera( + id, + path.c_str(), + user.c_str(), + pass.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBCURL - Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id ); + Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id ); #endif // HAVE_LIBCURL - } - else - { - Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id ); - } - monitor = new Monitor( - id, - name.c_str(), - function, - enabled, - linked_monitors.c_str(), - camera, - orientation, - deinterlacing, - event_prefix.c_str(), - label_format.c_str(), - Coord( label_x, label_y ), - image_buffer_count, - warmup_count, - pre_event_count, - post_event_count, - stream_replay_buffer, - alarm_frame_count, - section_length, - frame_skip, - motion_frame_skip, - capture_delay, - alarm_capture_delay, - fps_report_interval, - ref_blend_perc, - alarm_ref_blend_perc, - track_motion, - signal_check_colour, - purpose, - 0, - 0 + } + else + { + Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id ); + } + monitor = new Monitor( + id, + name.c_str(), + server_id, + function, + enabled, + linked_monitors.c_str(), + camera, + orientation, + deinterlacing, + event_prefix.c_str(), + label_format.c_str(), + Coord( label_x, label_y ), + image_buffer_count, + warmup_count, + pre_event_count, + post_event_count, + stream_replay_buffer, + alarm_frame_count, + section_length, + frame_skip, + motion_frame_skip, + capture_delay, + alarm_capture_delay, + fps_report_interval, + ref_blend_perc, + alarm_ref_blend_perc, + track_motion, + signal_check_colour, + purpose, + 0, + 0 - ); - - int n_zones = 0; - if ( load_zones ) - { - Zone **zones = 0; - n_zones = Zone::Load( monitor, zones ); - monitor->AddZones( n_zones, zones ); - } - Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); - } - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - // Yadda yadda - mysql_free_result( result ); + ); + int n_zones = 0; + if ( load_zones ) + { + Zone **zones = 0; + n_zones = Zone::Load( monitor, zones ); + monitor->AddZones( n_zones, zones ); + } + Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); return( monitor ); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index b8326a1c4..8cf5ece36 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -211,6 +211,7 @@ protected: // These are read from the DB and thereafter remain unchanged unsigned int id; char name[64]; + unsigned int server_id; Function function; // What the monitor is doing bool enabled; // Whether the monitor is enabled or asleep unsigned int width; // Normally the same as the camera, but not if partly rotated @@ -298,7 +299,7 @@ protected: public: // OurCheckAlarms seems to be unused. Check it on zm_monitor.cpp for more info. //bool OurCheckAlarms( Zone *zone, const Image *pImage ); - Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); + Monitor( int p_id, const char *p_name, unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); ~Monitor(); void AddZones( int p_n_zones, Zone *p_zones[] ); @@ -413,7 +414,7 @@ public: #if HAVE_LIBAVFORMAT static int LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose ); #endif // HAVE_LIBAVFORMAT - static Monitor *Load( int id, bool load_zones, Purpose purpose ); + static Monitor *Load( unsigned int id, bool load_zones, Purpose purpose ); //void writeStreamImage( Image *image, struct timeval *timestamp, int scale, int mag, int x, int y ); //void StreamImages( int scale=100, int maxfps=10, time_t ttl=0, int msq_id=0 ); //void StreamImagesRaw( int scale=100, int maxfps=10, time_t ttl=0 ); From 9117e2949a6359adc003d99a39ff274321be7ccd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 16 Aug 2015 10:52:47 -0400 Subject: [PATCH 015/178] add server.php. --- web/skins/classic/views/server.php | 99 ++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 web/skins/classic/views/server.php diff --git a/web/skins/classic/views/server.php b/web/skins/classic/views/server.php new file mode 100644 index 000000000..c53bef2bc --- /dev/null +++ b/web/skins/classic/views/server.php @@ -0,0 +1,99 @@ +translate('No'), 1=>translate('Yes') ); +$nv = array( 'None'=>translate('None'), 'View'=>translate('View') ); +$nve = array( 'None'=>translate('None'), 'View'=>translate('View'), 'Edit'=>translate('Edit') ); + +$sql = "select Id,Name from Monitors order by Sequence asc"; +$monitors = array(); +foreach( dbFetchAll( $sql ) as $monitor ) +{ + $monitors[] = $monitor; +} + +$focusWindow = true; + +xhtmlHeaders(__FILE__, translate('Server')." - ".$newServer['Name'] ); +?> + +
+ +
+
+ + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+
+
+ + From b3240bbc8f2c411ef5c501774c3ca30a677f88e9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 16 Aug 2015 12:21:52 -0400 Subject: [PATCH 016/178] set name=action on submit tag, and remove stuff that we don't want right now --- web/skins/classic/views/server.php | 36 ++---------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/web/skins/classic/views/server.php b/web/skins/classic/views/server.php index c53bef2bc..fa57a7e97 100644 --- a/web/skins/classic/views/server.php +++ b/web/skins/classic/views/server.php @@ -34,17 +34,6 @@ if ( $_REQUEST['id'] ) { $newServer['Name'] = translate('NewServer'); } -$yesno = array( 0=>translate('No'), 1=>translate('Yes') ); -$nv = array( 'None'=>translate('None'), 'View'=>translate('View') ); -$nve = array( 'None'=>translate('None'), 'View'=>translate('View'), 'Edit'=>translate('Edit') ); - -$sql = "select Id,Name from Monitors order by Sequence asc"; -$monitors = array(); -foreach( dbFetchAll( $sql ) as $monitor ) -{ - $monitors[] = $monitor; -} - $focusWindow = true; xhtmlHeaders(__FILE__, translate('Server')." - ".$newServer['Name'] ); @@ -59,38 +48,17 @@ xhtmlHeaders(__FILE__, translate('Server')." - ".$newServer['Name'] ); - - - - - -
- -
- + +
From 99d674ef788a4ec32a9f39205563a068b7d604ce Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 16 Aug 2015 12:22:31 -0400 Subject: [PATCH 017/178] remove code that put a * next to the server name. It was copied from the user list and indicated the logged in user. --- web/skins/classic/views/options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 5e335ce43..92d019666 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -225,7 +225,7 @@ elseif ( $tab == "users" ) - + disabled="disabled"/> From 41637278c95abd45175ae2046da95a4964310423 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 19 Aug 2015 16:08:12 -0400 Subject: [PATCH 018/178] merge master --- docs/installationguide/centos.rst | 5 - docs/installationguide/debian.rst | 37 ----- docs/installationguide/fedora.rst | 4 - docs/installationguide/index.rst | 12 -- docs/installationguide/ubuntu.rst | 52 ------- misc/apache.conf.in | 8 +- .../lib/ZoneMinder/ConfigData.pm.in | 2 +- src/zm_monitor.cpp | 145 ++---------------- src/zm_monitor.h | 2 +- web/api/.gitattributes | 33 ---- web/api/.gitignore | 21 --- web/api/app/Config/core.php | 4 +- web/skins/classic/includes/functions.php | 1 - 13 files changed, 20 insertions(+), 306 deletions(-) delete mode 100644 docs/installationguide/centos.rst delete mode 100644 docs/installationguide/debian.rst delete mode 100644 docs/installationguide/fedora.rst delete mode 100644 docs/installationguide/index.rst delete mode 100644 docs/installationguide/ubuntu.rst delete mode 100644 web/api/.gitattributes delete mode 100644 web/api/.gitignore diff --git a/docs/installationguide/centos.rst b/docs/installationguide/centos.rst deleted file mode 100644 index 606aaffd5..000000000 --- a/docs/installationguide/centos.rst +++ /dev/null @@ -1,5 +0,0 @@ -Centos -====== - - - diff --git a/docs/installationguide/debian.rst b/docs/installationguide/debian.rst deleted file mode 100644 index 9294ebeb6..000000000 --- a/docs/installationguide/debian.rst +++ /dev/null @@ -1,37 +0,0 @@ -Debian -====== - -A fresh build based on master branch running Debian 7 (wheezy)\: -:: - - root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; - - root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; - root@host:~# cd zoneminder; - root@host:~# ln -s distros/debian; - root@host:~# dpkg-checkbuilddeps; - root@host:~# dpkg-buildpackage; - -One level above you'll now find a deb package matching the architecture of the build host: -:: - - root@host:~# ls -1 ~/zoneminder*; - /root/zoneminder_1.26.4-1_amd64.changes - /root/zoneminder_1.26.4-1_amd64.deb - /root/zoneminder_1.26.4-1.dsc - /root/zoneminder_1.26.4-1.tar.gz - -The dpkg command itself does not resolve dependencies. That's what high-level interfaces like aptitude and apt-get are normally for. Unfortunately, unlike RPM, there's no easy way to install a separate deb package not contained with any repository. - -To overcome this "limitation" we'll use dpkg only to install the zoneminder package and apt-get to fetch all needed dependencies afterwards. Running dpkg-reconfigure in the end will ensure that the setup scripts e.g. for database provisioning were executed. -:: - - root@host:~# dpkg -i /root/zoneminder_1.26.4-1_amd64.deb; apt-get install -f; - root@host:~# dpkg-reconfigure zoneminder; - -Alternatively you may also use gdebi to automatically resolve dependencies during installation: -:: - - root@host:~# aptitude install -y gdebi; - root@host:~# gdebi /root/zoneminder_1.26.4-1_amd64.deb; - diff --git a/docs/installationguide/fedora.rst b/docs/installationguide/fedora.rst deleted file mode 100644 index 09ffe4297..000000000 --- a/docs/installationguide/fedora.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fedora -====== - - diff --git a/docs/installationguide/index.rst b/docs/installationguide/index.rst deleted file mode 100644 index 58a8f4b21..000000000 --- a/docs/installationguide/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -Installation Guide -====================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - ubuntu - debian - fedora - centos diff --git a/docs/installationguide/ubuntu.rst b/docs/installationguide/ubuntu.rst deleted file mode 100644 index 4f6d8289d..000000000 --- a/docs/installationguide/ubuntu.rst +++ /dev/null @@ -1,52 +0,0 @@ -Ubuntu -====== - -PPA Install ------------ -Follow these instructions to install current release version on Ubuntu.: - - sudo apt-add-repository ppa:iconnor/zoneminder - -Once you have updated the repository then update and install the package.: - - sudo apt-get update - sudo apt-get install zoneminder - - - -Build Package From Source -------------------------- - -A fresh build based on master branch running Ubuntu 1204 LTS. Will likely work for other versions as well.:: - - root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; - - root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; - root@host:~# cd zoneminder; - root@host:~# ln -s distros/ubuntu1204 debian; - root@host:~# dpkg-checkbuilddeps; - root@host:~# dpkg-buildpackage; - - -One level above you'll now find a deb package matching the architecture of the build host\::: - - root@host:~# ls -1 ~/zoneminder\*; - /root/zoneminder_1.26.4-1_amd64.changes - /root/zoneminder_1.26.4-1_amd64.deb - /root/zoneminder_1.26.4-1.dsc - /root/zoneminder_1.26.4-1.tar.gz - - -The dpkg command itself does not resolve dependencies. That's what high-level interfaces like aptitude and apt-get are normally for. Unfortunately, unlike RPM, there's no easy way to install a separate deb package not contained with any repository. - -To overcome this "limitation" we'll use dpkg only to install the zoneminder package and apt-get to fetch all needed dependencies afterwards. Running dpkg-reconfigure in the end will ensure that the setup scripts e.g. for database provisioning were executed.:: - - root@host:~# dpkg -i /root/zoneminder_1.26.4-1_amd64.deb; apt-get install -f; - root@host:~# dpkg-reconfigure zoneminder; - -Alternatively you may also use gdebi to automatically resolve dependencies during installation\::: - - root@host:~# aptitude install -y gdebi; - root@host:~# gdebi /root/zoneminder_1.26.4-1_amd64.deb; - - sudo apt-get install apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg-turbo8-dev libjpeg-turbo8 apache2-mpm-prefork libapache2-mod-php5 php5-cli diff --git a/misc/apache.conf.in b/misc/apache.conf.in index 06c9beb15..7fd0a1617 100644 --- a/misc/apache.conf.in +++ b/misc/apache.conf.in @@ -14,17 +14,19 @@ AllowOverride All - ScriptAlias /cgi-bin/ "@CGI_PREFIX@" + # Remember to enable cgi mod (i.e. "a2enmod cgi"). + ScriptAlias /cgi-bin "@CGI_PREFIX@" Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AllowOverride All + Require all granted # Use the first option to have Apache logs written to the general log # directory, or the second to have them written to the regular Apache # directory (you may have to change the path to that used on your system) ErrorLog @ZM_LOGDIR@/apache-error.log - ErrorLog /var/log/httpd/zm-error.log +# ErrorLog /var/log/httpd/zm-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. @@ -34,6 +36,6 @@ # directory, or the second to have them written to the regular Apache # directory (you may have to change the path to that used on your system) CustomLog @ZM_LOGDIR@/apache-access.log combined - CustomLog /var/log/httpd/zm-access.log combined +# CustomLog /var/log/httpd/zm-access.log combined diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index e55e856e4..8b42a2274 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -428,7 +428,7 @@ our @options = }, { name => "ZM_PATH_ZMS", - default => "/cgi-bin/nph-zms", + default => "/zm/cgi-bin/nph-zms", description => "Web path to zms streaming server", help => qqq(" The ZoneMinder streaming server is required to send streamed diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 017c12502..df1174e36 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2013,7 +2013,7 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) #if ZM_HAS_V4L int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose ) { - std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'"; + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'"; ; if ( device[0] ) { sql += " AND Device='"; @@ -2196,7 +2196,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose ) { - std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'"; + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'"; if ( staticConfig.SERVER_ID ) { sql += " AND ServerId='"; sql += staticConfig.SERVER_ID; @@ -2373,7 +2373,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose ) { - std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'"; + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'"; if ( file[0] ) { sql += " AND Path='"; sql += file; @@ -2516,7 +2516,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu #if HAVE_LIBAVFORMAT int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose ) { - std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'"; + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'"; if ( file[0] ) { sql += " AND Path = '"; sql += file; @@ -2663,7 +2663,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) { - std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id ); + std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id ); MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ); if ( ! dbrow ) { @@ -2704,7 +2704,6 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) v4l_captures_per_frame = config.captures_per_frame; } Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); -<<<<<<< HEAD col++; std::string protocol = dbrow[col]; col++; @@ -2732,6 +2731,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); int label_x = atoi(dbrow[col]); col++; int label_y = atoi(dbrow[col]); col++; + int label_size = atoi(dbrow[col]); col++; int image_buffer_count = atoi(dbrow[col]); col++; int warmup_count = atoi(dbrow[col]); col++; @@ -2742,6 +2742,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); int section_length = atoi(dbrow[col]); col++; int frame_skip = atoi(dbrow[col]); col++; int motion_frame_skip = atoi(dbrow[col]); col++; + double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++; + unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0); int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; int fps_report_interval = atoi(dbrow[col]); col++; @@ -2764,71 +2766,6 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); Camera *camera = 0; if ( type == "Local" ) { -======= - col++; - - std::string protocol = dbrow[col]; col++; - std::string method = dbrow[col]; col++; - std::string host = dbrow[col]; col++; - std::string port = dbrow[col]; col++; - std::string path = dbrow[col]; col++; - std::string options = dbrow[col]; col++; - std::string user = dbrow[col]; col++; - std::string pass = dbrow[col]; col++; - - int width = atoi(dbrow[col]); col++; - int height = atoi(dbrow[col]); col++; - int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; - Orientation orientation = (Orientation)atoi(dbrow[col]); col++; - unsigned int deinterlacing = atoi(dbrow[col]); col++; - int brightness = atoi(dbrow[col]); col++; - int contrast = atoi(dbrow[col]); col++; - int hue = atoi(dbrow[col]); col++; - int colour = atoi(dbrow[col]); col++; - - std::string event_prefix = dbrow[col]; col++; - std::string label_format = dbrow[col]; col++; - - int label_x = atoi(dbrow[col]); col++; - int label_y = atoi(dbrow[col]); col++; - int label_size = atoi(dbrow[col]); col++; - - int image_buffer_count = atoi(dbrow[col]); col++; - int warmup_count = atoi(dbrow[col]); col++; - int pre_event_count = atoi(dbrow[col]); col++; - int post_event_count = atoi(dbrow[col]); col++; - int stream_replay_buffer = atoi(dbrow[col]); col++; - int alarm_frame_count = atoi(dbrow[col]); col++; - int section_length = atoi(dbrow[col]); col++; - int frame_skip = atoi(dbrow[col]); col++; - int motion_frame_skip = atoi(dbrow[col]); col++; - double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++; - unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0); - int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int fps_report_interval = atoi(dbrow[col]); col++; - int ref_blend_perc = atoi(dbrow[col]); col++; - int alarm_ref_blend_perc = atoi(dbrow[col]); col++; - int track_motion = atoi(dbrow[col]); col++; - - int signal_check_colour; - if ( dbrow[col][0] == '#' ) - signal_check_colour = strtol(dbrow[col]+1,0,16); - else - signal_check_colour = strtol(dbrow[col],0,16); - col++; - bool embed_exif = (*dbrow[col] != '0'); col++; - - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - - int extras = (deinterlacing>>24)&0xff; - - Camera *camera = 0; - if ( type == "Local" ) - { ->>>>>>> master #if ZM_HAS_V4L camera = new LocalCamera( id, @@ -2977,7 +2914,6 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); #else // HAVE_LIBCURL Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id ); #endif // HAVE_LIBCURL -<<<<<<< HEAD } else { @@ -2996,6 +2932,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); event_prefix.c_str(), label_format.c_str(), Coord( label_x, label_y ), + label_size, image_buffer_count, warmup_count, pre_event_count, @@ -3005,6 +2942,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); section_length, frame_skip, motion_frame_skip, + analysis_fps, + analysis_update_delay, capture_delay, alarm_capture_delay, fps_report_interval, @@ -3027,68 +2966,6 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); monitor->AddZones( n_zones, zones ); } Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); -======= - } - else - { - Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id ); - } - monitor = new Monitor( - id, - name.c_str(), - function, - enabled, - linked_monitors.c_str(), - camera, - orientation, - deinterlacing, - event_prefix.c_str(), - label_format.c_str(), - Coord( label_x, label_y ), - label_size, - image_buffer_count, - warmup_count, - pre_event_count, - post_event_count, - stream_replay_buffer, - alarm_frame_count, - section_length, - frame_skip, - motion_frame_skip, - analysis_fps, - analysis_update_delay, - capture_delay, - alarm_capture_delay, - fps_report_interval, - ref_blend_perc, - alarm_ref_blend_perc, - track_motion, - signal_check_colour, - embed_exif, - purpose, - 0, - 0 - - ); - - int n_zones = 0; - if ( load_zones ) - { - Zone **zones = 0; - n_zones = Zone::Load( monitor, zones ); - monitor->AddZones( n_zones, zones ); - } - Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); - } - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - // Yadda yadda - mysql_free_result( result ); - ->>>>>>> master return( monitor ); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index d75d4a856..46ace886a 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -307,7 +307,7 @@ protected: public: // OurCheckAlarms seems to be unused. Check it on zm_monitor.cpp for more info. //bool OurCheckAlarms( Zone *zone, const Image *pImage ); - Monitor( int p_id, const char *p_name, unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, unsigned int p_analysis_update_delay, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); + Monitor( int p_id, const char *p_name, unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int label_size, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, unsigned int p_analysis_update_delay, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); ~Monitor(); void AddZones( int p_n_zones, Zone *p_zones[] ); diff --git a/web/api/.gitattributes b/web/api/.gitattributes deleted file mode 100644 index fc3f49166..000000000 --- a/web/api/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -# Define the line ending behavior of the different file extensions -# Set default behaviour, in case users don't have core.autocrlf set. -* text=auto - -# Explicitly declare text files we want to always be normalized and converted -# to native line endings on checkout. -*.php text -*.default text -*.ctp text -*.sql text -*.md text -*.po text -*.js text -*.css text -*.ini text -*.properties text -*.txt text -*.xml text -*.yml text -.htaccess text - -# Declare files that will always have CRLF line endings on checkout. -*.bat eol=crlf - -# Declare files that will always have LF line endings on checkout. -*.pem eol=lf - -# Denote all files that are truly binary and should not be modified. -*.png binary -*.jpg binary -*.gif binary -*.ico binary -*.mo binary \ No newline at end of file diff --git a/web/api/.gitignore b/web/api/.gitignore deleted file mode 100644 index 4a1adb886..000000000 --- a/web/api/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# User specific & automatically generated files # -################################################# -/app/Config/database.php -/app/tmp -/lib/Cake/Console/Templates/skel/tmp/ -/plugins -/vendors -/build -/dist -/tags - -# OS generated files # -###################### -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -.Trashes -Icon? -ehthumbs.db -Thumbs.db \ No newline at end of file diff --git a/web/api/app/Config/core.php b/web/api/app/Config/core.php index 34f8e5ec4..a698a4ea0 100644 --- a/web/api/app/Config/core.php +++ b/web/api/app/Config/core.php @@ -222,12 +222,12 @@ /** * A random string used in security hashing methods. */ - Configure::write('Security.salt', 'ycA4zI3Xb3Eb640RoiWehDeQCHDqKlwBFDK7aSLI'); + Configure::write('Security.salt', '4AlwR5ePsf7gY8OxBCp1ftqw5pHhY7bQIJWwSRSB'); /** * A random numeric string (digits only) used to encrypt/decrypt strings. */ - Configure::write('Security.cipherSeed', '41940792832193579176474142058'); + Configure::write('Security.cipherSeed', '65025553361572663298232797852'); /** * Apply timestamps with the last modified time to static assets (js, css, images). diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 683f1a270..c9328563f 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -67,7 +67,6 @@ function xhtmlHeaders( $file, $title ) ?> - Date: Thu, 27 Aug 2015 11:08:42 -0400 Subject: [PATCH 019/178] restore missing docs --- docs/installationguide/centos.rst | 5 +++++ docs/installationguide/debian.rst | 37 +++++++++++++++++++++++++++++++ docs/installationguide/fedora.rst | 4 ++++ docs/installationguide/index.rst | 12 ++++++++++ 4 files changed, 58 insertions(+) create mode 100644 docs/installationguide/centos.rst create mode 100644 docs/installationguide/debian.rst create mode 100644 docs/installationguide/fedora.rst create mode 100644 docs/installationguide/index.rst diff --git a/docs/installationguide/centos.rst b/docs/installationguide/centos.rst new file mode 100644 index 000000000..606aaffd5 --- /dev/null +++ b/docs/installationguide/centos.rst @@ -0,0 +1,5 @@ +Centos +====== + + + diff --git a/docs/installationguide/debian.rst b/docs/installationguide/debian.rst new file mode 100644 index 000000000..9294ebeb6 --- /dev/null +++ b/docs/installationguide/debian.rst @@ -0,0 +1,37 @@ +Debian +====== + +A fresh build based on master branch running Debian 7 (wheezy)\: +:: + + root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; + + root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; + root@host:~# cd zoneminder; + root@host:~# ln -s distros/debian; + root@host:~# dpkg-checkbuilddeps; + root@host:~# dpkg-buildpackage; + +One level above you'll now find a deb package matching the architecture of the build host: +:: + + root@host:~# ls -1 ~/zoneminder*; + /root/zoneminder_1.26.4-1_amd64.changes + /root/zoneminder_1.26.4-1_amd64.deb + /root/zoneminder_1.26.4-1.dsc + /root/zoneminder_1.26.4-1.tar.gz + +The dpkg command itself does not resolve dependencies. That's what high-level interfaces like aptitude and apt-get are normally for. Unfortunately, unlike RPM, there's no easy way to install a separate deb package not contained with any repository. + +To overcome this "limitation" we'll use dpkg only to install the zoneminder package and apt-get to fetch all needed dependencies afterwards. Running dpkg-reconfigure in the end will ensure that the setup scripts e.g. for database provisioning were executed. +:: + + root@host:~# dpkg -i /root/zoneminder_1.26.4-1_amd64.deb; apt-get install -f; + root@host:~# dpkg-reconfigure zoneminder; + +Alternatively you may also use gdebi to automatically resolve dependencies during installation: +:: + + root@host:~# aptitude install -y gdebi; + root@host:~# gdebi /root/zoneminder_1.26.4-1_amd64.deb; + diff --git a/docs/installationguide/fedora.rst b/docs/installationguide/fedora.rst new file mode 100644 index 000000000..09ffe4297 --- /dev/null +++ b/docs/installationguide/fedora.rst @@ -0,0 +1,4 @@ +Fedora +====== + + diff --git a/docs/installationguide/index.rst b/docs/installationguide/index.rst new file mode 100644 index 000000000..58a8f4b21 --- /dev/null +++ b/docs/installationguide/index.rst @@ -0,0 +1,12 @@ +Installation Guide +====================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + ubuntu + debian + fedora + centos From 53159ed12ca0e48275b819cde2c912ea966d08ec Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:10:05 -0400 Subject: [PATCH 020/178] restore changelog to keep PR clean --- distros/ubuntu1504/changelog | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/distros/ubuntu1504/changelog b/distros/ubuntu1504/changelog index 47a2032bb..9dea00498 100644 --- a/distros/ubuntu1504/changelog +++ b/distros/ubuntu1504/changelog @@ -6,24 +6,6 @@ zoneminder (1.28.1+1-vivid-SNAPSHOT2015071501) vivid; urgency=medium -- Isaac Connor Wed, 15 Jul 2015 11:56:28 -0400 -zoneminder (1.28.1+1-vivid-SNAPSHOT2015070402) vivid; urgency=medium - - * Correct PRIMARY KEY update code on States table - - -- Isaac Connor Tue, 07 Jul 2015 15:40:21 -0400 - -zoneminder (1.28.1+1-vivid-SNAPSHOT2015070401) vivid; urgency=medium - - * Bump actual version # so that db upgrade scripts run - - -- Isaac Connor Tue, 07 Jul 2015 12:44:55 -0400 - -zoneminder (1.28.1+1-vivid-SNAPSHOT2015070301) vivid; urgency=medium - - * initial merge of api. Various other small fixes/improvements. - - -- Isaac Connor Mon, 06 Jul 2015 15:59:08 -0400 - zoneminder (1.28.1+1-trusty-SNAPSHOT2015030201) trusty; urgency=medium * maybe fix for RTSP Basic Auth From 80a294da348afcfcc116479a811fcf135a45aa2b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:10:13 -0400 Subject: [PATCH 021/178] tabs to spaces --- scripts/zmfilter.pl.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 4280f4e48..d98d31809 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -349,10 +349,10 @@ sub getFilters my ( $temp_attr_name ) = $filter_expr->{terms}[$i]->{attr} =~ /^Monitor(.+)$/; $db_filter->{Sql} .= "M.".$temp_attr_name; } - elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) - { - $db_filter->{Sql} .= "M.ServerId"; - } + elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) + { + $db_filter->{Sql} .= "M.ServerId"; + } elsif ( $filter_expr->{terms}[$i]->{attr} eq 'DateTime' ) { $db_filter->{Sql} .= "E.StartTime"; @@ -396,13 +396,13 @@ sub getFilters { $value = "'$temp_value'"; } - elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) { - if ( $temp_value eq 'ZM_SERVER_ID' ) { - $value = "'$Config{ZM_SERVER_ID}'"; - } else { - $value = "'$temp_value'"; - } - } + elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) { + if ( $temp_value eq 'ZM_SERVER_ID' ) { + $value = "'$Config{ZM_SERVER_ID}'"; + } else { + $value = "'$temp_value'"; + } + } elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Name' || $filter_expr->{terms}[$i]->{attr} eq 'Cause' || $filter_expr->{terms}[$i]->{attr} eq 'Notes' From 9cdf8ec31780b0d2c81307237aa14a09b163b26e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:13:44 -0400 Subject: [PATCH 022/178] tabs to spaces --- scripts/zmpkg.pl.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 38f19275e..97b3eff18 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -121,7 +121,7 @@ my $retval = 0; if ( $command eq "state" ) { Info( "Updating DB: $state->{Name}\n" ); - my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=? ORDER BY Id ASC' : 'SELECT * FROM Monitors ORDER BY Id ASC'; + my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=? ORDER BY Id ASC' : 'SELECT * FROM Monitors ORDER BY Id ASC'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID}: () ) @@ -226,7 +226,7 @@ if ( $command =~ /^(?:start|restart)$/ ) zmMemTidy(); runCommand( "zmdc.pl startup" ); - my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors'; + my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () ) From bca9a194888603afda09b026139c779382e8f174 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:14:00 -0400 Subject: [PATCH 023/178] tabs to spaces --- src/zm_monitor.cpp | 980 ++++++++++++++++++++++----------------------- 1 file changed, 490 insertions(+), 490 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 3b5c69cd4..6f9f0e9fa 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -263,7 +263,7 @@ bool Monitor::MonitorLink::hasAlarmed() Monitor::Monitor( int p_id, const char *p_name, - const unsigned int p_server_id, + const unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, @@ -297,7 +297,7 @@ Monitor::Monitor( int p_n_zones, Zone *p_zones[] ) : id( p_id ), - server_id( p_server_id ), + server_id( p_server_id ), function( (Function)p_function ), enabled( p_enabled ), width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), @@ -389,11 +389,11 @@ Monitor::Monitor( + 64; /* Padding used to permit aligning the images buffer to 16 byte boundary */ Debug( 1, "mem.size=%d", mem_size ); - mem_ptr = NULL; + mem_ptr = NULL; if ( purpose == CAPTURE ) { - this->connect(); - if ( ! mem_ptr ) exit(-1); + this->connect(); + if ( ! mem_ptr ) exit(-1); memset( mem_ptr, 0, mem_size ); shared_data->size = sizeof(SharedData); shared_data->active = enabled; @@ -420,8 +420,8 @@ Monitor::Monitor( trigger_data->trigger_showtext[0] = 0; shared_data->valid = true; } else if ( purpose == ANALYSIS ) { - this->connect(); - if ( ! mem_ptr ) exit(-1); + this->connect(); + if ( ! mem_ptr ) exit(-1); shared_data->state = IDLE; shared_data->last_read_time = 0; shared_data->alarm_x = -1; @@ -437,9 +437,9 @@ Monitor::Monitor( } } - // Will this not happen every time a monitor is instantiated? Seems like all the calls to the Monitor constructor pass a zero for n_zones, then load zones after.. + // Will this not happen every time a monitor is instantiated? Seems like all the calls to the Monitor constructor pass a zero for n_zones, then load zones after.. if ( !n_zones ) { - Debug( 1, "Monitor %s has no zones, adding one.", name ); + Debug( 1, "Monitor %s has no zones, adding one.", name ); n_zones = 1; zones = new Zone *[1]; Coord coords[4] = { Coord( 0, 0 ), Coord( width-1, 0 ), Coord( width-1, height-1 ), Coord( 0, height-1 ) }; @@ -521,28 +521,28 @@ bool Monitor::connect() { // Allocate the size if ( ftruncate( map_fd, mem_size ) < 0 ) { Fatal( "Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno) ); - } + } } else if ( map_stat.st_size == 0 ) { Error( "Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size ); - return false; + return false; } else if ( map_stat.st_size != mem_size ) { Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size ); - return false; - } else { + return false; + } else { #ifdef MAP_LOCKED - mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0 ); - if ( mem_ptr == MAP_FAILED ) { - if ( errno == EAGAIN ) { - Debug( 1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size ); + mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0 ); + if ( mem_ptr == MAP_FAILED ) { + if ( errno == EAGAIN ) { + Debug( 1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size ); #endif - mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 ); - Debug( 1, "Mapped file %s (%d bytes) to locked memory, unlocked", mem_file, mem_size ); + mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 ); + Debug( 1, "Mapped file %s (%d bytes) to locked memory, unlocked", mem_file, mem_size ); #ifdef MAP_LOCKED - } - } + } + } #endif - if ( mem_ptr == MAP_FAILED ) - Fatal( "Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno ); + if ( mem_ptr == MAP_FAILED ) + Fatal( "Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno ); } #else // ZM_MEM_MAPPED shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, IPC_CREAT|0700 ); @@ -563,9 +563,9 @@ bool Monitor::connect() { unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); if(((unsigned long)shared_images % 16) != 0) { - /* Align images buffer to nearest 16 byte boundary */ - Debug(3,"Aligning shared memory images to the next 16 byte boundary"); - shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16))); + /* Align images buffer to nearest 16 byte boundary */ + Debug(3,"Aligning shared memory images to the next 16 byte boundary"); + shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16))); } image_buffer = new Snapshot[image_buffer_count]; for ( int i = 0; i < image_buffer_count; i++ ) @@ -596,39 +596,39 @@ bool Monitor::connect() { } } - return true; + return true; } Monitor::~Monitor() { - if ( timestamps ) { - delete[] timestamps; - timestamps = 0; - } - if ( images ) { - delete[] images; - images = 0; - } + if ( timestamps ) { + delete[] timestamps; + timestamps = 0; + } + if ( images ) { + delete[] images; + images = 0; + } if ( privacy_bitmask ) { delete[] privacy_bitmask; privacy_bitmask = NULL; } - if ( mem_ptr ) { - if ( event ) - Info( "%s: %03d - Closing event %d, shutting down", name, image_count, event->Id() ); - closeEvent(); + if ( mem_ptr ) { + if ( event ) + Info( "%s: %03d - Closing event %d, shutting down", name, image_count, event->Id() ); + closeEvent(); - if ( (deinterlacing & 0xff) == 4) - { - delete next_buffer.image; - delete next_buffer.timestamp; - } - for ( int i = 0; i < image_buffer_count; i++ ) - { - delete image_buffer[i].image; - } - delete[] image_buffer; - } // end if mem_ptr + if ( (deinterlacing & 0xff) == 4) + { + delete next_buffer.image; + delete next_buffer.timestamp; + } + for ( int i = 0; i < image_buffer_count; i++ ) + { + delete image_buffer[i].image; + } + delete[] image_buffer; + } // end if mem_ptr for ( int i = 0; i < n_zones; i++ ) { @@ -638,49 +638,49 @@ Monitor::~Monitor() delete camera; - if ( mem_ptr ) { - if ( purpose == ANALYSIS ) - { - shared_data->state = state = IDLE; - shared_data->last_read_index = image_buffer_count; - shared_data->last_read_time = 0; + if ( mem_ptr ) { + if ( purpose == ANALYSIS ) + { + shared_data->state = state = IDLE; + shared_data->last_read_index = image_buffer_count; + shared_data->last_read_time = 0; - if ( analysis_fps ) - { - for ( int i = 0; i < pre_event_buffer_count; i++ ) - { - delete pre_event_buffer[i].image; - delete pre_event_buffer[i].timestamp; - } - delete[] pre_event_buffer; - } - } - else if ( purpose == CAPTURE ) - { - shared_data->valid = false; - memset( mem_ptr, 0, mem_size ); - } + if ( analysis_fps ) + { + for ( int i = 0; i < pre_event_buffer_count; i++ ) + { + delete pre_event_buffer[i].image; + delete pre_event_buffer[i].timestamp; + } + delete[] pre_event_buffer; + } + } + else if ( purpose == CAPTURE ) + { + shared_data->valid = false; + memset( mem_ptr, 0, mem_size ); + } #if ZM_MEM_MAPPED - if ( msync( mem_ptr, mem_size, MS_SYNC ) < 0 ) - Error( "Can't msync: %s", strerror(errno) ); - if ( munmap( mem_ptr, mem_size ) < 0 ) - Fatal( "Can't munmap: %s", strerror(errno) ); - close( map_fd ); + if ( msync( mem_ptr, mem_size, MS_SYNC ) < 0 ) + Error( "Can't msync: %s", strerror(errno) ); + if ( munmap( mem_ptr, mem_size ) < 0 ) + Fatal( "Can't munmap: %s", strerror(errno) ); + close( map_fd ); #else // ZM_MEM_MAPPED - struct shmid_ds shm_data; - if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) { - Error( "Can't shmctl: %s", strerror(errno) ); - exit( -1 ); - } - if ( shm_data.shm_nattch <= 1 ) { - if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 ) { - Error( "Can't shmctl: %s", strerror(errno) ); - exit( -1 ); - } - } + struct shmid_ds shm_data; + if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) { + Error( "Can't shmctl: %s", strerror(errno) ); + exit( -1 ); + } + if ( shm_data.shm_nattch <= 1 ) { + if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 ) { + Error( "Can't shmctl: %s", strerror(errno) ); + exit( -1 ); + } + } #endif // ZM_MEM_MAPPED - } // end if mem_ptr + } // end if mem_ptr } void Monitor::AddZones( int p_n_zones, Zone *p_zones[] ) @@ -728,7 +728,7 @@ int Monitor::GetImage( int index, int scale ) if ( index != image_buffer_count ) { Image *image; - // If we are going to be modifying the snapshot before writing, then we need to copy it + // If we are going to be modifying the snapshot before writing, then we need to copy it if ( ( scale != ZM_SCALE_BASE ) || ( !config.timestamp_on_capture ) ) { Snapshot *snap = &image_buffer[index]; Image *snap_image = snap->image; @@ -1228,32 +1228,32 @@ bool Monitor::CheckSignal( const Image *image ) break; } - if(colours == ZM_COLOUR_GRAY8) { - if ( *(buffer+index) != grayscale_val ) - return true; - - } else if(colours == ZM_COLOUR_RGB24) { - const uint8_t *ptr = buffer+(index*colours); - - if ( usedsubpixorder == ZM_SUBPIX_ORDER_BGR) { - if ( (RED_PTR_BGRA(ptr) != red_val) || (GREEN_PTR_BGRA(ptr) != green_val) || (BLUE_PTR_BGRA(ptr) != blue_val) ) - return true; - } else { - /* Assume RGB */ - if ( (RED_PTR_RGBA(ptr) != red_val) || (GREEN_PTR_RGBA(ptr) != green_val) || (BLUE_PTR_RGBA(ptr) != blue_val) ) - return true; - } - - } else if(colours == ZM_COLOUR_RGB32) { - if ( usedsubpixorder == ZM_SUBPIX_ORDER_ARGB || usedsubpixorder == ZM_SUBPIX_ORDER_ABGR) { - if ( ARGB_ABGR_ZEROALPHA(*(((const Rgb*)buffer)+index)) != ARGB_ABGR_ZEROALPHA(colour_val) ) - return true; - } else { - /* Assume RGBA or BGRA */ - if ( RGBA_BGRA_ZEROALPHA(*(((const Rgb*)buffer)+index)) != RGBA_BGRA_ZEROALPHA(colour_val) ) - return true; - } - } + if(colours == ZM_COLOUR_GRAY8) { + if ( *(buffer+index) != grayscale_val ) + return true; + + } else if(colours == ZM_COLOUR_RGB24) { + const uint8_t *ptr = buffer+(index*colours); + + if ( usedsubpixorder == ZM_SUBPIX_ORDER_BGR) { + if ( (RED_PTR_BGRA(ptr) != red_val) || (GREEN_PTR_BGRA(ptr) != green_val) || (BLUE_PTR_BGRA(ptr) != blue_val) ) + return true; + } else { + /* Assume RGB */ + if ( (RED_PTR_RGBA(ptr) != red_val) || (GREEN_PTR_RGBA(ptr) != green_val) || (BLUE_PTR_RGBA(ptr) != blue_val) ) + return true; + } + + } else if(colours == ZM_COLOUR_RGB32) { + if ( usedsubpixorder == ZM_SUBPIX_ORDER_ARGB || usedsubpixorder == ZM_SUBPIX_ORDER_ABGR) { + if ( ARGB_ABGR_ZEROALPHA(*(((const Rgb*)buffer)+index)) != ARGB_ABGR_ZEROALPHA(colour_val) ) + return true; + } else { + /* Assume RGBA or BGRA */ + if ( RGBA_BGRA_ZEROALPHA(*(((const Rgb*)buffer)+index)) != RGBA_BGRA_ZEROALPHA(colour_val) ) + return true; + } + } } return( false ); @@ -1724,7 +1724,7 @@ bool Monitor::Analyse() if ( config.create_analysis_images ) { bool got_anal_image = false; - alarm_image.Assign( *snap_image ); + alarm_image.Assign( *snap_image ); for( int i = 0; i < n_zones; i++ ) { if ( zones[i]->Alarmed() ) @@ -2038,18 +2038,18 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) #if ZM_HAS_V4L int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose ) { - std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'"; + std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'"; ; if ( device[0] ) { - sql += " AND Device='"; - sql += device; - sql += "'"; - } - if ( staticConfig.SERVER_ID ) { - sql += " AND ServerId='"; - sql += staticConfig.SERVER_ID; - sql += "'"; - } + sql += " AND Device='"; + sql += device; + sql += "'"; + } + if ( staticConfig.SERVER_ID ) { + sql += " AND ServerId='"; + sql += staticConfig.SERVER_ID; + sql += "'"; + } MYSQL_RES *result = zmDbFetch( sql.c_str() ); if ( !result ) { @@ -2066,7 +2066,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2074,26 +2074,26 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose const char *device = dbrow[col]; col++; int channel = atoi(dbrow[col]); col++; int format = atoi(dbrow[col]); col++; - bool v4l_multi_buffer; - if ( dbrow[col] ) { - if (*dbrow[col] == '0' ) { - v4l_multi_buffer = false; - } else if ( *dbrow[col] == '1' ) { - v4l_multi_buffer = true; - } - } else { - v4l_multi_buffer = config.v4l_multi_buffer; - } - col++; - - int v4l_captures_per_frame = 0; - if ( dbrow[col] ) { - v4l_captures_per_frame = atoi(dbrow[col]); - } else { - v4l_captures_per_frame = config.captures_per_frame; - } + bool v4l_multi_buffer; + if ( dbrow[col] ) { + if (*dbrow[col] == '0' ) { + v4l_multi_buffer = false; + } else if ( *dbrow[col] == '1' ) { + v4l_multi_buffer = true; + } + } else { + v4l_multi_buffer = config.v4l_multi_buffer; + } + col++; + + int v4l_captures_per_frame = 0; + if ( dbrow[col] ) { + v4l_captures_per_frame = atoi(dbrow[col]); + } else { + v4l_captures_per_frame = config.captures_per_frame; + } Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); - col++; + col++; const char *method = dbrow[col]; col++; int width = atoi(dbrow[col]); col++; @@ -2150,8 +2150,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); device, channel, format, - v4l_multi_buffer, - v4l_captures_per_frame, + v4l_multi_buffer, + v4l_captures_per_frame, method, cam_width, cam_height, @@ -2168,7 +2168,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); monitors[i] = new Monitor( id, name, - server_id, + server_id, function, enabled, linked_monitors, @@ -2248,7 +2248,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int id = atoi(dbrow[col]); col++; std::string name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2346,7 +2346,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c monitors[i] = new Monitor( id, name.c_str(), - server_id, + server_id, function, enabled, linked_monitors, @@ -2402,9 +2402,9 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu { std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'"; if ( file[0] ) { - sql += " AND Path='"; - sql += file; - sql += "'"; + sql += " AND Path='"; + sql += file; + sql += "'"; } if ( staticConfig.SERVER_ID ) { sql += " AND ServerId='"; @@ -2427,7 +2427,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2490,7 +2490,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu monitors[i] = new Monitor( id, name, - server_id, + server_id, function, enabled, linked_monitors, @@ -2546,9 +2546,9 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose { std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'"; if ( file[0] ) { - sql += " AND Path = '"; - sql += file; - sql += "'"; + sql += " AND Path = '"; + sql += file; + sql += "'"; } if ( staticConfig.SERVER_ID ) { sql += " AND ServerId='"; @@ -2571,7 +2571,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = atoi(dbrow[col]); col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2638,7 +2638,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose monitors[i] = new Monitor( id, name, - server_id, + server_id, function, enabled, linked_monitors, @@ -2694,337 +2694,337 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) { std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id ); - MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ); + MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ); if ( ! dbrow ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } Monitor *monitor = 0; - unsigned int col = 0; + unsigned int col = 0; - unsigned int id = atoi(dbrow[col]); col++; - std::string name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; - std::string type = dbrow[col]; col++; - int function = atoi(dbrow[col]); col++; - int enabled = atoi(dbrow[col]); col++; - std::string linked_monitors = dbrow[col]; col++; + unsigned int id = atoi(dbrow[col]); col++; + std::string name = dbrow[col]; col++; + unsigned int server_id = atoi(dbrow[col]); col++; + std::string type = dbrow[col]; col++; + int function = atoi(dbrow[col]); col++; + int enabled = atoi(dbrow[col]); col++; + std::string linked_monitors = dbrow[col]; col++; - std::string device = dbrow[col]; col++; - int channel = atoi(dbrow[col]); col++; - int format = atoi(dbrow[col]); col++; + std::string device = dbrow[col]; col++; + int channel = atoi(dbrow[col]); col++; + int format = atoi(dbrow[col]); col++; - bool v4l_multi_buffer; - if ( dbrow[col] ) { - if (*dbrow[col] == '0' ) { - v4l_multi_buffer = false; - } else if ( *dbrow[col] == '1' ) { - v4l_multi_buffer = true; - } - } else { - v4l_multi_buffer = config.v4l_multi_buffer; - } - col++; + bool v4l_multi_buffer; + if ( dbrow[col] ) { + if (*dbrow[col] == '0' ) { + v4l_multi_buffer = false; + } else if ( *dbrow[col] == '1' ) { + v4l_multi_buffer = true; + } + } else { + v4l_multi_buffer = config.v4l_multi_buffer; + } + col++; - int v4l_captures_per_frame = 0; - if ( dbrow[col] ) { - v4l_captures_per_frame = atoi(dbrow[col]); - } else { - v4l_captures_per_frame = config.captures_per_frame; - } + int v4l_captures_per_frame = 0; + if ( dbrow[col] ) { + v4l_captures_per_frame = atoi(dbrow[col]); + } else { + v4l_captures_per_frame = config.captures_per_frame; + } Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); - col++; + col++; - std::string protocol = dbrow[col]; col++; - std::string method = dbrow[col]; col++; - std::string host = dbrow[col]; col++; - std::string port = dbrow[col]; col++; - std::string path = dbrow[col]; col++; - std::string options = dbrow[col]; col++; - std::string user = dbrow[col]; col++; - std::string pass = dbrow[col]; col++; + std::string protocol = dbrow[col]; col++; + std::string method = dbrow[col]; col++; + std::string host = dbrow[col]; col++; + std::string port = dbrow[col]; col++; + std::string path = dbrow[col]; col++; + std::string options = dbrow[col]; col++; + std::string user = dbrow[col]; col++; + std::string pass = dbrow[col]; col++; - int width = atoi(dbrow[col]); col++; - int height = atoi(dbrow[col]); col++; - int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; - Orientation orientation = (Orientation)atoi(dbrow[col]); col++; - unsigned int deinterlacing = atoi(dbrow[col]); col++; - int brightness = atoi(dbrow[col]); col++; - int contrast = atoi(dbrow[col]); col++; - int hue = atoi(dbrow[col]); col++; - int colour = atoi(dbrow[col]); col++; + int width = atoi(dbrow[col]); col++; + int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; + int palette = atoi(dbrow[col]); col++; + Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; + int brightness = atoi(dbrow[col]); col++; + int contrast = atoi(dbrow[col]); col++; + int hue = atoi(dbrow[col]); col++; + int colour = atoi(dbrow[col]); col++; - std::string event_prefix = dbrow[col]; col++; - std::string label_format = dbrow[col]; col++; + std::string event_prefix = dbrow[col]; col++; + std::string label_format = dbrow[col]; col++; - int label_x = atoi(dbrow[col]); col++; - int label_y = atoi(dbrow[col]); col++; - int label_size = atoi(dbrow[col]); col++; + int label_x = atoi(dbrow[col]); col++; + int label_y = atoi(dbrow[col]); col++; + int label_size = atoi(dbrow[col]); col++; - int image_buffer_count = atoi(dbrow[col]); col++; - int warmup_count = atoi(dbrow[col]); col++; - int pre_event_count = atoi(dbrow[col]); col++; - int post_event_count = atoi(dbrow[col]); col++; - int stream_replay_buffer = atoi(dbrow[col]); col++; - int alarm_frame_count = atoi(dbrow[col]); col++; - int section_length = atoi(dbrow[col]); col++; - int frame_skip = atoi(dbrow[col]); col++; - int motion_frame_skip = atoi(dbrow[col]); col++; - double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++; - unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0); - int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; - int fps_report_interval = atoi(dbrow[col]); col++; - int ref_blend_perc = atoi(dbrow[col]); col++; - int alarm_ref_blend_perc = atoi(dbrow[col]); col++; - int track_motion = atoi(dbrow[col]); col++; + int image_buffer_count = atoi(dbrow[col]); col++; + int warmup_count = atoi(dbrow[col]); col++; + int pre_event_count = atoi(dbrow[col]); col++; + int post_event_count = atoi(dbrow[col]); col++; + int stream_replay_buffer = atoi(dbrow[col]); col++; + int alarm_frame_count = atoi(dbrow[col]); col++; + int section_length = atoi(dbrow[col]); col++; + int frame_skip = atoi(dbrow[col]); col++; + int motion_frame_skip = atoi(dbrow[col]); col++; + double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++; + unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0); + int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; + int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++; + int fps_report_interval = atoi(dbrow[col]); col++; + int ref_blend_perc = atoi(dbrow[col]); col++; + int alarm_ref_blend_perc = atoi(dbrow[col]); col++; + int track_motion = atoi(dbrow[col]); col++; - int signal_check_colour; - if ( dbrow[col][0] == '#' ) - signal_check_colour = strtol(dbrow[col]+1,0,16); - else - signal_check_colour = strtol(dbrow[col],0,16); + int signal_check_colour; + if ( dbrow[col][0] == '#' ) + signal_check_colour = strtol(dbrow[col]+1,0,16); + else + signal_check_colour = strtol(dbrow[col],0,16); bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); + int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); + int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - int extras = (deinterlacing>>24)&0xff; + int extras = (deinterlacing>>24)&0xff; - Camera *camera = 0; - if ( type == "Local" ) - { + Camera *camera = 0; + if ( type == "Local" ) + { #if ZM_HAS_V4L - camera = new LocalCamera( - id, - device.c_str(), - channel, - format, - v4l_multi_buffer, - v4l_captures_per_frame, - method, - cam_width, - cam_height, - colours, - palette, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE, - extras - ); + camera = new LocalCamera( + id, + device.c_str(), + channel, + format, + v4l_multi_buffer, + v4l_captures_per_frame, + method, + cam_width, + cam_height, + colours, + palette, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE, + extras + ); #else // ZM_HAS_V4L - Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); + Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); #endif // ZM_HAS_V4L - } - else if ( type == "Remote" ) - { - if ( protocol == "http" ) - { - camera = new RemoteCameraHttp( - id, - method.c_str(), - host.c_str(), - port.c_str(), - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); - } - else if ( protocol == "rtsp" ) - { + } + else if ( type == "Remote" ) + { + if ( protocol == "http" ) + { + camera = new RemoteCameraHttp( + id, + method.c_str(), + host.c_str(), + port.c_str(), + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); + } + else if ( protocol == "rtsp" ) + { #if HAVE_LIBAVFORMAT - camera = new RemoteCameraRtsp( - id, - method.c_str(), - host.c_str(), - port.c_str(), - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new RemoteCameraRtsp( + id, + method.c_str(), + host.c_str(), + port.c_str(), + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBAVFORMAT - Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); + Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); #endif // HAVE_LIBAVFORMAT - } - else - { - Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); - } - } - else if ( type == "File" ) - { - camera = new FileCamera( - id, - path.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); - } - else if ( type == "Ffmpeg" ) - { + } + else + { + Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id ); + } + } + else if ( type == "File" ) + { + camera = new FileCamera( + id, + path.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); + } + else if ( type == "Ffmpeg" ) + { #if HAVE_LIBAVFORMAT - camera = new FfmpegCamera( - id, - path.c_str(), - method, - options, - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new FfmpegCamera( + id, + path.c_str(), + method, + options, + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBAVFORMAT - Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id ); + Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id ); #endif // HAVE_LIBAVFORMAT - } - else if (type == "Libvlc") - { + } + else if (type == "Libvlc") + { #if HAVE_LIBVLC - camera = new LibvlcCamera( - id, - path.c_str(), - method, - options, - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new LibvlcCamera( + id, + path.c_str(), + method, + options, + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBVLC - Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id ); + Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id ); #endif // HAVE_LIBVLC - } - else if ( type == "cURL" ) - { + } + else if ( type == "cURL" ) + { #if HAVE_LIBCURL - camera = new cURLCamera( - id, - path.c_str(), - user.c_str(), - pass.c_str(), - cam_width, - cam_height, - colours, - brightness, - contrast, - hue, - colour, - purpose==CAPTURE - ); + camera = new cURLCamera( + id, + path.c_str(), + user.c_str(), + pass.c_str(), + cam_width, + cam_height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE + ); #else // HAVE_LIBCURL - Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id ); + Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id ); #endif // HAVE_LIBCURL - } - else - { - Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id ); - } - monitor = new Monitor( - id, - name.c_str(), - server_id, - function, - enabled, - linked_monitors.c_str(), - camera, - orientation, - deinterlacing, - event_prefix.c_str(), - label_format.c_str(), - Coord( label_x, label_y ), - label_size, - image_buffer_count, - warmup_count, - pre_event_count, - post_event_count, - stream_replay_buffer, - alarm_frame_count, - section_length, - frame_skip, - motion_frame_skip, - analysis_fps, - analysis_update_delay, - capture_delay, - alarm_capture_delay, - fps_report_interval, - ref_blend_perc, - alarm_ref_blend_perc, - track_motion, - signal_check_colour, + } + else + { + Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id ); + } + monitor = new Monitor( + id, + name.c_str(), + server_id, + function, + enabled, + linked_monitors.c_str(), + camera, + orientation, + deinterlacing, + event_prefix.c_str(), + label_format.c_str(), + Coord( label_x, label_y ), + label_size, + image_buffer_count, + warmup_count, + pre_event_count, + post_event_count, + stream_replay_buffer, + alarm_frame_count, + section_length, + frame_skip, + motion_frame_skip, + analysis_fps, + analysis_update_delay, + capture_delay, + alarm_capture_delay, + fps_report_interval, + ref_blend_perc, + alarm_ref_blend_perc, + track_motion, + signal_check_colour, embed_exif, - purpose, - 0, - 0 + purpose, + 0, + 0 - ); + ); - int n_zones = 0; - if ( load_zones ) - { - Zone **zones = 0; - n_zones = Zone::Load( monitor, zones ); - monitor->AddZones( n_zones, zones ); + int n_zones = 0; + if ( load_zones ) + { + Zone **zones = 0; + n_zones = Zone::Load( monitor, zones ); + monitor->AddZones( n_zones, zones ); monitor->AddPrivacyBitmask( zones ); - } - Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); + } + Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); return( monitor ); } int Monitor::Capture() { - static int FirstCapture = 1; - int captureResult; - - int index = image_count%image_buffer_count; - Image* capture_image = image_buffer[index].image; - - if ( (deinterlacing & 0xff) == 4) { - if ( FirstCapture != 1 ) { - /* Copy the next image into the shared memory */ - capture_image->CopyBuffer(*(next_buffer.image)); - } - - /* Capture a new next image */ - captureResult = camera->Capture(*(next_buffer.image)); - - if ( FirstCapture ) { - FirstCapture = 0; - return 0; - } - - } else { - /* Capture directly into image buffer, avoiding the need to memcpy() */ - captureResult = camera->Capture(*capture_image); - } + static int FirstCapture = 1; + int captureResult; + + int index = image_count%image_buffer_count; + Image* capture_image = image_buffer[index].image; + + if ( (deinterlacing & 0xff) == 4) { + if ( FirstCapture != 1 ) { + /* Copy the next image into the shared memory */ + capture_image->CopyBuffer(*(next_buffer.image)); + } + + /* Capture a new next image */ + captureResult = camera->Capture(*(next_buffer.image)); + + if ( FirstCapture ) { + FirstCapture = 0; + return 0; + } + + } else { + /* Capture directly into image buffer, avoiding the need to memcpy() */ + captureResult = camera->Capture(*capture_image); + } if ( captureResult != 0 ) { @@ -3041,18 +3041,18 @@ int Monitor::Capture() if ( captureResult == 1 ) { - /* Deinterlacing */ - if ( (deinterlacing & 0xff) == 1 ) { - capture_image->Deinterlace_Discard(); - } else if ( (deinterlacing & 0xff) == 2 ) { - capture_image->Deinterlace_Linear(); - } else if ( (deinterlacing & 0xff) == 3 ) { - capture_image->Deinterlace_Blend(); - } else if ( (deinterlacing & 0xff) == 4 ) { - capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff ); - } else if ( (deinterlacing & 0xff) == 5 ) { - capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff ); - } + /* Deinterlacing */ + if ( (deinterlacing & 0xff) == 1 ) { + capture_image->Deinterlace_Discard(); + } else if ( (deinterlacing & 0xff) == 2 ) { + capture_image->Deinterlace_Linear(); + } else if ( (deinterlacing & 0xff) == 3 ) { + capture_image->Deinterlace_Blend(); + } else if ( (deinterlacing & 0xff) == 4 ) { + capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff ); + } else if ( (deinterlacing & 0xff) == 5 ) { + capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff ); + } if ( orientation != ROTATE_0 ) @@ -3085,7 +3085,7 @@ int Monitor::Capture() if ( capture_image->Size() > camera->ImageSize() ) { - Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() ); + Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() ); return( -1 ); } @@ -3464,7 +3464,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z } if (zone->CheckExtendAlarmCount()) { alarm=true; - zone->SetAlarm(); + zone->SetAlarm(); } else { zone->ClearAlarm(); } @@ -4161,36 +4161,36 @@ void MonitorStream::runStream() char *swap_path = 0; bool buffered_playback = false; - int swap_path_length = strlen(config.path_swap)+1; // +1 for NULL terminator + int swap_path_length = strlen(config.path_swap)+1; // +1 for NULL terminator - if ( connkey && playback_buffer > 0 ) { + if ( connkey && playback_buffer > 0 ) { - if ( swap_path_length + 15 > PATH_MAX ) { - // 15 is for /zmswap-whatever, assuming max 6 digits for monitor id - Error( "Swap Path is too long. %d > %d ", swap_path_length+15, PATH_MAX ); - } else { - swap_path = (char *)malloc( swap_path_length+15 ); - Debug( 3, "Checking swap image path %s", config.path_swap ); - strncpy( swap_path, config.path_swap, swap_path_length ); - if ( checkSwapPath( swap_path, false ) ) { - snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-m%d", monitor->Id() ); - if ( checkSwapPath( swap_path, true ) ) { - snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-q%06d", connkey ); - if ( checkSwapPath( swap_path, true ) ) { - buffered_playback = true; - } - } - } + if ( swap_path_length + 15 > PATH_MAX ) { + // 15 is for /zmswap-whatever, assuming max 6 digits for monitor id + Error( "Swap Path is too long. %d > %d ", swap_path_length+15, PATH_MAX ); + } else { + swap_path = (char *)malloc( swap_path_length+15 ); + Debug( 3, "Checking swap image path %s", config.path_swap ); + strncpy( swap_path, config.path_swap, swap_path_length ); + if ( checkSwapPath( swap_path, false ) ) { + snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-m%d", monitor->Id() ); + if ( checkSwapPath( swap_path, true ) ) { + snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-q%06d", connkey ); + if ( checkSwapPath( swap_path, true ) ) { + buffered_playback = true; + } + } + } - if ( !buffered_playback ) { - Error( "Unable to validate swap image path, disabling buffered playback" ); - } else { - Debug( 2, "Assigning temporary buffer" ); - temp_image_buffer = new SwapImage[temp_image_buffer_count]; - memset( temp_image_buffer, 0, sizeof(*temp_image_buffer)*temp_image_buffer_count ); - Debug( 2, "Assigned temporary buffer" ); - } - } + if ( !buffered_playback ) { + Error( "Unable to validate swap image path, disabling buffered playback" ); + } else { + Debug( 2, "Assigning temporary buffer" ); + temp_image_buffer = new SwapImage[temp_image_buffer_count]; + memset( temp_image_buffer, 0, sizeof(*temp_image_buffer)*temp_image_buffer_count ); + Debug( 2, "Assigned temporary buffer" ); + } + } } float max_secs_since_last_sent_frame = 10.0; //should be > keep alive amount (5 secs) @@ -4428,7 +4428,7 @@ void MonitorStream::runStream() } } } - if ( swap_path ) free( swap_path ); + if ( swap_path ) free( swap_path ); closeComms(); } From 09e5463a81df2cc8fd6b7513f9b04df32f9ed6ab Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:16:58 -0400 Subject: [PATCH 024/178] test for value in server_id before atoi --- src/zm_monitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 6f9f0e9fa..35f82ac8f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2066,7 +2066,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2248,7 +2248,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int id = atoi(dbrow[col]); col++; std::string name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2427,7 +2427,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2571,7 +2571,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int id = atoi(dbrow[col]); col++; const char *name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; const char *linked_monitors = dbrow[col]; col++; @@ -2704,7 +2704,7 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) unsigned int id = atoi(dbrow[col]); col++; std::string name = dbrow[col]; col++; - unsigned int server_id = atoi(dbrow[col]); col++; + unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++; std::string type = dbrow[col]; col++; int function = atoi(dbrow[col]); col++; int enabled = atoi(dbrow[col]); col++; From b2699237c78c35c5a5b5c1a6bb393b543ac01d48 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:35:47 -0400 Subject: [PATCH 025/178] put back mootools --- web/skins/classic/includes/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index c9328563f..683f1a270 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -67,6 +67,7 @@ function xhtmlHeaders( $file, $title ) ?> + Date: Thu, 27 Aug 2015 11:37:33 -0400 Subject: [PATCH 026/178] restore --- web/api/app/Config/core.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/api/app/Config/core.php b/web/api/app/Config/core.php index 9bb177506..5902a2235 100644 --- a/web/api/app/Config/core.php +++ b/web/api/app/Config/core.php @@ -223,12 +223,12 @@ /** * A random string used in security hashing methods. */ - Configure::write('Security.salt', '4AlwR5ePsf7gY8OxBCp1ftqw5pHhY7bQIJWwSRSB'); + Configure::write('Security.salt', 'Q0MjGG2xRQEhJVQR85WhFJKI7f2St8RYMlVR7GNQ'); /** * A random numeric string (digits only) used to encrypt/decrypt strings. */ - Configure::write('Security.cipherSeed', '65025553361572663298232797852'); + Configure::write('Security.cipherSeed', '02670120062639232092038865362'); /** * Apply timestamps with the last modified time to static assets (js, css, images). From f5ba7cb20856cd77b29d677dffbb481dffbbc595 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 27 Aug 2015 11:39:16 -0400 Subject: [PATCH 027/178] restore --- web/api/.gitattributes | 33 +++++++++++++++++++++++++++++++++ web/api/.gitignore | 21 +++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 web/api/.gitattributes create mode 100644 web/api/.gitignore diff --git a/web/api/.gitattributes b/web/api/.gitattributes new file mode 100644 index 000000000..fc3f49166 --- /dev/null +++ b/web/api/.gitattributes @@ -0,0 +1,33 @@ +# Define the line ending behavior of the different file extensions +# Set default behaviour, in case users don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files we want to always be normalized and converted +# to native line endings on checkout. +*.php text +*.default text +*.ctp text +*.sql text +*.md text +*.po text +*.js text +*.css text +*.ini text +*.properties text +*.txt text +*.xml text +*.yml text +.htaccess text + +# Declare files that will always have CRLF line endings on checkout. +*.bat eol=crlf + +# Declare files that will always have LF line endings on checkout. +*.pem eol=lf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary +*.gif binary +*.ico binary +*.mo binary \ No newline at end of file diff --git a/web/api/.gitignore b/web/api/.gitignore new file mode 100644 index 000000000..4a1adb886 --- /dev/null +++ b/web/api/.gitignore @@ -0,0 +1,21 @@ +# User specific & automatically generated files # +################################################# +/app/Config/database.php +/app/tmp +/lib/Cake/Console/Templates/skel/tmp/ +/plugins +/vendors +/build +/dist +/tags + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db \ No newline at end of file From 70fa177a32fb0428b228f8a78b8086533b284a78 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 31 Aug 2015 16:04:34 -0400 Subject: [PATCH 028/178] bump db version --- CMakeLists.txt | 2 +- configure.ac | 2 +- version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3e3779f0..aa052ccc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # cmake_minimum_required (VERSION 2.6) project (zoneminder) -set(zoneminder_VERSION "1.28.106") +set(zoneminder_VERSION "1.28.107") # make API version a minor of ZM version set(zoneminder_API_VERSION "${zoneminder_VERSION}.1") diff --git a/configure.ac b/configure.ac index 32ba09ae1..0bdb55fd5 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # For instructions on building with cmake, please see INSTALL # AC_PREREQ(2.59) -AC_INIT(zm,1.28.105,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html) +AC_INIT(zm,1.28.107,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR(src/zm.h) AC_CONFIG_HEADERS(config.h) diff --git a/version b/version index 71864bd8d..0234b6353 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.28.106 +1.28.107 From e4238edd53bf0e78730466b10640d52102c4ab5f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 14 Sep 2015 14:11:49 -0400 Subject: [PATCH 029/178] this build patch is no longer needed --- .../ubuntu1504_cmake/patches/apache2.patch | 40 ------------------- distros/ubuntu1504_cmake/patches/series | 1 - 2 files changed, 41 deletions(-) delete mode 100644 distros/ubuntu1504_cmake/patches/apache2.patch diff --git a/distros/ubuntu1504_cmake/patches/apache2.patch b/distros/ubuntu1504_cmake/patches/apache2.patch deleted file mode 100644 index 9710b3b63..000000000 --- a/distros/ubuntu1504_cmake/patches/apache2.patch +++ /dev/null @@ -1,40 +0,0 @@ -Last-Update: 2015-04-02 -Forwarded: no -Author: Dmitry Smirnov -Description: adapt apache2.conf to work out-of-the-box. - ---- a/misc/apache.conf.in -+++ b/misc/apache.conf.in -@@ -13,19 +13,21 @@ - Options FollowSymLinks - AllowOverride All - - -- ScriptAlias /cgi-bin/ "@CGI_PREFIX@" -+ # Remember to enable cgi mod (i.e. "a2enmod cgi"). -+ ScriptAlias /cgi-bin "@CGI_PREFIX@" - - Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch - AllowOverride All -+ Require all granted - - - # Use the first option to have Apache logs written to the general log - # directory, or the second to have them written to the regular Apache - # directory (you may have to change the path to that used on your system) - ErrorLog @ZM_LOGDIR@/apache-error.log -- ErrorLog /var/log/httpd/zm-error.log -+# ErrorLog /var/log/httpd/zm-error.log - - # Possible values include: debug, info, notice, warn, error, crit, - # alert, emerg. - LogLevel warn -@@ -33,7 +35,7 @@ - # Use the first option to have Apache logs written to the general log - # directory, or the second to have them written to the regular Apache - # directory (you may have to change the path to that used on your system) - CustomLog @ZM_LOGDIR@/apache-access.log combined -- CustomLog /var/log/httpd/zm-access.log combined -+# CustomLog /var/log/httpd/zm-access.log combined - - diff --git a/distros/ubuntu1504_cmake/patches/series b/distros/ubuntu1504_cmake/patches/series index 4f6f53a23..fc70f4006 100644 --- a/distros/ubuntu1504_cmake/patches/series +++ b/distros/ubuntu1504_cmake/patches/series @@ -1,3 +1,2 @@ -apache2.patch default_cgi-path.patch use_libjs-mootools.patch From 6e3c8bb3800edf526a49d0bc7abcdd3e3cf80981 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 14 Sep 2015 15:15:44 -0400 Subject: [PATCH 030/178] revert --- .../lib/ZoneMinder/ConfigData.pm.in | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 8b42a2274..7fff3d62e 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -357,6 +357,60 @@ our @options = type => $types{boolean}, category => "system", }, + # PP - Google reCaptcha settings + { + name => "ZM_OPT_USE_GOOG_RECAPTCHA", + default => "no", + description => "Add Google reCaptcha to login page", + help => qqq(" + This option allows you to include a google + reCaptcha validation at login. This means in addition to providing + a valid usernane and password, you will also have to + pass the reCaptcha test. Please note that enabling this + option results in the zoneminder login page reach out + to google servers for captcha validation. Also please note + that enabling this option will break 3rd party clients + like zmNinja and zmView as they also need to login to ZoneMinder + and they will fail the reCaptcha test. + "), + requires => [ + {name=>"ZM_OPT_USE_AUTH", value=>"yes"} + ], + type => $types {boolean}, + category => "system", + }, + + { + name => "ZM_OPT_GOOG_RECAPTCHA_SITEKEY", + default => "...Insert your recaptcha site-key here...", + description => "Your recaptcha site-key", + help => qqq("You need to generate your keys from + the Google reCaptcha website. + Please refer to https://www.google.com/recaptcha/ + for more details. + "), + requires => [ + {name=>"ZM_OPT_USE_GOOG_RECAPTCHA", value=>"yes"} + ], + type => $types {string}, + category => "system", + }, + { + name => "ZM_OPT_GOOG_RECAPTCHA_SECRETKEY", + default => "...Insert your recaptcha secret-key here...", + description => "Your recaptcha secret-key", + help => qqq("You need to generate your keys from + the Google reCaptcha website. + Please refer to https://www.google.com/recaptcha/ + for more details. + "), + requires => [ + {name=>"ZM_OPT_USE_GOOG_RECAPTCHA", value=>"yes"} + ], + type => $types {string}, + category => "system", + }, + { name => "ZM_DIR_EVENTS", default => "events", @@ -428,7 +482,7 @@ our @options = }, { name => "ZM_PATH_ZMS", - default => "/zm/cgi-bin/nph-zms", + default => "/cgi-bin/nph-zms", description => "Web path to zms streaming server", help => qqq(" The ZoneMinder streaming server is required to send streamed From d235733290c5afb3733e9cdd15aa9752ee343673 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 14 Sep 2015 15:57:22 -0400 Subject: [PATCH 031/178] Need to include logger if we are going to use Error --- web/includes/config.php.in | 1 + 1 file changed, 1 insertion(+) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index e4ea1b651..3168cee1a 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -167,6 +167,7 @@ function loadConfig( $defineConsts=true ) //print_r( $configCats ); } +require_once( 'logger.php' ); // For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID if ( ! defined('ZM_SERVER_ID') ) { if ( defined('ZM_SERVER_NAME') ) { From b680aa41c5bd3b26af4ee968b05d68351b936588 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Sep 2015 17:26:31 -0400 Subject: [PATCH 032/178] save should be Save --- web/includes/actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 53d9c8a6e..b6d477b04 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -691,7 +691,7 @@ if ( !empty($action) ) { if ( $_REQUEST['object'] == 'server' ) { - if ( $action == "save" ) { + if ( $action == "Save" ) { if ( !empty($_REQUEST['id']) ) $dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) ); else From fb872315d1e836861c4d1349049be488a667ed0d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 08:38:53 -0400 Subject: [PATCH 033/178] add an error log entry for unknown action --- web/includes/actions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/includes/actions.php b/web/includes/actions.php index b6d477b04..b1d79dcc2 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -715,6 +715,8 @@ if ( !empty($action) ) dbQuery( "DELETE FROM Servers WHERE Id=?", array($Id) ); } $refreshParent = true; + } else { + Error( "Unknown action $action in saving Server" ); } } else if ( $action == "version" && isset($_REQUEST['option']) ) From 4fa6948e5c22f93e81fab214c02dc48ba6855ee8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 09:12:21 -0400 Subject: [PATCH 034/178] add form validation for server editing. Currently just requires a name --- web/skins/classic/views/js/server.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 web/skins/classic/views/js/server.js diff --git a/web/skins/classic/views/js/server.js b/web/skins/classic/views/js/server.js new file mode 100644 index 000000000..70063d1de --- /dev/null +++ b/web/skins/classic/views/js/server.js @@ -0,0 +1,14 @@ +function validateForm( form, newServer ) +{ + var errors = new Array(); + if ( !form.elements['newServer[Name]'].value ) + { + errors[errors.length] = "You must supply a name"; + } + if ( errors.length ) + { + alert( errors.join( "\n" ) ); + return( false ); + } + return( true ); +} From 681718e908a0276e96dbd88e205887fbfffd6abb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 11:07:08 -0400 Subject: [PATCH 035/178] init to avoid error message --- web/skins/classic/views/monitor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 369319608..5d0330c53 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -40,6 +40,7 @@ if ( isset($_REQUEST['tab']) ) else $tab = "general"; + $Server = null; if ( defined( 'ZM_SERVER_ID' ) ) { $Server = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( ZM_SERVER_ID ) ); } From 73badd1c2d560eb895371181b86ed92861e3d7b9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 11:12:04 -0400 Subject: [PATCH 036/178] check for value of ZM_SERVER_NAME and ZM_SERVER_HOST and include it in the error message --- web/includes/config.php.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index 3168cee1a..466e195f2 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -170,17 +170,17 @@ function loadConfig( $defineConsts=true ) require_once( 'logger.php' ); // For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID if ( ! defined('ZM_SERVER_ID') ) { - if ( defined('ZM_SERVER_NAME') ) { + if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) { $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME)); if ( ! $server_id ) { - Error("ZM_SERVER_NAME set in config, but not found in Servers table."); + Error("ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in config, but not found in Servers table."); } else { define( 'ZM_SERVER_ID', $server_id ); } - } else if ( defined('ZM_SERVER_HOST') ) { + } else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) { $server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST)); if ( ! $server_id ) { - Error("ZM_SERVER_HOST set in config, but not found in Servers table."); + Error("ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in config, but not found in Servers table."); } else { define( 'ZM_SERVER_ID', $server_id ); } From e172911088816053f343edfd8d63aa3303532e86 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 14:51:05 -0400 Subject: [PATCH 037/178] include Server object and fix Server dropdown --- web/skins/classic/views/monitor.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 5d0330c53..2ec5982ab 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +require_once( 'includes/Server.php'); + if ( !canView( 'Monitors' ) ) { $view = "error"; @@ -647,8 +649,12 @@ switch ( $tab ) 'None'); + $result = dbQuery( 'SELECT * FROM Servers ORDER BY Name'); + $results = $result->fetchALL(PDO::FETCH_CLASS, 'Server' ); + foreach ( $results as $row => $server_obj ) { + $servers[ $server_obj->Id] = $server_obj->Name; + } ?> From 0f181b72d1d0e9c437b3c3a37ff7510e0f10da27 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 14:51:23 -0400 Subject: [PATCH 038/178] include Server object and display the server column --- web/skins/classic/views/console.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 915972d10..37ab27414 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +require_once('includes/Server.php'); + $eventCounts = array( array( "title" => translate('Events'), @@ -235,6 +237,7 @@ else + - + @@ -304,6 +307,7 @@ foreach( $displayMonitors as $monitor ) ?> '.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit( 'Monitors' ) ) ?> + Name() ?> '.$monitor['Device'].' ('.$monitor['Channel'].')', canEdit( 'Monitors' ) ) ?> From a8ba32db649c26e41e9f591aad791768249b358f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 14:51:59 -0400 Subject: [PATCH 039/178] add Server.php to autoconf build --- web/includes/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/web/includes/Makefile.am b/web/includes/Makefile.am index 93fe65380..7943e32d1 100644 --- a/web/includes/Makefile.am +++ b/web/includes/Makefile.am @@ -6,6 +6,7 @@ web_DATA = \ config.php dist_web_DATA = \ + Server.php \ actions.php \ database.php \ functions.php \ From ac5f42efcf5f5971e241f49d0e1dff7a1424e546 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Sep 2015 15:16:07 -0400 Subject: [PATCH 040/178] add a class for Server objects --- web/includes/Server.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 web/includes/Server.php diff --git a/web/includes/Server.php b/web/includes/Server.php new file mode 100644 index 000000000..e49167ed9 --- /dev/null +++ b/web/includes/Server.php @@ -0,0 +1,20 @@ + $v) { + $this->{$k} = $v; + } + } else { + Error("Unable to load Server record for Id=" . $params['Id'] ); + } + } + } + public function Name() { + return $this->{'Name'}; + } +} +?> From 52cdb8a05a31410aab9882c8b9b52caa4bb67bb4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:29:36 -0400 Subject: [PATCH 041/178] add Monitor class --- web/includes/Makefile.am | 1 + web/includes/Monitor.php | 61 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 web/includes/Monitor.php diff --git a/web/includes/Makefile.am b/web/includes/Makefile.am index 7943e32d1..d4a1ece9b 100644 --- a/web/includes/Makefile.am +++ b/web/includes/Makefile.am @@ -6,6 +6,7 @@ web_DATA = \ config.php dist_web_DATA = \ + Monitor.php \ Server.php \ actions.php \ database.php \ diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php new file mode 100644 index 000000000..a3d3ebebb --- /dev/null +++ b/web/includes/Monitor.php @@ -0,0 +1,61 @@ + $v) { + $this->{$k} = $v; + } + } else { + Error("Unable to load Monitor record for Id=" . $id ); + } + } else { + + } + } // end function __construct + public function __call( $fn, array $args){ + if(isset($this->{$fn})){ + return $fn; + #array_unshift($args, $this); + #call_user_func_array( $this->{$fn}, $args); + } + } + public function getStreamSrc( $args, $querySep='&' ) { + if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) { + $Server = new Server( $this->{'ServerId'} ); + $streamSrc = ZM_BASE_PROTOCOL.'://'.$Server->Hostname.ZM_PATH_ZMS; + } else { + $streamSrc = ZM_BASE_URL.ZM_PATH_ZMS; + } + + $args[] = "monitor=".$this->{'Id'}; + + if ( ZM_OPT_USE_AUTH ) { + if ( ZM_AUTH_RELAY == "hashed" ) { + $args[] = "auth=".generateAuthHash( ZM_AUTH_HASH_IPS ); + } elseif ( ZM_AUTH_RELAY == "plain" ) { + $args[] = "user=".$_SESSION['username']; + $args[] = "pass=".$_SESSION['password']; + } elseif ( ZM_AUTH_RELAY == "none" ) { + $args[] = "user=".$_SESSION['username']; + } + } + if ( !in_array( "mode=single", $args ) && !empty($GLOBALS['connkey']) ) { + $args[] = "connkey=".$GLOBALS['connkey']; + } + if ( ZM_RAND_STREAM ) { + $args[] = "rand=".time(); + } + + if ( count($args) ) { + $streamSrc .= "?".join( $querySep, $args ); + } + + return( $streamSrc ); + } // end function etStreamSrc +} +?> From 13327b765194159f0b43f9bc29aa6b0ac40e6f9e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:34:09 -0400 Subject: [PATCH 042/178] Load Controls if appropriate --- web/includes/Monitor.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index a3d3ebebb..9ebe76c3e 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -5,14 +5,20 @@ require_once( 'Server.php' ); class Monitor { public function __construct( $id ) { if ( $id ) { - $s = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $id ) ); - if ( $s ) { - foreach ($s as $k => $v) { - $this->{$k} = $v; + $s = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $id ) ); + if ( $s ) { + foreach ($s as $k => $v) { + $this->{$k} = $v; + } + if ( $this->{'Controllable'} ) { + $s = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $this->{'ControlId'} ) ); + foreach ($s as $k => $v) { + $this->{$k} = $v; + } + } + } else { + Error("Unable to load Monitor record for Id=" . $id ); } - } else { - Error("Unable to load Monitor record for Id=" . $id ); - } } else { } From 01718aaffb88264e08bad536cfe6f5d91ff75842 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:34:26 -0400 Subject: [PATCH 043/178] consturctor just takes an id --- web/includes/Server.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/web/includes/Server.php b/web/includes/Server.php index e49167ed9..ec01ea032 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -1,20 +1,27 @@ $v) { - $this->{$k} = $v; - } - } else { - Error("Unable to load Server record for Id=" . $params['Id'] ); + public function __construct( $id ) { + if ( $id ) { + $s = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( $id ) ); + if ( $s ) { + foreach ($s as $k => $v) { + $this->{$k} = $v; } + } else { + Error("Unable to load Server record for Id=" . $id ); } - } + } else { + $this->{'Name'} = ''; + $this->{'Hostname'} = ''; + } + } + public function Name() { - return $this->{'Name'}; + return $this->{'Name'}; + } + public function Hostname() { + return $this->{'Hostname'}; } } ?> From 4a65ae1d2aff8e5d4e0ecedac943a23ed71dfb46 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:34:48 -0400 Subject: [PATCH 044/178] fix error in display of Server --- web/skins/classic/views/console.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 37ab27414..1a77e76d5 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -307,7 +307,10 @@ foreach( $displayMonitors as $monitor ) ?> '.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit( 'Monitors' ) ) ?> - Name() ?> + Name(); + ?> '.$monitor['Device'].' ('.$monitor['Channel'].')', canEdit( 'Monitors' ) ) ?> From 366c4ec67673758412e422fcf585b7ffb428bbeb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:35:09 -0400 Subject: [PATCH 045/178] monitor array to class --- web/skins/classic/views/js/watch.js.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/skins/classic/views/js/watch.js.php b/web/skins/classic/views/js/watch.js.php index f33983d9f..829beb0e7 100644 --- a/web/skins/classic/views/js/watch.js.php +++ b/web/skins/classic/views/js/watch.js.php @@ -44,9 +44,9 @@ var showMode = "'; var maxDisplayEvents = ; -var monitorId = ; -var monitorWidth = ; -var monitorHeight = ; +var monitorId = Id ?>; +var monitorWidth = Width ?>; +var monitorHeight = Height ?>; var scale = ; @@ -61,11 +61,11 @@ var canStreamNative = ; var canPlayPauseAudio = Browser.ie; - +CanMoveMap ) { ?> var imageControlMode = "moveMap"; - +CanMoveRel ) { ?> var imageControlMode = "movePseudoMap"; - +CanMoveCon ) { ?> var imageControlMode = "moveConMap"; var imageControlMode = null; From c415399043eaf3afc8874ccc82d21bdf9abd757b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:35:27 -0400 Subject: [PATCH 046/178] add Hostname to Server --- web/skins/classic/views/server.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/skins/classic/views/server.php b/web/skins/classic/views/server.php index fa57a7e97..51863e7dc 100644 --- a/web/skins/classic/views/server.php +++ b/web/skins/classic/views/server.php @@ -54,6 +54,10 @@ xhtmlHeaders(__FILE__, translate('Server')." - ".$newServer['Name'] ); + + + +
From aac45e54b87ed279f262cac54eab28b8e909eb2b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 17 Sep 2015 15:35:38 -0400 Subject: [PATCH 047/178] monitor array to class --- web/skins/classic/views/watch.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/web/skins/classic/views/watch.php b/web/skins/classic/views/watch.php index 8a955840f..a93d05c89 100644 --- a/web/skins/classic/views/watch.php +++ b/web/skins/classic/views/watch.php @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +require_once('includes/Monitor.php'); + if ( !canView( 'Stream' ) ) { $view = "error"; @@ -29,50 +31,51 @@ if ( ! visibleMonitor( $_REQUEST['mid'] ) ) { } $sql = 'SELECT C.*, M.* FROM Monitors AS M LEFT JOIN Controls AS C ON (M.ControlId = C.Id ) WHERE M.Id = ?'; -$monitor = dbFetchOne( $sql, NULL, array( $_REQUEST['mid'] ) ); +$monitor = new Monitor( $_REQUEST['mid'] ); +#dbFetchOne( $sql, NULL, array( $_REQUEST['mid'] ) ); if ( isset($_REQUEST['showControls']) ) $showControls = validInt($_REQUEST['showControls']); else - $showControls = (canView( 'Control' ) && ($monitor['DefaultView'] == 'Control')); + $showControls = (canView( 'Control' ) && ($monitor->DefaultView == 'Control')); -$showPtzControls = ( ZM_OPT_CONTROL && $monitor['Controllable'] && canView( 'Control' ) ); +$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable && canView( 'Control' ) ); if ( isset( $_REQUEST['scale'] ) ) $scale = validInt($_REQUEST['scale']); else - $scale = reScale( SCALE_BASE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); + $scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE ); $connkey = generateConnKey(); if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) { $streamMode = "mpeg"; - $streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) ); + $streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) ); } elseif ( canStream() ) { $streamMode = "jpeg"; - $streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor['StreamReplayBuffer'] ) ); + $streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor->StreamReplayBuffer() ) ); } else { $streamMode = "single"; - $streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale ) ); + $streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale ) ); Info( "The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser."); } -$showDvrControls = ( $streamMode == 'jpeg' && $monitor['StreamReplayBuffer'] != 0 ); +$showDvrControls = ( $streamMode == 'jpeg' && $monitor->StreamReplayBuffer() != 0 ); noCacheHeaders(); -xhtmlHeaders( __FILE__, $monitor['Name']." - ".translate('Feed') ); +xhtmlHeaders( __FILE__, $monitor->Name()." - ".translate('Feed') ); ?>