diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 6c98fe702..d4bea8e79 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -508,7 +508,7 @@ insert into Users values ('','admin',password('admin'),'',1,'View','Edit','Edit' -- -- Add a sample filter to purge the oldest 5 events when the disk is 95% full, delete is disabled though -- -insert into Filters values ('PurgeWhenFull','a:4:{s:5:"terms";a:2:{i:0;a:3:{s:3:"val";s:1:"0";s:4:"attr";s:8:"Archived";s:2:"op";s:1:"=";}i:1;a:4:{s:3:"cnj";s:3:"and";s:3:"val";s:2:"95";s:4:"attr";s:11:"DiskPercent";s:2:"op";s:2:">=";}}s:10:"sort_field";s:2:"Id";s:8:"sort_asc";s:1:"1";s:5:"limit";s:1:"5";}',0,0,0,0,0,0,'',1,0); +insert into Filters values ('PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":5,"sort_asc":1}',0,0,0,0,0,0,'',1,0); -- -- Add in some sample control protocol definitions diff --git a/scripts/zmcontrol.pl.in b/scripts/zmcontrol.pl.in index 8a28377e6..49c021627 100644 --- a/scripts/zmcontrol.pl.in +++ b/scripts/zmcontrol.pl.in @@ -45,7 +45,6 @@ use POSIX qw/strftime EPIPE/; use Socket; use Data::Dumper; use Module::Load; -use PHP::Serialization qw(serialize unserialize); use constant MAX_CONNECT_DELAY => 10; use constant MAX_COMMAND_WAIT => 1800; @@ -198,7 +197,7 @@ if ( !$server_up ) next if ( !$message ); - my $params = unserialize( $message ); + my $params = jsonDecode( $message ); #Debug( Dumper( $params ) ); my $command = $params->{command}; @@ -242,7 +241,7 @@ if ( !$server_up ) #print( "Writing commands\n" ); CLIENT->autoflush(); -my $message = serialize( \%options ); +my $message = jsonEncode( \%options ); print( CLIENT $message ); shutdown( CLIENT, 1 ); diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 1b480a3fa..bc6764322 100644 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -52,7 +52,6 @@ use POSIX; use Time::HiRes qw/gettimeofday/; use Date::Manip; use Getopt::Long; -use PHP::Serialization qw(serialize unserialize); use Data::Dumper; use constant EVENT_PATH => (ZM_DIR_EVENTS=~m|/|)?ZM_DIR_EVENTS:(ZM_PATH_WEB.'/'.ZM_DIR_EVENTS); @@ -266,7 +265,7 @@ sub getFilters FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) { Debug( "Found filter '$db_filter->{Name}'\n" ); - my $filter_expr = unserialize( $db_filter->{Query} ); + my $filter_expr = jsonDecode( $db_filter->{Query} ); my $sql = "select E.Id,E.MonitorId,M.Name as MonitorName,M.DefaultRate,M.DefaultScale,E.Name,E.Cause,E.Notes,E.StartTime,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.Videoed,E.Uploaded,E.Emailed,E.Messaged,E.Executed from Events as E inner join Monitors as M on M.Id = E.MonitorId where not isnull(E.EndTime)"; $db_filter->{Sql} = ''; diff --git a/web/ajax/control.php b/web/ajax/control.php index 577a3ca0e..227082f63 100644 --- a/web/ajax/control.php +++ b/web/ajax/control.php @@ -28,7 +28,7 @@ if ( canView( 'Control', $_REQUEST['id'] ) ) $options[$matches[1]] = !empty($matches[2])?$matches[2]:1; } } - $option_string = serialize( $options ); + $option_string = jsonEncode( $options ); if ( !socket_write( $socket, $option_string ) ) ajaxError( "socket_write() failed: ".socket_strerror(socket_last_error()) ); ajaxResponse( 'Used socket' ); diff --git a/web/includes/actions.php b/web/includes/actions.php index 9fc875d96..0ce4ffc7b 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -87,7 +87,7 @@ if ( !empty($action) ) $_REQUEST['filter']['sort_field'] = validStr($_REQUEST['sort_field']); $_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['sort_asc']); $_REQUEST['filter']['limit'] = validInt($_REQUEST['limit']); - $sql = "replace into Filters set Name = '".dbEscape($filterName)."', Query = '".dbEscape(serialize($_REQUEST['filter']))."'"; + $sql = "replace into Filters set Name = '".dbEscape($filterName)."', Query = '".dbEscape(jsonEncode($_REQUEST['filter']))."'"; if ( !empty($_REQUEST['autoArchive']) ) $sql .= ", AutoArchive = '".dbEscape($_REQUEST['autoArchive'])."'"; if ( !empty($_REQUEST['autoVideo']) ) @@ -194,7 +194,7 @@ if ( !empty($action) ) $options[$matches[1]] = $matches[2]?$matches[2]:1; } } - $optionString = serialize( $options ); + $optionString = jsonEncode( $options ); if ( !socket_write( $socket, $optionString ) ) { die( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) ); diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index e89ccc454..21b804353 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -39,7 +39,7 @@ if ( isset($dbFilter) ) { if ( $dbFilter['Background'] ) $backgroundStr = '['.strtolower($SLANG['Background']).']'; - $_REQUEST['filter'] = unserialize( $dbFilter['Query'] ); + $_REQUEST['filter'] = jsonDecode( $dbFilter['Query'] ); $_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:"DateTime"; $_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:"1"; $_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:""; diff --git a/web/skins/mobile/views/events.php b/web/skins/mobile/views/events.php index 99363d868..dbe16b086 100644 --- a/web/skins/mobile/views/events.php +++ b/web/skins/mobile/views/events.php @@ -33,8 +33,7 @@ foreach ( dbFetchAll( $sql ) as $row ) if ( isset($_REQUEST['filterName']) ) { $dbFilter = dbFetchOne( "select * from Filters where Name = '".dbEscape($_REQUEST['filterName'])."'" ); - $_REQUEST['filter'] = unserialize( $dbFilter['Query'] ); - $_REQUEST['filter'] = unserialize( $dbFilter['Query'] ); + $_REQUEST['filter'] = jsonDecode( $dbFilter['Query'] ); $_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:"DateTime"; $_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:"1"; $_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:"";