diff --git a/web/zm.php b/web/zm.php index 1172a421d..713f14a83 100644 --- a/web/zm.php +++ b/web/zm.php @@ -113,6 +113,15 @@ if ( $action ) die( mysql_error() ); } } + elseif ( $delete_mids ) + { + foreach( $delete_mids as $delete_mid ) + { + $result = mysql_query( "delete from Monitors where Id = '$delete_mid'" ); + if ( !$result ) + die( mysql_error() ); + } + } } elseif ( $action == "function" && $mid ) { @@ -129,30 +138,8 @@ if ( $action ) $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); - $sql = "select count(if(Function='Passive',1,NULL)) as PassiveCount, count(if(Function='Active',1,NULL)) as ActiveCount from Monitors where Id = '$mid'"; - $result = mysql_query( $sql ); - if ( !$result ) - echo mysql_error(); - $row = mysql_fetch_assoc( $result ); - $passive_count = $row[PassiveCount]; - $active_count = $row[ActiveCount]; - if ( !$passive_count && !$active_count ) - { - stopDaemon( "zmc", $monitor[Device] ); - } - else - { - startDaemon( "zmc", $monitor[Device] ); - } - if ( !$active_count ) - { - stopDaemon( "zma", $monitor[Device] ); - } - else - { - startDaemon( "zma", $monitor[Device] ); - } + controlDaemons( $monitor[Device] ); $refresh_parent = true; } } @@ -234,6 +221,48 @@ if ( $action ) $refresh_parent = true; } } + elseif ( $action == "monitor" && isset( $mid ) ) + { + if ( $zid > 0 ) + { + $result = mysql_query( "select * from Monitors where Id = '$mid'" ); + if ( !$result ) + die( mysql_error() ); + $monitor = mysql_fetch_assoc( $result ); + } + else + { + $monitor = array(); + } + + $changes = array(); + if ( $new_name != $monitor[Name] ) $changes[] = "Name = '$new_name'"; + if ( $new_function != $monitor['Function'] ) $changes[] = "Function = '$new_function'"; + if ( $new_device != $monitor['Device'] ) $changes[] = "Device = '$new_device'"; + if ( $new_channel != $monitor['Channel'] ) $changes[] = "Channel = '$new_channel'"; + if ( $new_format != $monitor['Format'] ) $changes[] = "Format = '$new_format'"; + if ( $new_width != $monitor['Width'] ) $changes[] = "Width = '$new_width'"; + if ( $new_height != $monitor['Height'] ) $changes[] = "Height = '$new_height'"; + if ( $new_colours != $monitor['Colours'] ) $changes[] = "Colours = '$new_colours'"; + + if ( count( $changes ) ) + { + if ( $mid > 0 ) + { + $sql = "update Monitors set ".implode( ", ", $changes )." where MonitorId = '$mid'"; + } + else + { + $sql = "insert into Monitors set ".implode( ", ", $changes ); + $view = 'none'; + } + $result = mysql_query( $sql ); + if ( !$result ) + die( mysql_error() ); + controlDaemons( $monitor[Device] ); + $refresh_parent = true; + } + } } if ( !$view ) @@ -296,7 +325,7 @@ if ( $view == "console" )