From a0e1f9cba2a472d171264e8b0b3918f73bee2021 Mon Sep 17 00:00:00 2001 From: stan Date: Sat, 8 Nov 2003 11:52:12 +0000 Subject: [PATCH] Corrected SQL to find active monitors to make sure they are restarted. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@689 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_funcs.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/zm_funcs.php b/web/zm_funcs.php index ed5b74f9c..039674b8e 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -250,23 +250,21 @@ function zmcControl( $monitor, $restart=false ) { if ( $monitor[Type] == "Local" ) { - $sql = "select count(if(Function='Monitor',1,NULL)) as PassiveCount, count(if(Function>'Monitor',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Device = '$monitor[Device]'"; + $sql = "select count(if(Function!='None',1,NULL)) as ActiveCount from Monitors where Device = '$monitor[Device]'"; $zmc_args = "-d $monitor[Device]"; } else { - $sql = "select count(if(Function='Monitor',1,NULL)) as PassiveCount, count(if(Function>'Monitor',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Host = '$monitor[Host]' and Port = '$monitor[Port]' and Path = '$monitor[Path]'"; + $sql = "select count(if(Function!='None',1,NULL)) as ActiveCount from Monitors where Host = '$monitor[Host]' and Port = '$monitor[Port]' and Path = '$monitor[Path]'"; $zmc_args = "-H $monitor[Host] -P $monitor[Port] -p '$monitor[Path]'"; } $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); $row = mysql_fetch_assoc( $result ); - $passive_count = $row[PassiveCount]; $active_count = $row[ActiveCount]; - $x10_count = $row[X10Count]; - if ( !$passive_count && !$active_count && !$x10_count ) + if ( !$active_count ) { daemonControl( "stop", "zmc", $zmc_args ); } @@ -284,12 +282,17 @@ function zmaControl( $monitor, $restart=false ) { if ( !is_array( $monitor ) ) { - $sql = "select Id,Function from Monitors where Id = '$monitor'"; + $sql = "select Id,Function,RunMode from Monitors where Id = '$monitor'"; $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); $monitor = mysql_fetch_assoc( $result ); } + if ( $monitor[RunMode] == 'Triggered' ) + { + // Don't touch anything that's triggered + return; + } switch ( $monitor['Function'] ) { case 'Modect' :