Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2019-10-17 16:35:34 -04:00
commit c6adf46384
7 changed files with 31 additions and 9 deletions

View File

@ -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;
}

View File

@ -79,6 +79,7 @@ while( 1 ) {
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!');
sleep($interval);
next;
}
if ( ( ($since_last_check) > $interval ) or $force ) {
@ -88,7 +89,7 @@ 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{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');
@ -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);
}
}

View File

@ -23,7 +23,7 @@ protected $defaults = array(
'Channel' => 0,
'Format' => '0',
'V4LMultiBuffer' => null,
'V4LCapturesPerFrame' => null,
'V4LCapturesPerFrame' => 1,
'Protocol' => null,
'Method' => '',
'Host' => null,

View File

@ -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);

View File

@ -1223,6 +1223,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&amp;') {
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='&amp;') {
case '>' :
case '<' :
case '<=' :
case 'LIKE' :
case 'NOT LIKE':
$filter['sql'] .= ' '.$term['op'].' '. $value;
break;
case '=~' :

View File

@ -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.',

View File

@ -115,6 +115,8 @@ $opTypes = array(
'![]' => translate('OpNotIn'),
'IS' => translate('OpIs'),
'IS NOT' => translate('OpIsNot'),
'LIKE' => translate('OpLike'),
'NOT LIKE' => translate('OpNotLike'),
);
$archiveTypes = array(