Use JSON encoding for language independent serialisation (filters and control commands) rather than PHP serialisation. Removes dependency on rare PHP::Serialization perl module.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3357 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
8ece56e7b9
commit
7b43ac2645
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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} = '';
|
||||
|
||||
|
|
|
@ -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' );
|
||||
|
|
|
@ -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)) );
|
||||
|
|
|
@ -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']:"";
|
||||
|
|
|
@ -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']:"";
|
||||
|
|
Loading…
Reference in New Issue