From 81beaf7cd88df4e727f68ed37cf85490f122fed8 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 23 Sep 2002 13:15:11 +0000 Subject: [PATCH] Added zone addition and deletion. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@37 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm.php | 93 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/web/zm.php b/web/zm.php index 8f93c45f1..b20867051 100644 --- a/web/zm.php +++ b/web/zm.php @@ -88,18 +88,30 @@ if ( $action ) if ( !$result ) die( mysql_error() ); } - elseif ( $action == "delete" && $delete_eids ) + elseif ( $action == "delete" ) { - foreach( $delete_eids as $delete_eid ) + if ( $delete_eids ) { - $result = mysql_query( "delete from Frames where EventId = '$delete_eid'" ); - if ( !$result ) - die( mysql_error() ); - $result = mysql_query( "delete from Events where Id = '$delete_eid'" ); - if ( !$result ) - die( mysql_error() ); - if ( $delete_eid ) - system( escapeshellcmd( "rm -rf events/*/".sprintf( "%04d", $delete_eid ) ) ); + foreach( $delete_eids as $delete_eid ) + { + $result = mysql_query( "delete from Frames where EventId = '$delete_eid'" ); + if ( !$result ) + die( mysql_error() ); + $result = mysql_query( "delete from Events where Id = '$delete_eid'" ); + if ( !$result ) + die( mysql_error() ); + if ( $delete_eid ) + system( escapeshellcmd( "rm -rf events/*/".sprintf( "%04d", $delete_eid ) ) ); + } + } + elseif ( $delete_zids ) + { + foreach( $delete_zids as $delete_zid ) + { + $result = mysql_query( "delete from Zones where Id = '$delete_zid'" ); + if ( !$result ) + die( mysql_error() ); + } } } elseif ( $action == "function" && $mid ) @@ -170,10 +182,17 @@ if ( $action ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); - $result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" ); - if ( !$result ) - die( mysql_error() ); - $zone = mysql_fetch_assoc( $result ); + if ( $zid > 0 ) + { + $result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" ); + if ( !$result ) + die( mysql_error() ); + $zone = mysql_fetch_assoc( $result ); + } + else + { + $zone = array(); + } $changes = array(); if ( $new_name != $zone[Name] ) $changes[] = "Name = '$new_name'"; @@ -198,7 +217,15 @@ if ( $action ) if ( count( $changes ) ) { - $sql = "update Zones set ".implode( ", ", $changes )." where MonitorId = '$mid' and Id = '$zid'"; + if ( $zid > 0 ) + { + $sql = "update Zones set ".implode( ", ", $changes )." where MonitorId = '$mid' and Id = '$zid'"; + } + else + { + $sql = "insert into Zones set MonitorId = '$mid', ".implode( ", ", $changes ); + $view = 'none'; + } #echo "$sql"; $result = mysql_query( $sql ); if ( !$result ) @@ -344,7 +371,7 @@ function newWindow(Url,Name,Width,Height) { ?>     - + @@ -942,7 +969,7 @@ function closeWindow() { - + @@ -969,7 +996,7 @@ function closeWindow() { ?> - + @@ -985,14 +1012,26 @@ elseif( $view == "zone" ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); - $result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" ); - if ( !$result ) - die( mysql_error() ); - $zone = mysql_fetch_assoc( $result ); + if ( $zid > 0 ) + { + $result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" ); + if ( !$result ) + die( mysql_error() ); + $zone = mysql_fetch_assoc( $result ); + } + else + { + $zone = array(); + $zone[Name] = "New"; + $zone[LoX] = 0; + $zone[LoY] = 0; + $zone[HiX] = $monitor[Width]-1; + $zone[HiY] = $monitor[Height]-1; + } ?> -ZM - <?php echo $monitor[Name] ?> - Zone <?php echo $zone[Id] ?> +ZM - <?php echo $monitor[Name] ?> - Zone <?php echo $zone[Name] ?>
Id