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

This commit is contained in:
Isaac Connor 2020-05-12 11:20:49 -04:00
commit 1f3cf266a2
6 changed files with 52 additions and 31 deletions

View File

@ -339,6 +339,7 @@ sub profiles {
# #
# use message parser without schema validation ??? # use message parser without schema validation ???
# #
return @profiles;
} # end sub profiles } # end sub profiles

View File

@ -102,7 +102,19 @@ if ( $action eq 'probe' ) {
$client->create_services(); $client->create_services();
if ( $action eq 'profiles' ) { if ( $action eq 'profiles' ) {
ZoneMinder::ONVIF::profiles($client); my @profiles = ZoneMinder::ONVIF::profiles($client);
foreach my $profile ( @profiles ) {
my ( $token, $name, $encoding, $width, $height, $frame_rate_limit, $uri ) = @{$profile};
print join(', ', $token,
$name,
$encoding,
$width,
$height,
$frame_rate_limit,
$uri,
) . "\n";
} # end foreach profile
} elsif( $action eq 'move' ) { } elsif( $action eq 'move' ) {
my $dir = shift; my $dir = shift;
ZoneMinder::ONVIF::move($client, $dir); ZoneMinder::ONVIF::move($client, $dir);

View File

@ -671,8 +671,9 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
if ( db_frame ) { if ( db_frame ) {
static char sql[ZM_SQL_MED_BUFSIZ]; static char sql[ZM_SQL_MED_BUFSIZ];
// The idea is to write out 1/sec
frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score)); frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score));
if ( write_to_db || ( frame_data.size() > 20 ) ) { if ( write_to_db || (frame_data.size() > (int)monitor->get_fps()) ) {
Debug(1, "Adding %d frames to DB", frame_data.size()); Debug(1, "Adding %d frames to DB", frame_data.size());
WriteDbFrames(); WriteDbFrames();
last_db_frame = frames; last_db_frame = frames;

View File

@ -547,6 +547,9 @@ public:
#if HAVE_LIBAVCODEC #if HAVE_LIBAVCODEC
//void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 ); //void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 );
#endif // HAVE_LIBAVCODEC #endif // HAVE_LIBAVCODEC
double get_fps( ) const {
return fps;
}
}; };
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit)) #define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))

View File

@ -246,7 +246,7 @@ function collectData() {
if ( isset($elementData['sql']) ) if ( isset($elementData['sql']) )
$fieldSql[] = $elementData['sql'].' as '.$element; $fieldSql[] = $elementData['sql'].' as '.$element;
else else
$fieldSql[] = '`'.$element.'`'; $fieldSql[] = $element;
if ( isset($elementData['table']) && isset($elementData['join']) ) { if ( isset($elementData['table']) && isset($elementData['join']) ) {
$joinSql[] = 'left join '.$elementData['table'].' on '.$elementData['join']; $joinSql[] = 'left join '.$elementData['table'].' on '.$elementData['join'];
} }
@ -258,14 +258,15 @@ function collectData() {
if ( count($fieldSql) ) { if ( count($fieldSql) ) {
$sql = 'SELECT '.join(', ', $fieldSql).' FROM '.$entitySpec['table']; $sql = 'SELECT '.join(', ', $fieldSql).' FROM '.$entitySpec['table'];
#$sql = 'SELECT '.join(', ', array_map($fieldSql, function($f){return '`'.$f.'`';})).' FROM '.$entitySpec['table'];
if ( $joinSql ) if ( $joinSql )
$sql .= ' '.join(' ', array_unique($joinSql)); $sql .= ' '.join(' ', array_unique($joinSql));
if ( $id && !empty($entitySpec['selector']) ) { if ( $id && !empty($entitySpec['selector']) ) {
$index = 0; $index = 0;
$where = array(); $where = array();
foreach( $entitySpec['selector'] as $selIndex => $selector ) { foreach ( $entitySpec['selector'] as $selIndex => $selector ) {
$selectorParamName = ':selector' . $selIndex; $selectorParamName = ':selector' . $selIndex;
if ( is_array( $selector ) ) { if ( is_array($selector) ) {
$where[] = $selector['selector'].' = '.$selectorParamName; $where[] = $selector['selector'].' = '.$selectorParamName;
$values[$selectorParamName] = validInt($id[$index]); $values[$selectorParamName] = validInt($id[$index]);
} else { } else {
@ -280,15 +281,15 @@ function collectData() {
$sql .= ' GROUP BY '.join(',', array_unique($groupSql)); $sql .= ' GROUP BY '.join(',', array_unique($groupSql));
if ( !empty($_REQUEST['sort']) ) { if ( !empty($_REQUEST['sort']) ) {
$sql .= ' ORDER BY '; $sql .= ' ORDER BY ';
$sort_fields = explode(',',$_REQUEST['sort']); $sort_fields = explode(',', $_REQUEST['sort']);
foreach ( $sort_fields as $sort_field ) { foreach ( $sort_fields as $sort_field ) {
preg_match('/^(\w+)\s*(ASC|DESC)?( NULLS FIRST)?$/i', $sort_field, $matches); preg_match('/^`?(\w+)`?\s*(ASC|DESC)?( NULLS FIRST)?$/i', $sort_field, $matches);
if ( count($matches) ) { if ( count($matches) ) {
if ( in_array($matches[1], $fieldSql) ) { if ( in_array($matches[1], $fieldSql) ) {
$sql .= $matches[1]; $sql .= $matches[1];
} else { } else {
ZM\Error('Sort field ' . $matches[1] . ' not in SQL Fields'); ZM\Error('Sort field '.$matches[1].' from ' .$sort_field.' not in SQL Fields: '.join(',', $sort_field));
} }
if ( count($matches) > 2 ) { if ( count($matches) > 2 ) {
$sql .= ' '.strtoupper($matches[2]); $sql .= ' '.strtoupper($matches[2]);

View File

@ -1,7 +1,7 @@
<?php <?php
namespace ZM; namespace ZM;
require_once( 'config.php' ); require_once('config.php');
class Logger { class Logger {
private static $instance; private static $instance;
@ -70,7 +70,7 @@ class Logger {
$this->terminate(); $this->terminate();
} }
public function initialise( $options=array() ) { public function initialise($options=array()) {
if ( !empty($options['id']) ) if ( !empty($options['id']) )
$this->id = $options['id']; $this->id = $options['id'];
@ -237,31 +237,31 @@ class Logger {
$this->effectiveLevel = $this->level; $this->effectiveLevel = $this->level;
if ( !$this->hasTerm ) { if ( !$this->hasTerm ) {
if ( $lastLevel < self::DEBUG && $this->level >= self::DEBUG ) { if ( $lastLevel < self::DEBUG && $this->level >= self::DEBUG ) {
$this->savedErrorReporting = error_reporting( E_ALL ); $this->savedErrorReporting = error_reporting(E_ALL);
$this->savedDisplayErrors = ini_set( 'display_errors', true ); $this->savedDisplayErrors = ini_set('display_errors', true);
} elseif ( $lastLevel >= self::DEBUG && $this->level < self::DEBUG ) { } elseif ( $lastLevel >= self::DEBUG && $this->level < self::DEBUG ) {
error_reporting( $this->savedErrorReporting ); error_reporting($this->savedErrorReporting);
ini_set( 'display_errors', $this->savedDisplayErrors ); ini_set('display_errors', $this->savedDisplayErrors);
} }
} }
} }
return( $this->level ); return $this->level;
} }
public function debugOn() { public function debugOn() {
return( $this->effectiveLevel >= self::DEBUG ); return( $this->effectiveLevel >= self::DEBUG );
} }
public function termLevel( $termLevel ) { public function termLevel($termLevel) {
if ( isset($termLevel) ) { if ( isset($termLevel) ) {
$termLevel = $this->limit($termLevel); $termLevel = $this->limit($termLevel);
if ( $this->termLevel != $termLevel ) if ( $this->termLevel != $termLevel )
$this->termLevel = $termLevel; $this->termLevel = $termLevel;
} }
return( $this->termLevel ); return $this->termLevel;
} }
public function databaseLevel( $databaseLevel=NULL ) { public function databaseLevel($databaseLevel=NULL) {
if ( !is_null($databaseLevel) ) { if ( !is_null($databaseLevel) ) {
$databaseLevel = $this->limit($databaseLevel); $databaseLevel = $this->limit($databaseLevel);
if ( $this->databaseLevel != $databaseLevel ) { if ( $this->databaseLevel != $databaseLevel ) {
@ -269,7 +269,7 @@ class Logger {
if ( $this->databaseLevel > self::NOLOG ) { if ( $this->databaseLevel > self::NOLOG ) {
if ( (include_once 'database.php') === FALSE ) { if ( (include_once 'database.php') === FALSE ) {
$this->databaseLevel = self::NOLOG; $this->databaseLevel = self::NOLOG;
Warning( 'Unable to write log entries to DB, database.php not found' ); Warning('Unable to write log entries to DB, database.php not found');
} }
} }
} }
@ -277,7 +277,7 @@ class Logger {
return $this->databaseLevel; return $this->databaseLevel;
} }
public function fileLevel( $fileLevel ) { public function fileLevel($fileLevel) {
if ( isset($fileLevel) ) { if ( isset($fileLevel) ) {
$fileLevel = $this->limit($fileLevel); $fileLevel = $this->limit($fileLevel);
if ( $this->fileLevel != $fileLevel ) { if ( $this->fileLevel != $fileLevel ) {
@ -291,14 +291,14 @@ class Logger {
return $this->fileLevel; return $this->fileLevel;
} }
public function weblogLevel( $weblogLevel ) { public function weblogLevel($weblogLevel) {
if ( isset($weblogLevel) ) { if ( isset($weblogLevel) ) {
$weblogLevel = $this->limit($weblogLevel); $weblogLevel = $this->limit($weblogLevel);
if ( $this->weblogLevel != $weblogLevel ) { if ( $this->weblogLevel != $weblogLevel ) {
if ( $weblogLevel > self::NOLOG && $this->weblogLevel <= self::NOLOG ) { if ( $weblogLevel > self::NOLOG && $this->weblogLevel <= self::NOLOG ) {
$this->savedLogErrors = ini_set( 'log_errors', true ); $this->savedLogErrors = ini_set('log_errors', true);
} elseif ( $weblogLevel <= self::NOLOG && $this->weblogLevel > self::NOLOG ) { } elseif ( $weblogLevel <= self::NOLOG && $this->weblogLevel > self::NOLOG ) {
ini_set( 'log_errors', $this->savedLogErrors ); ini_set('log_errors', $this->savedLogErrors);
} }
$this->weblogLevel = $weblogLevel; $this->weblogLevel = $weblogLevel;
} }
@ -306,7 +306,7 @@ class Logger {
return $this->weblogLevel; return $this->weblogLevel;
} }
public function syslogLevel( $syslogLevel ) { public function syslogLevel($syslogLevel) {
if ( isset($syslogLevel) ) { if ( isset($syslogLevel) ) {
$syslogLevel = $this->limit($syslogLevel); $syslogLevel = $this->limit($syslogLevel);
if ( $this->syslogLevel != $syslogLevel ) { if ( $this->syslogLevel != $syslogLevel ) {
@ -353,7 +353,7 @@ class Logger {
fclose($this->logFd); fclose($this->logFd);
} }
public function logPrint( $level, $string, $file=NULL, $line=NULL ) { public function logPrint($level, $string, $file=NULL, $line=NULL) {
if ( $level > $this->effectiveLevel ) { if ( $level > $this->effectiveLevel ) {
return; return;
} }
@ -375,21 +375,21 @@ class Logger {
$rootPath = getcwd(); $rootPath = getcwd();
else else
$rootPath = $_SERVER['DOCUMENT_ROOT']; $rootPath = $_SERVER['DOCUMENT_ROOT'];
$file = preg_replace('/^'.addcslashes($rootPath,'/').'\/?/', '', $file); $file = preg_replace('/^'.addcslashes($rootPath, '/').'\/?/', '', $file);
} }
} }
if ( $this->useErrorLog ) { if ( $this->useErrorLog ) {
$message .= ' at '.$file.' line '.$line; $message .= ' at '.$file.' line '.$line;
} else {
$message = $message;
} }
if ( $level <= $this->termLevel ) { if ( $level <= $this->termLevel ) {
if ( $this->hasTerm ) if ( $this->hasTerm ) {
print($message."\n"); print($message."\n");
else } else {
print(preg_replace("/\n/", '<br/>', htmlspecialchars($message)).'<br/>'); // Didn't we already replace all newlines with spaces above?
print(preg_replace('/\n/', '<br/>', htmlspecialchars($message)).'<br/>');
}
} }
if ( $level <= $this->fileLevel ) { if ( $level <= $this->fileLevel ) {
@ -402,6 +402,9 @@ class Logger {
} }
} else if ( $this->logFd ) { } else if ( $this->logFd ) {
fprintf($this->logFd, $message."\n"); fprintf($this->logFd, $message."\n");
} else {
$this->fileLevel = self::NOLOG;
Error('No logFd but have fileLevel logging!?');
} }
} }