diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 611bea059..e14ae8d14 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -236,6 +236,11 @@ sub Sql { || $term->{attr} eq 'Cause' || $term->{attr} eq 'Notes' ) { + if ( $term->{op} eq 'LIKE' + || $term->{op} eq 'NOT LIKE' + ) { + $temp_value = '%'.$temp_value.'%' if $temp_value !~ /%/; + } $value = "'$temp_value'"; } elsif ( $term->{attr} eq 'DateTime' or $term->{attr} eq 'StartDateTime' or $term->{attr} eq 'EndDateTime' ) { if ( $temp_value eq 'NULL' ) { @@ -295,6 +300,10 @@ sub Sql { $self->{Sql} .= ' IN ('.join(',', @value_list).')'; } elsif ( $term->{op} eq '!~' ) { $self->{Sql} .= ' NOT IN ('.join(',', @value_list).')'; + } elsif ( $term->{op} eq 'LIKE' ) { + $self->{Sql} .= " LIKE $value"; + } elsif ( $term->{op} eq 'NOT LIKE' ) { + $self->{Sql} .= " NOT LIKE $value"; } else { $self->{Sql} .= ' '.$term->{op}.' '.$value; } diff --git a/scripts/zmtelemetry.pl.in b/scripts/zmtelemetry.pl.in index 15135e769..efd5e735e 100644 --- a/scripts/zmtelemetry.pl.in +++ b/scripts/zmtelemetry.pl.in @@ -60,7 +60,7 @@ if ( $version ) { if ( $help ) { pod2usage(-exitstatus => -1); } -if ( ! defined $interval ) { +if ( !defined $interval ) { $interval = eval($Config{ZM_TELEMETRY_INTERVAL}); } @@ -69,16 +69,17 @@ if ( !($Config{ZM_TELEMETRY_DATA} or $force) ) { exit(0); } -print 'ZoneMinder Telemetry Agent starting at '.strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n"; +print 'ZoneMinder Telemetry Agent starting at '.strftime('%y/%m/%d %H:%M:%S', localtime())."\n"; my $lastCheck = $Config{ZM_TELEMETRY_LAST_UPLOAD}; while( 1 ) { my $now = time(); my $since_last_check = $now-$lastCheck; - Debug(" Last Check time (now($now) - lastCheck($lastCheck)) = $since_last_check > interval($interval) or force($force)"); + Debug("Last Check time (now($now) - lastCheck($lastCheck)) = $since_last_check > interval($interval) or force($force)"); if ( $since_last_check < 0 ) { - Warning( 'Seconds since last check is negative! Which means that lastCheck is in the future!' ); + Warning('Seconds since last check is negative! Which means that lastCheck is in the future!'); + sleep($interval); next; } if ( ( ($since_last_check) > $interval ) or $force ) { @@ -88,8 +89,8 @@ while( 1 ) { # We should keep *BSD systems in mind when calling system commands my %telemetry; $telemetry{uuid} = getUUID($dbh); - ($telemetry{city}, $telemetry{region}, $telemetry{country}, $telemetry{latitude}, $telemetry{longitude}) = getGeo(); - $telemetry{timestamp} = strftime( '%Y-%m-%dT%H:%M:%S%z', localtime() ); + @telemetry{qw(city region country latitude longitude)} = getGeo(); + $telemetry{timestamp} = strftime('%Y-%m-%dT%H:%M:%S%z', localtime()); $telemetry{monitor_count} = countQuery($dbh,'Monitors'); $telemetry{event_count} = countQuery($dbh,'Events'); $telemetry{architecture} = runSysCmd('uname -p'); @@ -138,6 +139,7 @@ sub runSysCmd { chomp($path); $arguments[0] = $path; my $cmd = join(' ',@arguments); + ($cmd) = $cmd =~ /(.*)/; # detaint $result = qx( $cmd ); chomp($result); } @@ -221,7 +223,7 @@ sub getGeo { } else { Warning("Geoip data retrieval returned HTTP POST error code: $resp_code"); Debug("Geoip data retrieval failure response message: $resp_msg"); - return ($unknown, $unknown, $unknown, $unknown); + return ($unknown, $unknown, $unknown, $unknown, $unknown); } } diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 092b619c3..ccb7a4163 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -23,7 +23,7 @@ protected $defaults = array( 'Channel' => 0, 'Format' => '0', 'V4LMultiBuffer' => null, - 'V4LCapturesPerFrame' => null, + 'V4LCapturesPerFrame' => 1, 'Protocol' => null, 'Method' => '', 'Host' => null, diff --git a/web/includes/actions/monitor.php b/web/includes/actions/monitor.php index 058ae1d8b..424532e4b 100644 --- a/web/includes/actions/monitor.php +++ b/web/includes/actions/monitor.php @@ -78,7 +78,7 @@ if ( $action == 'monitor' ) { $restart = false; if ( count($changes) ) { - if ( $mid ) { + if ( $monitor->Id() ) { # If we change anything that changes the shared mem size, zma can complain. So let's stop first. if ( $monitor->Type() != 'WebSite' ) { @@ -203,6 +203,8 @@ if ( $action == 'monitor' ) { dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) ); //$view = 'none'; $Storage = $monitor->Storage(); + + error_reporting(0); mkdir($Storage->Path().'/'.$mid, 0755); $saferName = basename($_REQUEST['newMonitor']['Name']); symlink($mid, $Storage->Path().'/'.$saferName); diff --git a/web/includes/functions.php b/web/includes/functions.php index 7d8ace272..825467fb4 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1223,6 +1223,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') { case 'Name': case 'Cause': case 'Notes': + if($term['op'] == 'LIKE' || $term['op'] == 'NOT LIKE') { + $value = '%'.$value.'%'; + } $value = dbEscape($value); break; case 'MonitorServerId': @@ -1275,6 +1278,8 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') { case '>' : case '<' : case '<=' : + case 'LIKE' : + case 'NOT LIKE': $filter['sql'] .= ' '.$term['op'].' '. $value; break; case '=~' : diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index b2890a605..d405f5aa0 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -579,6 +579,8 @@ $SLANG = array( 'OpNotMatches' => 'does not match', 'OpIs' => 'is', 'OpIsNot' => 'is not', + 'OpLike' => 'contains', + 'OpNotLike' => 'does not contain', 'OptionalEncoderParam' => 'Optional Encoder Parameters', 'OptionHelp' => 'Option Help', 'OptionRestartWarning' => 'These changes may not come into effect fully\nwhile the system is running. When you have\nfinished making your changes please ensure that\nyou restart ZoneMinder.', diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 67eaf7fc2..425e914c9 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -115,6 +115,8 @@ $opTypes = array( '![]' => translate('OpNotIn'), 'IS' => translate('OpIs'), 'IS NOT' => translate('OpIsNot'), + 'LIKE' => translate('OpLike'), + 'NOT LIKE' => translate('OpNotLike'), ); $archiveTypes = array(