From 25a0e86afea504efbafbef8bcee96dd324664bb7 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 29 Nov 2002 11:21:37 +0000 Subject: [PATCH] Changed the filter query format from PHP serialize to &= delimited so perl can read it. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@130 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zmactions.php | 8 ++++++- web/zmhtml.php | 60 +++++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/web/zmactions.php b/web/zmactions.php index 25805ac62..8352bc295 100644 --- a/web/zmactions.php +++ b/web/zmactions.php @@ -324,7 +324,13 @@ if ( $action ) $filter_query[$op_name] = $$op_name; $filter_query[$value_name] = $$value_name; } - $filter_query_string = serialize( $filter_query ); + $filter_parms = array(); + while( list( $key, $value ) = each( $filter_query ) ) + { + $filter_parms[] = "$key=$value"; + } + $filter_query_string = join( '&', $filter_parms ); + //$filter_query_string = serialize( $filter_query ); $sql = "replace into Filters set MonitorId = '$mid', Name = '$filter_name', Query = '$filter_query_string', AutoDelete = '$auto_delete'"; #echo "$sql"; $result = mysql_query( $sql ); diff --git a/web/zmhtml.php b/web/zmhtml.php index e4682afba..3e0034dd5 100644 --- a/web/zmhtml.php +++ b/web/zmhtml.php @@ -830,6 +830,40 @@ location.href = '?view=events&mid='Choose Filter' ); + $result = mysql_query( "select * from Filters where MonitorId = '$mid' order by Name" ); + if ( !$result ) + die( mysql_error() ); + while ( $row = mysql_fetch_assoc( $result ) ) + { + $filter_names[$row[Name]] = $row[Name]; + if ( $filter_name == $row[Name] ) + { + $filter_data = $row; + } + } + + if ( $filter_data ) + { + //$filter_query = unserialize( $filter_data[Query] ); + //if ( is_array($filter_query) ) + //{ + //while( list( $key, $value ) = each( $filter_query ) ) + //{ + //$$key = $value; + //} + //} + foreach( split( '&', $filter_data[Query] ) as $filter_parm ) + { + list( $key, $value ) = split( '=', $filter_parm, 2 ); + if ( $key ) + { + $$key = $value; + } + } + } + $conjunction_types = array( 'and'=>'and', 'or'=>'or' ); $obracket_types = array( ''=>'' ); $cbracket_types = array( ''=>'' ); @@ -948,21 +982,6 @@ window.focus(); -'Choose Filter' ); - $result = mysql_query( "select * from Filters where MonitorId = '$mid' order by Name" ); - if ( !$result ) - die( mysql_error() ); - while ( $row = mysql_fetch_assoc( $result ) ) - { - $filter_names[$row[Name]] = $row[Name]; - if ( $filter_name == $row[Name] ) - { - $filter_data = $row; - } - } -?> @@ -979,17 +998,6 @@ window.focus();
Use  filter expressionsUse filter:  1 ) { buildSelect( $select_name, $filter_names, "submitToFilter( filter_form );" ); } else { ?> Save