Merge branch 'master' into hide_rtspdescribe

This commit is contained in:
Isaac Connor 2016-05-24 09:32:41 -04:00
commit 5eac0559e2
22 changed files with 314 additions and 152 deletions

View File

@ -17,6 +17,14 @@ Build-Depends: debhelper (>= 9), cmake
, libvlccore-dev, libvlc-dev
, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev
, libgcrypt11-dev, libpolkit-gobject-1-dev
, libphp-serialization-perl
, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, libdbd-mysql-perl
, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl
, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl
, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl
, libdata-dump-perl, libclass-std-fast-perl, libsoap-wsdl-perl, libio-socket-multicast-perl, libdigest-sha-perl
, libsys-cpu-perl, libsys-meminfo-perl
, libdata-uuid-perl
Standards-Version: 3.9.4
Package: zoneminder
@ -32,6 +40,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl
, libdata-dump-perl, libclass-std-fast-perl, libsoap-wsdl-perl, libio-socket-multicast-perl, libdigest-sha-perl
, libsys-cpu-perl, libsys-meminfo-perl
, libdata-uuid-perl
, libpcre3
, libav-tools, libavdevice53
, rsyslog | system-log-daemon

View File

@ -21,6 +21,7 @@ Build-Depends: debhelper (>= 9), python-sphinx | python3-sphinx, apache2-dev, dh
,libphp-serialization-perl
,libsys-mmap-perl [!hurd-any]
,libwww-perl
,libdata-uuid-perl
# Unbundled (dh_linktree):
,libjs-jquery
,libjs-mootools
@ -42,14 +43,15 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,libmodule-load-conditional-perl
,libnet-sftp-foreign-perl
# ,libzoneminder-perl (= ${source:Version})
,libarchive-zip-perl
,libdbd-mysql-perl
,libdevice-serialport-perl
,libimage-info-perl
,libjson-any-perl
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl
,libarchive-zip-perl
,libdbd-mysql-perl
,libdevice-serialport-perl
,libimage-info-perl
,libjson-any-perl
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl
,libdata-uuid-perl
,mysql-client | virtual-mysql-client
,perl-modules
,php5-mysql, php5-gd

View File

@ -25,6 +25,7 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa
,libphp-serialization-perl
,libsys-mmap-perl [!hurd-any]
,libwww-perl
,libdata-uuid-perl
# Unbundled (dh_linktree):
,libjs-jquery
,libjs-mootools
@ -45,20 +46,21 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,libphp-serialization-perl
,libmodule-load-conditional-perl
,libnet-sftp-foreign-perl
,libarchive-zip-perl
,libdbd-mysql-perl
,libdevice-serialport-perl
,libimage-info-perl
,libjson-any-perl
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl
,libdata-dump-perl
,libclass-std-fast-perl
,libsoap-wsdl-perl
,libio-socket-multicast-perl
,libdigest-sha-perl
,libsys-cpu-perl, libsys-meminfo-perl
,libarchive-zip-perl
,libdbd-mysql-perl
,libdevice-serialport-perl
,libimage-info-perl
,libjson-any-perl
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl
,libdata-dump-perl
,libclass-std-fast-perl
,libsoap-wsdl-perl
,libio-socket-multicast-perl
,libdigest-sha-perl
,libsys-cpu-perl, libsys-meminfo-perl
,libdata-uuid-perl
,mysql-client | virtual-mysql-client
,perl-modules
,php5-mysql | php-mysql, php5-gd | php-gd

View File

@ -130,6 +130,28 @@ depend on it.
curl -XDELETE http://server/zm/api/monitors/1.json
Arm/Disarm monitors
^^^^^^^^^^^^^^^^^^^^
This command will force an alarm on Monitor 1:
::
curl http://server/zm/api/monitors/alarm/id:1/command:on.json
This command will disable the alarm on Monitor 1:
::
curl http://server/zm/api/monitors/alarm/id:1/command:off.json
This command will report the status of the alarm Monitor 1:
::
curl http://server/zm/api/monitors/alarm/id:1/command:status.json
Return a list of all events
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -216,6 +238,26 @@ Return a list of events for all monitors within a specified date/time range
curl -XGET "http://server/zm/api/events/index/StartTime%20>=:2015-05-15%2018:43:56/EndTime%20<=:208:43:56.json"
Return event count based on times and conditions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The API also supports a handy mechanism to return a count of events for a period of time.
This returns number of events per monitor that were recorded in the last one hour
::
curl "http://server/zm/api/events/consoleEvents/1%20hour.json"
This returns number of events per monitor that were recorded in the last day where there were atleast 10 frames that were alarms"
::
curl "http://server/zm/api/events/consoleEvents/1%20day.json/AlarmFrames >=: 10.json"
Configuration Apis
^^^^^^^^^^^^^^^^^^^

View File

@ -61,16 +61,19 @@ sub _notify_response
}
sub send_multi() {
my ($self, $address, $port, $data) = @_;
my ($self, $address, $port, $utf8_string) = @_;
my $destination = $address . ':' . $port;
my $socket = IO::Socket::Multicast->new(PROTO => 'udp',
LocalPort=>$port, PeerAddr=>$destination, ReuseAddr=>1)
or die 'Cannot open multicast socket to ' . ${address} . ':' . ${port};
my $bytes = $utf8_string;
utf8::encode($bytes);
$socket->mcast_ttl(1);
$socket->send($data);
$socket->send($bytes);
}
sub receive_multi() {

View File

@ -0,0 +1,55 @@
package WSDiscovery10::Elements::Header;
use strict;
use warnings;
__PACKAGE__->_set_element_form_qualified(0);
sub get_xmlns { 'http://schemas.xmlsoap.org/soap/envelope/' };
our $XML_ATTRIBUTE_CLASS;
undef $XML_ATTRIBUTE_CLASS;
sub __get_attr_class {
return $XML_ATTRIBUTE_CLASS;
}
use Class::Std::Fast::Storable constructor => 'none';
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
Class::Std::initialize();
{ # BLOCK to scope variables
my %Action_of :ATTR(:get<Action>);
my %MessageID_of :ATTR(:get<MessageID>);
my %ReplyTo_of :ATTR(:get<ReplyTo>);
my %To_of :ATTR(:get<To>);
__PACKAGE__->_factory(
[ qw( Action MessageID ReplyTo To ) ],
{
'Action' => \%Action_of,
'MessageID' => \%MessageID_of,
'ReplyTo' => \%ReplyTo_of,
'To' => \%To_of,
},
{
'Action' => 'WSDiscovery10::Elements::Action',
'MessageID' => 'WSDiscovery10::Elements::MessageID',
'ReplyTo' => 'WSDiscovery10::Elements::ReplyTo',
'To' => 'WSDiscovery10::Elements::To',
},
{
'Action' => '',
'MessageID' => '',
'ReplyTo' => '',
'To' => '',
}
);
} # end BLOCK
1;

View File

@ -34,7 +34,11 @@ sub ProbeOp {
},
header => {
'use' => 'literal',
namespace => 'http://schemas.xmlsoap.org/ws/2004/08/addressing',
encodingStyle => '',
parts => [qw( WSDiscovery10::Elements::Header )],
},
headerfault => {

View File

@ -23,7 +23,12 @@ our $typemap_1 = {
'ProbeMatches/ProbeMatch/Types' => 'WSDiscovery10::Types::QNameListType',
'ProbeMatches/ProbeMatch/EndpointReference' => 'WSDiscovery10::Types::EndpointReferenceType',
'ProbeMatches/ProbeMatch/EndpointReference/ReferenceProperties' => 'WSDiscovery10::Types::ReferencePropertiesType',
'ProbeMatches/ProbeMatch/EndpointReference/PortType' => 'WSDiscovery10::Types::AttributedQName'
'ProbeMatches/ProbeMatch/EndpointReference/PortType' => 'WSDiscovery10::Types::AttributedQName',
'MessageID' => '__SKIP__',
'RelatesTo' => '__SKIP__',
'To' => '__SKIP__',
'Action' => '__SKIP__',
'AppSequence' => '__SKIP__',
};
;

View File

@ -7,8 +7,10 @@ __PACKAGE__->_set_element_form_qualified(0);
sub get_xmlns { 'http://schemas.xmlsoap.org/ws/2005/04/discovery' };
our $XML_ATTRIBUTE_CLASS;
undef $XML_ATTRIBUTE_CLASS;
our $XML_ATTRIBUTE_CLASS = 'WSDiscovery10::Types::ProbeType::_ProbeType::XmlAttr';
#our $XML_ATTRIBUTE_CLASS;
#undef $XML_ATTRIBUTE_CLASS;
sub __get_attr_class {
return $XML_ATTRIBUTE_CLASS;
@ -49,11 +51,55 @@ __PACKAGE__->_factory(
} # end BLOCK
package WSDiscovery10::Types::ProbeType::_ProbeType::XmlAttr;
#use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
use Class::Std::Fast::Storable constructor => 'none', cache => 1;
use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
{ # BLOCK to scope variables
my %Attribs_of :ATTR(:get<Attribs>);
sub new
{
my $self = pop @{ Class::Std::Fast::OBJECT_CACHE_REF()->{ $_[0] } };
$self = bless \(my $o = Class::Std::Fast::ID()), $_[0]
if not defined $self;
$self->BUILD(${$self}, $_[1]);
return $self;
}
sub BUILD
{
my ($self, $ident, $arg_ref) = @_;
$Attribs_of{$ident} = $arg_ref;
}
# without this no attributes are serialized
# SOAP::WSDL::XSD::Typelib::CompexType sub serialize_attr()
sub as_bool :BOOLIFY { 1 }
sub serialize()
{
my $ident = ${ $_[0] };
my $option_ref = $_[1];
my $attr_str = "";
foreach my $attr (keys %{$Attribs_of{$ident}})
{
my $value = %{$Attribs_of{$ident}}{$attr};
$attr_str .= " $attr=\"$value\"";
}
return $attr_str;
}
} # end BLOCK
1;

View File

@ -25,13 +25,14 @@
#
use Getopt::Std;
use Data::UUID;
require ONVIF::Client;
require WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort;
require WSDiscovery10::Elements::Header;
require WSDiscovery10::Elements::Types;
require WSDiscovery10::Elements::Scopes;
require WSDiscovery10::Elements::To;
require WSDiscovery::TransportUDP;
@ -169,6 +170,8 @@ sub discover
## try both soap versions
my %services;
my $uuid_gen = Data::UUID->new();
if($verbose) {
print "Probing for SOAP 1.1\n"
}
@ -177,12 +180,18 @@ sub discover
});
$svc_discover->set_soap_version('1.1');
my $uuid = $uuid_gen->create_str();
my $result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::To->new({ value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' })
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
# print $result . "\n";
@ -197,12 +206,22 @@ sub discover
});
$svc_discover->set_soap_version('1.2');
# copies of the same Probe message must have the same MessageID.
# This is not a copy. So we generate a new uuid.
$uuid = $uuid_gen->create_str();
$result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType
xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl',
'xmlns:tds' => 'http://www.onvif.org/ver10/device/wsdl', },
Types => 'dn:NetworkVideoTransmitter tds:Device', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::To->new({ value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' })
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
# print $result . "\n";

View File

@ -81,11 +81,6 @@ our @EXPORT = ( @EXPORT_OK );
our $VERSION = $ZoneMinder::Base::VERSION;
BEGIN {
ZoneMinder::Config::zmConfigLoad();
ZoneMinder::Database::zmDbConnect();
}
1;
__END__

View File

@ -30,7 +30,6 @@ use warnings;
require Exporter;
require ZoneMinder::Base;
require ZoneMinder::Database;
use ZoneMinder::ConfigData qw(:all);
our @ISA = qw(Exporter ZoneMinder::Base);
@ -70,48 +69,39 @@ use constant ZM_CONFIG => "@ZM_CONFIG@"; # Path to the ZoneMinder config file
use Carp;
# Load the config from the database into the symbol table
sub zmConfigLoad {
%Config = ();
BEGIN
{
my $config_file = ZM_CONFIG;
open( my $CONFIG, "<", $config_file )
or croak( "Can't open config file '$config_file': $!" );
foreach my $str ( <$CONFIG> )
{
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*(.*?)\s*$/;
if ( ! $name ) {
print( STDERR "Warning, bad line in $config_file: $str\n" );
next;
} # end if
$name =~ tr/a-z/A-Z/;
$Config{$name} = $value;
}
close( $CONFIG );
my $config_file = ZM_CONFIG;
open( my $CONFIG, "<", $config_file )
or croak( "Can't open config file '$config_file': $!" );
foreach my $str ( <$CONFIG> ) {
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*(.*?)\s*$/;
if ( ! $name ) {
print( STDERR "Warning, bad line in $config_file: $str\n" );
next;
} # end if
$name =~ tr/a-z/A-Z/;
$Config{$name} = $value;
}
close( $CONFIG );
my $dbh = ZoneMinder::Database::zmDbConnect() or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
while( my $config = $sth->fetchrow_hashref() ) {
$Config{$config->{Name}} = $config->{Value};
}
$sth->finish();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$Config{ZM_SERVER_ID} = undef;
$sth = $dbh->prepare_cached( 'SELECT * FROM Servers WHERE Name=?' );
if ( $Config{ZM_SERVER_NAME} ) {
$res = $sth->execute( $Config{ZM_SERVER_NAME} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
} elsif ( $Config{ZM_SERVER_HOST} ) {
$res = $sth->execute( $Config{ZM_SERVER_HOST} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
use DBI;
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$Config{ZM_DB_HOST}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
) or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
while( my $config = $sth->fetchrow_hashref() ) {
$Config{$config->{Name}} = $config->{Value};
}
$sth->finish();
}
#$dbh->disconnect();
}
sub loadConfigFromDB {
@ -228,8 +218,6 @@ sub saveConfigToDB {
$dbh->{AutoCommit} = $ac;
}
1;
__END__
1;
__END__

View File

@ -27,11 +27,9 @@ package ZoneMinder::Database;
use 5.006;
use strict;
use warnings;
use DBI;
require Exporter;
require ZoneMinder::Base;
require ZoneMinder::Config;
our @ISA = qw(Exporter ZoneMinder::Base);
@ -66,6 +64,7 @@ our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);
use Carp;
@ -80,23 +79,23 @@ sub zmDbConnect
}
if ( !defined( $dbh ) )
{
my ( $host, $port ) = ( $ZoneMinder::Config::Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($port) )
{
$dbh = DBI->connect( "DBI:mysql:database=".$ZoneMinder::Config::Config{ZM_DB_NAME}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$host
.";port=".$port
, $ZoneMinder::Config::Config{ZM_DB_USER}
, $ZoneMinder::Config::Config{ZM_DB_PASS}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
}
else
{
$dbh = DBI->connect( "DBI:mysql:database=".$ZoneMinder::Config::Config{ZM_DB_NAME}
.";host=".$ZoneMinder::Config::Config{ZM_DB_HOST}
, $ZoneMinder::Config::Config{ZM_DB_USER}
, $ZoneMinder::Config::Config{ZM_DB_PASS}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$Config{ZM_DB_HOST}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
}
$dbh->trace( 0 );

View File

@ -30,9 +30,6 @@ use warnings;
require Exporter;
require ZoneMinder::Base;
require ZoneMinder::Database;
require ZoneMinder::Config;
our @ISA = qw(Exporter ZoneMinder::Base);
@ -89,6 +86,8 @@ our $VERSION = $ZoneMinder::Base::VERSION;
#
# ==========================================================================
use ZoneMinder::Config qw(:all);
use DBI;
use Carp;
use POSIX;
@ -152,7 +151,7 @@ sub new
$this->{hasTerm} = -t STDERR;
( $this->{fileName} = $0 ) =~ s|^.*/||;
$this->{logPath} = $ZoneMinder::Config::Config{ZM_PATH_LOGS};
$this->{logPath} = $Config{ZM_PATH_LOGS};
$this->{logFile} = $this->{logPath}."/".$this->{id}.".log";
$this->{trace} = 0;
@ -165,7 +164,7 @@ sub BEGIN
{
# Fake the config variables that are used in case they are not defined yet
# Only really necessary to support upgrade from previous version
if ( !eval('defined($ZoneMinder::Config::Config{ZM_LOG_DEBUG})') )
if ( !eval('defined($Config{ZM_LOG_DEBUG})') )
{
no strict 'subs';
no strict 'refs';
@ -223,7 +222,7 @@ sub initialise( @ )
}
else
{
$tempDatabaseLevel = $ZoneMinder::Config::Config{ZM_LOG_LEVEL_DATABASE};
$tempDatabaseLevel = $Config{ZM_LOG_LEVEL_DATABASE};
}
if ( defined($options{fileLevel}) )
{
@ -231,7 +230,7 @@ sub initialise( @ )
}
else
{
$tempFileLevel = $ZoneMinder::Config::Config{ZM_LOG_LEVEL_FILE};
$tempFileLevel = $Config{ZM_LOG_LEVEL_FILE};
}
if ( defined($options{syslogLevel}) )
{
@ -239,7 +238,7 @@ sub initialise( @ )
}
else
{
$tempSyslogLevel = $ZoneMinder::Config::Config{ZM_LOG_LEVEL_SYSLOG};
$tempSyslogLevel = $Config{ZM_LOG_LEVEL_SYSLOG};
}
if ( defined($ENV{'LOG_PRINT'}) )
@ -255,9 +254,9 @@ sub initialise( @ )
$tempFileLevel = $level if ( defined($level = $this->getTargettedEnv('LOG_LEVEL_FILE')) );
$tempSyslogLevel = $level if ( defined($level = $this->getTargettedEnv('LOG_LEVEL_SYSLOG')) );
if ( $ZoneMinder::Config::Config{ZM_LOG_DEBUG} )
if ( $Config{ZM_LOG_DEBUG} )
{
foreach my $target ( split( /\|/, $ZoneMinder::Config::Config{ZM_LOG_DEBUG_TARGET} ) )
foreach my $target ( split( /\|/, $Config{ZM_LOG_DEBUG_TARGET} ) )
{
if ( $target eq $this->{id}
|| $target eq "_".$this->{id}
@ -266,12 +265,12 @@ sub initialise( @ )
|| $target eq ""
)
{
if ( $ZoneMinder::Config::Config{ZM_LOG_DEBUG_LEVEL} > NOLOG )
if ( $Config{ZM_LOG_DEBUG_LEVEL} > NOLOG )
{
$tempLevel = $this->limit( $ZoneMinder::Config::Config{ZM_LOG_DEBUG_LEVEL} );
if ( $ZoneMinder::Config::Config{ZM_LOG_DEBUG_FILE} ne "" )
$tempLevel = $this->limit( $Config{ZM_LOG_DEBUG_LEVEL} );
if ( $Config{ZM_LOG_DEBUG_FILE} ne "" )
{
$tempLogFile = $ZoneMinder::Config::Config{ZM_LOG_DEBUG_FILE};
$tempLogFile = $Config{ZM_LOG_DEBUG_FILE};
$tempFileLevel = $tempLevel;
}
}
@ -461,14 +460,32 @@ sub databaseLevel
{
if ( !$this->{dbh} )
{
$this->{dbh} = ZoneMinder::Database::zmDbConnect();
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($port) )
{
$this->{dbh} = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$host
.";port=".$port
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
}
else
{
$this->{dbh} = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$Config{ZM_DB_HOST}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
}
if ( !$this->{dbh} )
{
$databaseLevel = NOLOG;
Error( "Unable to write log entries to DB, can't connect to database '"
.$ZoneMinder::Config::Config{ZM_DB_NAME}
.$Config{ZM_DB_NAME}
."' on host '"
.$ZoneMinder::Config::Config{ZM_DB_HOST}
.$Config{ZM_DB_HOST}
."'"
);
}
@ -488,8 +505,7 @@ sub databaseLevel
{
if ( $this->{dbh} )
{
# $this->dbh is now the global dbh, so don't close it.
#$this->{dbh}->disconnect();
$this->{dbh}->disconnect();
undef($this->{dbh});
}
}
@ -566,8 +582,8 @@ sub openFile
{
$LOGFILE->autoflush() if ( $this->{autoFlush} );
my $webUid = (getpwnam( $ZoneMinder::Config::Config{ZM_WEB_USER} ))[2];
my $webGid = (getgrnam( $ZoneMinder::Config::Config{ZM_WEB_GROUP} ))[2];
my $webUid = (getpwnam( $Config{ZM_WEB_USER} ))[2];
my $webGid = (getgrnam( $Config{ZM_WEB_GROUP} ))[2];
if ( $> == 0 )
{
chown( $webUid, $webGid, $this->{logFile} )

View File

@ -92,7 +92,7 @@ my @daemons = (
'zmwatch.pl',
'zmupdate.pl',
'zmtrack.pl',
'zmtelemetry.pl',
'zmtelemetry.pl'
);
my $command = shift @ARGV;

View File

@ -71,7 +71,7 @@ if ( $Config{ZM_TELEMETRY_DATA} )
{
print( "Update agent starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
my $lastCheck = $Config{ZM_TELEMETRY_LAST_CHECK};
my $lastCheck = $Config{ZM_TELEMETRY_LAST_UPLOAD};
while( 1 ) {
my $now = time();

View File

@ -67,7 +67,12 @@ use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks
# ==========================================================================
@EXTRA_PERL_LIB@
use ZoneMinder;
use ZoneMinder::Base qw(:all);
use ZoneMinder::Config qw(:all);
use ZoneMinder::Logger qw(:all);
use ZoneMinder::General qw(:all);
use ZoneMinder::Database qw(:all);
use ZoneMinder::ConfigAdmin qw( :functions );
use POSIX;
use DBI;
use Getopt::Long;
@ -364,8 +369,8 @@ if ( $interactive ) {
my $sql = "ALTER TABLE $_ ENGINE = InnoDB";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
$sth->finish();
}
$sth->finish();
$dbh->do(q|SET sql_mode=''|); # Set mode back to default
}
}

View File

@ -123,7 +123,7 @@ private:
} sdes;
// BYE
struct Bye
struct
{
uint32_t srcN[]; // list of sources
// can't express trailing text for reason (what does this mean? it's not even english!)

View File

@ -291,36 +291,6 @@ void StreamBase::openComms()
if ( connkey > 0 )
{
snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", config.path_socks, connkey);
lock_fd = open(sock_path_lock, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR);
if ( lock_fd <= 0 )
{
Error("Unable to open sock lock file %s: %s", sock_path_lock, strerror(errno) );
lock_fd = 0;
}
else if ( flock(lock_fd, LOCK_EX) != 0 )
{
Error("Unable to lock sock lock file %s: %s", sock_path_lock, strerror(errno) );
close(lock_fd);
lock_fd = 0;
}
else
{
Debug( 1, "We have obtained a lock on %s fd: %d", sock_path_lock, lock_fd);
}
sd = socket( AF_UNIX, SOCK_DGRAM, 0 );
if ( sd < 0 )
{
Fatal( "Can't create socket: %s", strerror(errno) );
}
snprintf( loc_sock_path, sizeof(loc_sock_path), "%s/zms-%06ds.sock", config.path_socks, connkey );
unlink( loc_sock_path );
unsigned int length = snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", config.path_socks, connkey);
if ( length >= sizeof(sock_path_lock) ) {
Warning("Socket lock path was truncated.");

View File

@ -103,7 +103,7 @@ public function beforeFilter() {
$this->Monitor->create();
if ($this->Monitor->save($this->request->data)) {
$this->daemonControl($this->Monitor->id, 'start', $this->request->data);
$this->daemonControl($this->Monitor->id, 'start');
return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
}
}

View File

@ -1,10 +1,11 @@
var requestQueue = new Request.Queue( { concurrent: 2 } );
function Monitor( index, id, connKey )
function Monitor( index, monitorData )
{
this.index = index;
this.id = id;
this.connKey = connKey;
this.id = monitorData.id;
this.connKey = monitorData.connKey;
this.server_url = monitorData.server_url;
this.status = null;
this.alarmState = STATE_IDLE;
this.lastAlarmState = STATE_IDLE;
@ -110,7 +111,7 @@ function Monitor( index, id, connKey )
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
}
this.streamCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
}
@ -146,7 +147,7 @@ function initPage()
{
for ( var i = 0; i < monitorData.length; i++ )
{
monitors[i] = new Monitor( i, monitorData[i].id, monitorData[i].connKey );
monitors[i] = new Monitor( i, monitorData[i] );
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
monitors[i].start( delay );
}

View File

@ -35,7 +35,8 @@ monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>,
'connKey': <?php echo $monitor->connKey() ?>,
'width': <?php echo $monitor->Width() ?>,
'height':<?php echo $monitor->Height() ?>
'height':<?php echo $monitor->Height() ?>,
'server_url': '<?php echo $monitor->Server()->Url().$_SERVER['PHP_SELF'] ?>'
};
<?php
}