Merge pull request #1040 from ZoneMinder/multi-server

Multi server
This commit is contained in:
Andrew Bauer 2016-01-01 09:36:04 -06:00
commit c827f55580
54 changed files with 1196 additions and 629 deletions

View File

@ -4,7 +4,7 @@
#
cmake_minimum_required (VERSION 2.6)
project (zoneminder)
set(zoneminder_VERSION "1.28.109")
set(zoneminder_VERSION "1.28.110")
# make API version a minor of ZM version
set(zoneminder_API_VERSION "${zoneminder_VERSION}.1")

View File

@ -3,7 +3,7 @@
# For instructions on building with cmake, please see INSTALL
#
AC_PREREQ(2.59)
AC_INIT(zm,1.28.109,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html)
AC_INIT(zm,1.28.110,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR(src/zm.h)
AC_CONFIG_HEADERS(config.h)

View File

@ -269,6 +269,7 @@ DROP TABLE IF EXISTS `Logs`;
CREATE TABLE `Logs` (
`TimeKey` decimal(16,6) NOT NULL,
`Component` varchar(32) NOT NULL,
`ServerId` int(10) unsigned,
`Pid` smallint(6) DEFAULT NULL,
`Level` tinyint(3) NOT NULL,
`Code` char(3) NOT NULL,

21
db/zm_update-1.28.110.sql Normal file
View File

@ -0,0 +1,21 @@
--
-- This updates a 1.28.106 database to 1.28.107
--
--
-- Update Frame table to have a PrimaryKey of ID, insetad of a Composite Primary Key
-- Used primarially for compatibility with CakePHP
--
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Logs'
AND table_schema = DATABASE()
AND column_name = 'ServerId'
) > 0,
"SELECT 'Column ServerId already exists in Logs'",
"ALTER TABLE `Logs` ADD COLUMN `ServerId` int(10) unsigned AFTER Component"
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -1,3 +1,21 @@
zoneminder (1.28.108-nmu2015100101) wheezy; urgency=low
*
-- Isaac Connor <iconnor@connortechnology.com> Thu, 01 Oct 2015 18:20:29 +0000
zoneminder (1.28.107-nmu2015092401) wheezy; urgency=low
*
-- Isaac Connor <iconnor@connortechnology.com> Thu, 24 Sep 2015 14:15:46 +0000
zoneminder (1.28.1+106-nmu2015091001) wheezy; urgency=low
*
-- Isaac Connor <iconnor@connortechnology.com> Thu, 10 Sep 2015 18:03:43 +0000
zoneminder (1.28.0-0.1) wheezy; urgency=low
* Use CMake instead of Autotools to simplify

View File

@ -3,5 +3,6 @@ usr/lib/zoneminder/cgi-bin
usr/share/man
usr/share/perl5/ZoneMinder
usr/share/perl5/ZoneMinder.pm
usr/share/zoneminder
usr/share/zoneminder/db
usr/share/zoneminder/www
etc/zm

View File

@ -4,7 +4,8 @@
[Unit]
Description=ZoneMinder CCTV recording and surveillance system
After=network.target mysql.service
Requires=mysql.service
# Remarked out so that it will start ZM on machines that don't have mysql installed
#Requires=mysql.service
[Service]
#User=www-data

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1 @@
<mxfile type="dropbox" userAgent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0" version="5.2.7.3" editor="www.draw.io"><diagram>7Vvfb+I4F/1rkHYfFpEEQnlsmXZ2pXZUqaPd/fZlZIib+JsQs44pZf76uU6uEydOgELoUgkeELn+fc/JuddO6HnTxetnQZbRAw9o3HMHwWvP+9Rz3SvfhW9l2OSGsTfKDaFgQW5ySsMT+0HROEDrigU0rVSUnMeSLavGOU8SOpcVGxGCr6vVnnlcHXVJQj1iaXiak9i2/sUCGeGyXL+0/05ZGOmRHX+Sl8zI/Hso+CrB8Xqu95x98uIF0X1lC/VuwYeCc+hG/Vq8Tmms/Kh9lHvjrqW0mKSgCU5kRwMHUXgh8QpX+g9P6ANLAirA/rACF//2RMVLdvmFyjUX3+HXV77kMQ83PdePYaibGRT7ofqVd5jKjXZdtniqRnSgeB0xSZ+WZK5K18AVsEVyEWNxKgX/TqfQtwBLAnMB4zOL45op4oL94IkkuiFMUDLA6zpmYQI2yVXPz1AFyeRcFZMzHYQ+U80pkjUzocM+U76gUsA6B1jqISORyB52sC5ZMR5jlchgxFgzmSATw6LnEiD4gRi14OWOLbweSALkW6gF7cYC1qjsBzicoF/nMBBwwXb4ggWBGqYRYQ61n2O+BksE9Sg0MLFR0AguiWRcdeWCA2Fm0AVLQnVdXgHvwKCKVXM9R7ipBgPfn067gdgZDCsYu+MrC+QR3jkmxg7e88dBjJ0YEN+zBO65C7jdgKtRKsAd9xHLHfCimB4Fr2aSARsNINLgJRcy4iFPSHxbWsF7WkGVbwx8aRJcq+BWIgmWO8AXq/6fSrlBGMhKcgVWMcI9z9yt+ml1a8pXIoM6cxzGcElESLHeCAVJLWKr9wWNgQEv1XDa5MmsKayKqFa6wpKzRKZGz4/KYIhyTZUdDMwlKnmPza2dQa31EMO6Hj53A7aqgV2scS/8J+jDjvB/ZfJvZe57Pl7+L7scT/DykQoG01M3ddb4XRnjoYyeIWFGflXia4Sx6g8neOPuQ7ADeKHdYqj+n5DxcjDdX3+xOGNwwJRzkMpp9rG0H0r8qyvnxoOSUJCAAW61IKDNn5iADDoX60SBX3SmM99MsiOyVJNZvEK7ZdRP8tQw7c9WAMEhY9Q0H7Nk72ZpUFhl0zPoyqD1jbYha0GlMfyguxqy4jcHDb8qEOBMO+vTCV7XIWOEzDOo8SS5UBuWCznOkBzDyTuSowjKtnDk+WLAXnTCOI2Vd6HuL183S5Xd/dqUVOYWGNdoaVGsLT9r3oVp6z2Z0fiRpwzBnXEp+QIqxLWCIg+1EtMz5vZyfgJuOTVyTeztZpG9VLabnXALifzfJSswY7OJujbbqOt6o5NnMNrWXQazPyD23tBGyMrwUpi9rNnM+6h2RpJVN1LCaoLY6rad7jB3Vw2M1ba35X12Lj9sUeMdufzOjootoe4o50QXmwJfy8IWWNUZYnGihWac4D4CU5yMkpnusTxwbBKeSTU/9jT1TOFpCmqF8aiUp4nneWBS689Wo+Xd/3eljkuBmN7dnQcf05SHrzJd0ieZW8JePsAl7u0d99Lcp7VTHKXXO4JhQfvd0dBg3aSJdDoEHkM6HWm33YUGDPuBe1Mc/zdlr820afB9K7StZIhIkOm90uyApFERkes4Mp6O+wzUIe2rpyIZkkdhpbPi6oZ5bCfFQ/SviaQ+xznuCHUPPT3bMInuc8cYborwYztwWxjdP2LWRxpO8CzirRGzdcrdR0zd8xsDxGAwnSqpqAeITwTiIkntCGHFA2tTdcywb4hDl13ZUdHpW4opQPc7NHgKXM2U9La+skVrelqkjcdpnb3//3BaN3QgaWtKtTvXuvpIB+8OWqd8gt3B9kf0WrAuWrB/ptq1Bng+hsxCA2wCnyxvdVyk4keWgNGwnjucSgLqIx0sAa1T7l4C7IdDFwk4MwkYTqqvFbyzBOBpzUeWAP/ddjz1kQ7e8bROuXsJsB8CXiTgzCTAr78a+J4SoJ9KNOyIZ3rD+McjVJiSBRXE3nru91Cw6OtCtb2oNl8JJjff5rnTO3mBbTSqbj2KR8AGzTQTO3/crDu+vIB6yncUXa/+jqL99OVkL6DqN5ovL6CeCNyR9Xbx6V5Ahcvy7wR52lH+P8O7/Qk=</diagram></mxfile>

View File

@ -10,3 +10,4 @@ Contents:
debian
fedora
centos
multiserver

View File

@ -0,0 +1,57 @@
Multi-Server Install
====================
It is possible to run multiple ZoneMinder servers and manage them from a single interface. To achieve this each zoneminder server is connected to a single shared database server and shares file storage for event data.
.. image:: images/zm-multiserver.png
Topology Design Notes
---------------------
1. Device symbols represent separate logical functions, not necessarily separate hardware. For example, the Database Server and a ZoneMinder Server, can reside on the same physical hardware.
2. Configure each ZoneMinder Server to use the same, remote Database Server (Green).
3. The Storage Server (Red) represents shared storage, accessible by all ZoneMinder Servers, mounted under each servers events folder.
4. Create at least two networks for best performance. Dedicate a Storage LAN for communication with the Storage and Database Servers. Make use of multipath and jumbo frames if possible. Keep all other traffic off the Storage LAN! Dedicate the second LAN, called the Video LAN in the diagram, for all other traffic.
New installs
------------
1. Follow the normal instructions for your distro for installing ZoneMinder onto all the ZoneMinder servers in the normal fashion. Only a single database will be needed either as standalone, or on one of the ZoneMinder Servers.
2. On each ZoneMinder server, edit zm.conf. Find the ZM_DB_HOST variable and set it to the name or ip address of your Database Server.
3. Copy the file /usr/share/zoneminder/db/zm_create.sql from one of the ZoneMinder Servers to the machine targeted as the Database Server.
4. Install mysql/mariadb server onto the Database Server.
5. It is advised to run "mysql_secure_installation" to help secure the server.
6. Using the password for the root account set during the previous step, create the ZoneMinder database and configure a database account for ZoneMinder to use:
::
mysql -u root -p < zm_create.sql
mysql -u root -p
mysql> grant all on zm.* to 'zmuser'@'%' identified by 'zmpass';
mysql> exit;
mysqladmin -u root -p reload
The database account credentials, zmuser/zmpass, are arbitrary. Set them to anything that suits your environment.
Note that these commands are just an example and might not be secure enough for your environment.
7. If you have chosen to change the ZoneMinder database account credentials to something other than zmuser/zmpass, you must now update zm.conf on each ZoneMinder Server. Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous step.
Additionally, you must also edit /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner on each ZoneMinder Server. Scroll down and change login and password to the values you created in the previous step.
8. All ZoneMinders Servers must share a common events folder. This can be done in any manner supported by the underlying operating system. From the Storage Server, share/export a folder to be used for ZoneMinder events.
9. From each ZoneMinder Server, mount the shared events folder on the Storage Server to the events folder on the local ZoneMinder Server.
NOTE: The location of this folder varies by distro. This folder is often found under "/var/lib/zoneminder/events" for RedHat based distros and "/var/cache/zoneminder/events" for Debain based distros. This folder is NOT a Symbolic Link!
10. Open your browser and point it to the web console on any of the ZoneMinder Servers (they will all be the same). Open Options, click the Servers tab,and populate this screen with all of your ZoneMinder Servers.
11. When creating a new Monitor, remember to select the server the camera will be assigned to from the Server drop down box.

View File

@ -21,6 +21,9 @@ Monitor Tab
Name
The name for your monitor. This should be made up of alphanumeric characters (a-z,A-Z,0-9) and hyphen (-) and underscore(_) only. Whitespace is not allowed.
Server
Multi-Server implementation allows the ability to define multiple ZoneMinder servers sharing a single database. When servers are configured this setting allows you nominate the server for each monitor.
Source Type
This determines whether the camera is a local one attached to a physical video or USB port on your machine, a remote network camera or an image source that is represented by a file (for instance periodically downloaded from a alternate location). Choosing one or the other affects which set of options are shown in the Source tab.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,12 @@
Options - Servers
---------------
.. image:: images/Options_Servers.png
Servers tab is used for setting up multiple ZoneMinder servers sharing the same database and using a shared file share for all event data. To add a new server use the Add Server button. All that is required is a Name for the Server and Hostname.
To delete a server mark that server and click the Delete button.
Please note that all servers must have a functional web UI as the live view must come from the monitor's host server.
On each server, you will have to edit /etc/zm/zm.conf and set either ZM_SERVER_NAME=

View File

@ -102,6 +102,19 @@ BEGIN
}
$sth->finish();
#$dbh->disconnect();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$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};
}
}
}
1;

View File

@ -0,0 +1,161 @@
# ==========================================================================
#
# ZoneMinder Server Module, $Date$, $Revision$
# Copyright (C) 2001-2008 Philip Coombes
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the common definitions and functions used by the rest
# of the ZoneMinder scripts
#
package ZoneMinder::Server;
use 5.006;
use strict;
use warnings;
require Exporter;
require ZoneMinder::Base;
our @ISA = qw(Exporter ZoneMinder::Base);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use ZoneMinder ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = (
'functions' => [ qw(
) ]
);
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
#
# General Utility Functions
#
# ==========================================================================
use ZoneMinder::Config qw(:all);
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Database qw(:all);
use POSIX;
sub new {
my ( $parent, $id, $data ) = @_;
my $self = {};
bless $self, $parent;
if ( ( $$self{Id} = $id ) or $data ) {
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
$self->load( $data );
}
return $self;
} # end sub new
sub load {
my ( $self, $data ) = @_;
my $type = ref $self;
if ( ! $data ) {
#$log->debug("Object::load Loading from db $type");
$data = $ZoneMinder::Database::dbh->selectrow_hashref( 'SELECT * FROM Servers WHERE Id=?', {}, $$self{Id} );
if ( ! $data ) {
if ( $ZoneMinder::Database::dbh->errstr ) {
Error( "Failure to load Server record for $$self{id}: Reason: " . $ZoneMinder::Database::dbh->errstr );
} # end if
} # end if
} # end if ! $data
if ( $data and %$data ) {
@$self{keys %$data} = values %$data;
} # end if
} # end sub load
sub Name {
if ( @_ > 1 ) {
$_[0]{Name} = $_[1];
}
return $_[0]{Name};
} # end sub Name
sub Hostname {
if ( @_ > 1 ) {
$_[0]{Hostname} = $_[1];
}
return $_[0]{Hostname};
} # end sub Hostname
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Server;
blah blah blah
=head1 DESCRIPTION
Stub documentation for ZoneMinder, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head2 EXPORT
None by default.
=head1 SEE ALSO
Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
=head1 AUTHOR
Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2001-2008 Philip Coombes
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.
=cut

View File

@ -349,6 +349,10 @@ sub getFilters
my ( $temp_attr_name ) = $filter_expr->{terms}[$i]->{attr} =~ /^Monitor(.+)$/;
$db_filter->{Sql} .= "M.".$temp_attr_name;
}
elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' )
{
$db_filter->{Sql} .= "M.ServerId";
}
elsif ( $filter_expr->{terms}[$i]->{attr} eq 'DateTime' )
{
$db_filter->{Sql} .= "E.StartTime";
@ -392,6 +396,13 @@ sub getFilters
{
$value = "'$temp_value'";
}
elsif ( $filter_expr->{terms}[$i]->{attr} eq 'ServerId' ) {
if ( $temp_value eq 'ZM_SERVER_ID' ) {
$value = "'$Config{ZM_SERVER_ID}'";
} else {
$value = "'$temp_value'";
}
}
elsif ( $filter_expr->{terms}[$i]->{attr} eq 'Name'
|| $filter_expr->{terms}[$i]->{attr} eq 'Cause'
|| $filter_expr->{terms}[$i]->{attr} eq 'Notes'

View File

@ -121,10 +121,10 @@ my $retval = 0;
if ( $command eq "state" )
{
Info( "Updating DB: $state->{Name}\n" );
my $sql = "select * from Monitors order by Id asc";
my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=? ORDER BY Id ASC' : 'SELECT * FROM Monitors ORDER BY Id ASC';
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute()
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID}: () )
or Fatal( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() )
{
@ -226,10 +226,11 @@ if ( $command =~ /^(?:start|restart)$/ )
zmMemTidy();
runCommand( "zmdc.pl startup" );
my $sql = "select * from Monitors";
Info( "Starting up services for server $Config{ZM_SERVER_ID}\n" );
my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors';
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute()
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
or Fatal( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() )
{

View File

@ -433,11 +433,12 @@ sub loadMonitors
my %new_monitors = ();
my $sql = "SELECT * FROM Monitors
WHERE find_in_set( Function, 'Modect,Mocord,Nodect' )"
WHERE find_in_set( Function, 'Modect,Mocord,Nodect' )".
( $Config{ZM_SERVER_ID} ? 'AND ServerId=?' : '' )
;
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute()
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
or Fatal( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() )
{

View File

@ -74,14 +74,14 @@ sleep( START_DELAY );
my $dbh = zmDbConnect();
my $sql = "select * from Monitors";
my $sql = $Config{ZM_SERVER_ID} ? 'SELECT * FROM Monitors WHERE ServerId=?' : 'SELECT * FROM Monitors';
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
while( 1 )
{
my $now = time();
my $res = $sth->execute()
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
or Fatal( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() )
{

View File

@ -25,6 +25,8 @@
#include <string.h>
#include <errno.h>
#include "zm_utils.h"
void zmLoadConfig()
{
FILE *cfg;
@ -91,17 +93,46 @@ void zmLoadConfig()
staticConfig.DB_PASS = std::string(val_ptr);
else if ( strcasecmp( name_ptr, "ZM_PATH_WEB" ) == 0 )
staticConfig.PATH_WEB = std::string(val_ptr);
else if ( strcasecmp( name_ptr, "ZM_SERVER_HOST" ) == 0 )
staticConfig.SERVER_NAME = std::string(val_ptr);
else if ( strcasecmp( name_ptr, "ZM_SERVER_NAME" ) == 0 )
staticConfig.SERVER_NAME = std::string(val_ptr);
else if ( strcasecmp( name_ptr, "ZM_SERVER_ID" ) == 0 )
staticConfig.SERVER_ID = atoi(val_ptr);
else
{
// We ignore this now as there may be more parameters than the
// c/c++ binaries are bothered about
// Warning( "Invalid parameter '%s' in %s", name_ptr, ZM_CONFIG );
}
}
fclose( cfg);
} // end foreach line of the config
fclose( cfg );
zmDbConnect();
config.Load();
config.Assign();
// Populate the server config entries
if ( ! staticConfig.SERVER_ID ) {
if ( ! staticConfig.SERVER_NAME.empty() ) {
std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() );
if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) {
staticConfig.SERVER_ID = atoi(dbrow[0]);
} else {
Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() );
}
} // end if has SERVER_NAME
} else if ( staticConfig.SERVER_NAME.empty() ) {
std::string sql = stringtf("SELECT Name FROM Servers WHERE Id='%d'", staticConfig.SERVER_ID );
if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) {
staticConfig.SERVER_NAME = std::string(dbrow[0]);
} else {
Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID );
}
}
}
StaticConfig staticConfig;

View File

@ -65,6 +65,8 @@ struct StaticConfig
std::string DB_USER;
std::string DB_PASS;
std::string PATH_WEB;
std::string SERVER_NAME;
unsigned int SERVER_ID;
};
extern StaticConfig staticConfig;

View File

@ -95,7 +95,7 @@ MYSQL_RES * zmDbFetch( const char * query ) {
return result;
} // end MYSQL_RES * zmDbFetch( const char * query );
MYSQL_ROW zmDBFetchOne( const char *query ) {
MYSQL_ROW zmDbFetchOne( const char *query ) {
MYSQL_RES *result = zmDbFetch( query );
int n_rows = mysql_num_rows( result );
if ( n_rows != 1 ) {
@ -104,6 +104,7 @@ MYSQL_ROW zmDBFetchOne( const char *query ) {
}
MYSQL_ROW dbrow = mysql_fetch_row( result );
mysql_free_result( result );
if ( ! dbrow ) {
Error("Error getting row from query %s. Error is %s", query, mysql_error( &dbconn ) );
return NULL;

View File

@ -33,7 +33,7 @@ void zmDbConnect();
void zmDbClose();
MYSQL_RES * zmDbFetch( const char *query );
MYSQL_ROW zmDBFetchOne( const char *query );
MYSQL_ROW zmDbFetchOne( const char *query );
#ifdef __cplusplus
} /* extern "C" */

View File

@ -603,7 +603,8 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
char escapedString[(strlen(syslogStart)*2)+1];
mysql_real_escape_string( &mDbConnection, escapedString, syslogStart, strlen(syslogStart) );
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
if ( mysql_query( &mDbConnection, sql ) )
{
databaseLevel( NOLOG );

View File

@ -269,6 +269,7 @@ bool Monitor::MonitorLink::hasAlarmed()
Monitor::Monitor(
int p_id,
const char *p_name,
const unsigned int p_server_id,
int p_function,
bool p_enabled,
const char *p_linked_monitors,
@ -302,6 +303,7 @@ Monitor::Monitor(
int p_n_zones,
Zone *p_zones[]
) : id( p_id ),
server_id( p_server_id ),
function( (Function)p_function ),
enabled( p_enabled ),
width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ),
@ -2046,25 +2048,20 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors )
#if ZM_HAS_V4L
int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose )
{
static char sql[ZM_SQL_MED_BUFSIZ];
if ( !device[0] )
{
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) );
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'";
if ( device[0] ) {
sql += " AND Device='";
sql += device;
sql += "'";
}
else
{
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device );
}
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
if ( staticConfig.SERVER_ID ) {
Debug( 1, "Server ID %d", staticConfig.SERVER_ID );
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
}
MYSQL_RES *result = mysql_store_result( &dbconn );
if ( !result )
{
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
MYSQL_RES *result = zmDbFetch( sql.c_str() );
if ( !result ) {
Error( "Can't load local monitors: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
int n_monitors = mysql_num_rows( result );
@ -2077,6 +2074,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
int id = atoi(dbrow[col]); col++;
const char *name = dbrow[col]; col++;
unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
const char *linked_monitors = dbrow[col]; col++;
@ -2176,6 +2174,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
monitors[i] = new Monitor(
id,
name,
server_id,
function,
enabled,
linked_monitors,
@ -2229,24 +2228,17 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose )
{
static char sql[ZM_SQL_MED_BUFSIZ];
if ( !protocol )
{
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) );
}
else
{
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path );
}
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'";
if ( staticConfig.SERVER_ID ) {
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
}
MYSQL_RES *result = mysql_store_result( &dbconn );
if ( !result )
{
if ( protocol ) {
sql += stringtf(" AND Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path );
}
MYSQL_RES *result = zmDbFetch( sql.c_str() );
if ( !result ) {
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
@ -2260,6 +2252,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
int id = atoi(dbrow[col]); col++;
std::string name = dbrow[col]; col++;
unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
const char *linked_monitors = dbrow[col]; col++;
@ -2359,6 +2352,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
monitors[i] = new Monitor(
id,
name.c_str(),
server_id,
function,
enabled,
linked_monitors,
@ -2412,22 +2406,16 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose )
{
static char sql[ZM_SQL_MED_BUFSIZ];
if ( !file[0] )
{
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) );
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'";
if ( file[0] ) {
sql += " AND Path='";
sql += file;
sql += "'";
}
else
{
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file );
if ( staticConfig.SERVER_ID ) {
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
}
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
MYSQL_RES *result = mysql_store_result( &dbconn );
MYSQL_RES *result = zmDbFetch( sql.c_str() );
if ( !result )
{
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
@ -2443,6 +2431,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
int id = atoi(dbrow[col]); col++;
const char *name = dbrow[col]; col++;
unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
const char *linked_monitors = dbrow[col]; col++;
@ -2505,6 +2494,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
monitors[i] = new Monitor(
id,
name,
server_id,
function,
enabled,
linked_monitors,
@ -2558,27 +2548,21 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
#if HAVE_LIBAVFORMAT
int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose )
{
static char sql[ZM_SQL_MED_BUFSIZ];
if ( !file[0] )
{
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) );
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'";
if ( file[0] ) {
sql += " AND Path = '";
sql += file;
sql += "'";
}
else
{
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file );
if ( staticConfig.SERVER_ID ) {
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
}
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
MYSQL_RES *result = zmDbFetch( sql.c_str() );
if ( ! result ) {
Error( "Cannot load FfmpegMonitors" );
exit( mysql_errno( &dbconn ) );
}
MYSQL_RES *result = mysql_store_result( &dbconn );
if ( !result )
{
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
int n_monitors = mysql_num_rows( result );
Debug( 1, "Got %d monitors", n_monitors );
delete[] monitors;
@ -2589,6 +2573,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
int id = atoi(dbrow[col]); col++;
const char *name = dbrow[col]; col++;
unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
const char *linked_monitors = dbrow[col]; col++;
@ -2655,6 +2640,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
monitors[i] = new Monitor(
id,
name,
server_id,
function,
enabled,
linked_monitors,
@ -2706,331 +2692,313 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
}
#endif // HAVE_LIBAVFORMAT
Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose )
{
static char sql[ZM_SQL_MED_BUFSIZ];
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", id );
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id );
MYSQL_RES *result = mysql_store_result( &dbconn );
if ( !result )
{
MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() );
if ( ! dbrow ) {
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
}
int n_monitors = mysql_num_rows( result );
Debug( 1, "Got %d monitors", n_monitors );
Monitor *monitor = 0;
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
{
int col = 0;
unsigned int col = 0;
int id = atoi(dbrow[col]); col++;
std::string name = dbrow[col]; col++;
std::string type = dbrow[col]; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
std::string linked_monitors = dbrow[col]; col++;
unsigned int id = atoi(dbrow[col]); col++;
std::string name = dbrow[col]; col++;
unsigned int server_id = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
std::string type = dbrow[col]; col++;
int function = atoi(dbrow[col]); col++;
int enabled = atoi(dbrow[col]); col++;
std::string linked_monitors = dbrow[col]; col++;
std::string device = dbrow[col]; col++;
int channel = atoi(dbrow[col]); col++;
int format = atoi(dbrow[col]); col++;
std::string device = dbrow[col]; col++;
int channel = atoi(dbrow[col]); col++;
int format = atoi(dbrow[col]); col++;
bool v4l_multi_buffer = config.v4l_multi_buffer;
if ( dbrow[col] ) {
if (*dbrow[col] == '0' ) {
v4l_multi_buffer = false;
} else if ( *dbrow[col] == '1' ) {
v4l_multi_buffer = true;
}
bool v4l_multi_buffer = config.v4l_multi_buffer;
if ( dbrow[col] ) {
if (*dbrow[col] == '0' ) {
v4l_multi_buffer = false;
} else if ( *dbrow[col] == '1' ) {
v4l_multi_buffer = true;
}
col++;
}
col++;
int v4l_captures_per_frame = 0;
if ( dbrow[col] ) {
v4l_captures_per_frame = atoi(dbrow[col]);
} else {
v4l_captures_per_frame = config.captures_per_frame;
}
int v4l_captures_per_frame = 0;
if ( dbrow[col] ) {
v4l_captures_per_frame = atoi(dbrow[col]);
} else {
v4l_captures_per_frame = config.captures_per_frame;
}
Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
col++;
col++;
std::string protocol = dbrow[col]; col++;
std::string method = dbrow[col]; col++;
std::string host = dbrow[col]; col++;
std::string port = dbrow[col]; col++;
std::string path = dbrow[col]; col++;
std::string options = dbrow[col]; col++;
std::string user = dbrow[col]; col++;
std::string pass = dbrow[col]; col++;
std::string protocol = dbrow[col]; col++;
std::string method = dbrow[col]; col++;
std::string host = dbrow[col]; col++;
std::string port = dbrow[col]; col++;
std::string path = dbrow[col]; col++;
std::string options = dbrow[col]; col++;
std::string user = dbrow[col]; col++;
std::string pass = dbrow[col]; col++;
int width = atoi(dbrow[col]); col++;
int height = atoi(dbrow[col]); col++;
int colours = atoi(dbrow[col]); col++;
int palette = atoi(dbrow[col]); col++;
Orientation orientation = (Orientation)atoi(dbrow[col]); col++;
unsigned int deinterlacing = atoi(dbrow[col]); col++;
bool rtsp_describe = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
int hue = atoi(dbrow[col]); col++;
int colour = atoi(dbrow[col]); col++;
int width = atoi(dbrow[col]); col++;
int height = atoi(dbrow[col]); col++;
int colours = atoi(dbrow[col]); col++;
int palette = atoi(dbrow[col]); col++;
Orientation orientation = (Orientation)atoi(dbrow[col]); col++;
unsigned int deinterlacing = atoi(dbrow[col]); col++;
bool rtsp_describe = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
int hue = atoi(dbrow[col]); col++;
int colour = atoi(dbrow[col]); col++;
std::string event_prefix = dbrow[col]; col++;
std::string label_format = dbrow[col]; col++;
std::string event_prefix = dbrow[col]; col++;
std::string label_format = dbrow[col]; col++;
int label_x = atoi(dbrow[col]); col++;
int label_y = atoi(dbrow[col]); col++;
int label_size = atoi(dbrow[col]); col++;
int label_x = atoi(dbrow[col]); col++;
int label_y = atoi(dbrow[col]); col++;
int label_size = atoi(dbrow[col]); col++;
int image_buffer_count = atoi(dbrow[col]); col++;
int warmup_count = atoi(dbrow[col]); col++;
int pre_event_count = atoi(dbrow[col]); col++;
int post_event_count = atoi(dbrow[col]); col++;
int stream_replay_buffer = atoi(dbrow[col]); col++;
int alarm_frame_count = atoi(dbrow[col]); col++;
int section_length = atoi(dbrow[col]); col++;
int frame_skip = atoi(dbrow[col]); col++;
int motion_frame_skip = atoi(dbrow[col]); col++;
double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++;
unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0);
int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++;
int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++;
int fps_report_interval = atoi(dbrow[col]); col++;
int ref_blend_perc = atoi(dbrow[col]); col++;
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
int track_motion = atoi(dbrow[col]); col++;
int image_buffer_count = atoi(dbrow[col]); col++;
int warmup_count = atoi(dbrow[col]); col++;
int pre_event_count = atoi(dbrow[col]); col++;
int post_event_count = atoi(dbrow[col]); col++;
int stream_replay_buffer = atoi(dbrow[col]); col++;
int alarm_frame_count = atoi(dbrow[col]); col++;
int section_length = atoi(dbrow[col]); col++;
int frame_skip = atoi(dbrow[col]); col++;
int motion_frame_skip = atoi(dbrow[col]); col++;
double analysis_fps = dbrow[col] ? strtod(dbrow[col], NULL) : 0; col++;
unsigned int analysis_update_delay = strtoul(dbrow[col++], NULL, 0);
int capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++;
int alarm_capture_delay = (dbrow[col]&&atof(dbrow[col])>0.0)?int(DT_PREC_3/atof(dbrow[col])):0; col++;
int fps_report_interval = atoi(dbrow[col]); col++;
int ref_blend_perc = atoi(dbrow[col]); col++;
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
int track_motion = atoi(dbrow[col]); col++;
int signal_check_colour;
if ( dbrow[col][0] == '#' )
signal_check_colour = strtol(dbrow[col]+1,0,16);
else
signal_check_colour = strtol(dbrow[col],0,16);
col++;
bool embed_exif = (*dbrow[col] != '0'); col++;
int signal_check_colour;
if ( dbrow[col][0] == '#' )
signal_check_colour = strtol(dbrow[col]+1,0,16);
else
signal_check_colour = strtol(dbrow[col],0,16);
col++;
bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
int extras = (deinterlacing>>24)&0xff;
int extras = (deinterlacing>>24)&0xff;
Camera *camera = 0;
if ( type == "Local" )
{
#if ZM_HAS_V4L
camera = new LocalCamera(
id,
device.c_str(),
channel,
format,
v4l_multi_buffer,
v4l_captures_per_frame,
method,
cam_width,
cam_height,
colours,
palette,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE,
extras
);
#else // ZM_HAS_V4L
Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id );
#endif // ZM_HAS_V4L
}
else if ( type == "Remote" )
{
if ( protocol == "http" )
{
camera = new RemoteCameraHttp(
id,
method.c_str(),
host.c_str(),
port.c_str(),
path.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
}
else if ( protocol == "rtsp" )
{
#if HAVE_LIBAVFORMAT
camera = new RemoteCameraRtsp(
id,
method.c_str(),
host.c_str(),
port.c_str(),
path.c_str(),
cam_width,
cam_height,
rtsp_describe,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
#endif // HAVE_LIBAVFORMAT
}
else
{
Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
}
}
else if ( type == "File" )
{
camera = new FileCamera(
id,
path.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
}
else if ( type == "Ffmpeg" )
{
#if HAVE_LIBAVFORMAT
camera = new FfmpegCamera(
id,
path.c_str(),
method,
options,
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBAVFORMAT
}
else if (type == "Libvlc")
{
#if HAVE_LIBVLC
camera = new LibvlcCamera(
id,
path.c_str(),
method,
options,
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBVLC
Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id );
#endif // HAVE_LIBVLC
}
else if ( type == "cURL" )
{
#if HAVE_LIBCURL
camera = new cURLCamera(
id,
path.c_str(),
user.c_str(),
pass.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBCURL
Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBCURL
}
else
{
Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id );
}
monitor = new Monitor(
id,
name.c_str(),
function,
enabled,
linked_monitors.c_str(),
camera,
orientation,
deinterlacing,
event_prefix.c_str(),
label_format.c_str(),
Coord( label_x, label_y ),
label_size,
image_buffer_count,
warmup_count,
pre_event_count,
post_event_count,
stream_replay_buffer,
alarm_frame_count,
section_length,
frame_skip,
motion_frame_skip,
analysis_fps,
analysis_update_delay,
capture_delay,
alarm_capture_delay,
fps_report_interval,
ref_blend_perc,
alarm_ref_blend_perc,
track_motion,
signal_check_colour,
embed_exif,
purpose,
0,
0
);
int n_zones = 0;
if ( load_zones )
{
Zone **zones = 0;
n_zones = Zone::Load( monitor, zones );
monitor->AddZones( n_zones, zones );
monitor->AddPrivacyBitmask( zones );
}
Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones );
}
if ( mysql_errno( &dbconn ) )
Camera *camera = 0;
if ( type == "Local" )
{
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );
#if ZM_HAS_V4L
camera = new LocalCamera(
id,
device.c_str(),
channel,
format,
v4l_multi_buffer,
v4l_captures_per_frame,
method,
cam_width,
cam_height,
colours,
palette,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE,
extras
);
#else // ZM_HAS_V4L
Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id );
#endif // ZM_HAS_V4L
}
// Yadda yadda
mysql_free_result( result );
else if ( type == "Remote" )
{
if ( protocol == "http" )
{
camera = new RemoteCameraHttp(
id,
method.c_str(),
host.c_str(),
port.c_str(),
path.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
}
else if ( protocol == "rtsp" )
{
#if HAVE_LIBAVFORMAT
camera = new RemoteCameraRtsp(
id,
method.c_str(),
host.c_str(),
port.c_str(),
path.c_str(),
cam_width,
cam_height,
rtsp_describe,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
#endif // HAVE_LIBAVFORMAT
}
else
{
Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
}
}
else if ( type == "File" )
{
camera = new FileCamera(
id,
path.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
}
else if ( type == "Ffmpeg" )
{
#if HAVE_LIBAVFORMAT
camera = new FfmpegCamera(
id,
path.c_str(),
method,
options,
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBAVFORMAT
}
else if (type == "Libvlc")
{
#if HAVE_LIBVLC
camera = new LibvlcCamera(
id,
path.c_str(),
method,
options,
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBVLC
Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id );
#endif // HAVE_LIBVLC
}
else if ( type == "cURL" )
{
#if HAVE_LIBCURL
camera = new cURLCamera(
id,
path.c_str(),
user.c_str(),
pass.c_str(),
cam_width,
cam_height,
colours,
brightness,
contrast,
hue,
colour,
purpose==CAPTURE
);
#else // HAVE_LIBCURL
Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBCURL
}
else
{
Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id );
}
monitor = new Monitor(
id,
name.c_str(),
server_id,
function,
enabled,
linked_monitors.c_str(),
camera,
orientation,
deinterlacing,
event_prefix.c_str(),
label_format.c_str(),
Coord( label_x, label_y ),
label_size,
image_buffer_count,
warmup_count,
pre_event_count,
post_event_count,
stream_replay_buffer,
alarm_frame_count,
section_length,
frame_skip,
motion_frame_skip,
analysis_fps,
analysis_update_delay,
capture_delay,
alarm_capture_delay,
fps_report_interval,
ref_blend_perc,
alarm_ref_blend_perc,
track_motion,
signal_check_colour,
embed_exif,
purpose,
0,
0
);
int n_zones = 0;
if ( load_zones )
{
Zone **zones = 0;
n_zones = Zone::Load( monitor, zones );
monitor->AddZones( n_zones, zones );
monitor->AddPrivacyBitmask( zones );
}
Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones );
return( monitor );
}
@ -3038,24 +3006,24 @@ int Monitor::Capture()
{
static int FirstCapture = 1;
int captureResult;
int index = image_count%image_buffer_count;
Image* capture_image = image_buffer[index].image;
if ( (deinterlacing & 0xff) == 4) {
if ( FirstCapture != 1 ) {
/* Copy the next image into the shared memory */
capture_image->CopyBuffer(*(next_buffer.image));
}
/* Capture a new next image */
captureResult = camera->Capture(*(next_buffer.image));
if ( FirstCapture ) {
FirstCapture = 0;
return 0;
}
} else {
/* Capture directly into image buffer, avoiding the need to memcpy() */
captureResult = camera->Capture(*capture_image);
@ -3076,18 +3044,18 @@ int Monitor::Capture()
if ( captureResult == 1 )
{
/* Deinterlacing */
if ( (deinterlacing & 0xff) == 1 ) {
capture_image->Deinterlace_Discard();
} else if ( (deinterlacing & 0xff) == 2 ) {
capture_image->Deinterlace_Linear();
} else if ( (deinterlacing & 0xff) == 3 ) {
capture_image->Deinterlace_Blend();
} else if ( (deinterlacing & 0xff) == 4 ) {
capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff );
} else if ( (deinterlacing & 0xff) == 5 ) {
capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff );
}
/* Deinterlacing */
if ( (deinterlacing & 0xff) == 1 ) {
capture_image->Deinterlace_Discard();
} else if ( (deinterlacing & 0xff) == 2 ) {
capture_image->Deinterlace_Linear();
} else if ( (deinterlacing & 0xff) == 3 ) {
capture_image->Deinterlace_Blend();
} else if ( (deinterlacing & 0xff) == 4 ) {
capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff );
} else if ( (deinterlacing & 0xff) == 5 ) {
capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff );
}
if ( orientation != ROTATE_0 )
@ -3120,7 +3088,7 @@ int Monitor::Capture()
if ( capture_image->Size() > camera->ImageSize() )
{
Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() );
Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() );
return( -1 );
}
@ -3499,7 +3467,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z
}
if (zone->CheckExtendAlarmCount()) {
alarm=true;
zone->SetAlarm();
zone->SetAlarm();
} else {
zone->ClearAlarm();
}
@ -4466,7 +4434,7 @@ void MonitorStream::runStream()
}
}
}
if ( swap_path ) free( swap_path );
if ( swap_path ) free( swap_path );
closeComms();
}

View File

@ -211,6 +211,7 @@ protected:
// These are read from the DB and thereafter remain unchanged
unsigned int id;
char name[64];
unsigned int server_id;
Function function; // What the monitor is doing
bool enabled; // Whether the monitor is enabled or asleep
unsigned int width; // Normally the same as the camera, but not if partly rotated
@ -309,7 +310,7 @@ protected:
public:
// OurCheckAlarms seems to be unused. Check it on zm_monitor.cpp for more info.
//bool OurCheckAlarms( Zone *zone, const Image *pImage );
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int label_size, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, unsigned int p_analysis_update_delay, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 );
Monitor( int p_id, const char *p_name, unsigned int p_server_id, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int label_size, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, unsigned int p_analysis_update_delay, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 );
~Monitor();
void AddZones( int p_n_zones, Zone *p_zones[] );
@ -432,7 +433,7 @@ public:
#if HAVE_LIBAVFORMAT
static int LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose );
#endif // HAVE_LIBAVFORMAT
static Monitor *Load( int id, bool load_zones, Purpose purpose );
static Monitor *Load( unsigned int id, bool load_zones, Purpose purpose );
//void writeStreamImage( Image *image, struct timeval *timestamp, int scale, int mag, int x, int y );
//void StreamImages( int scale=100, int maxfps=10, time_t ttl=0, int msq_id=0 );
//void StreamImagesRaw( int scale=100, int maxfps=10, time_t ttl=0 );

View File

@ -1 +1 @@
1.28.109
1.28.110

View File

@ -1,5 +1,6 @@
<?php
require_once( 'includes/control_functions.php' );
require_once( 'includes/Monitor.php' );
// Monitor control actions, require a monitor id and control view permissions for that monitor
if ( empty($_REQUEST['id']) )
@ -7,7 +8,7 @@ if ( empty($_REQUEST['id']) )
if ( canView( 'Control', $_REQUEST['id'] ) )
{
$monitor = dbFetchOne( 'select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = ?', NULL, array($_REQUEST['id']) );
$monitor = new Monitor( $_REQUEST['id'] );
$ctrlCommand = buildControlCommand( $monitor );
@ -17,7 +18,7 @@ if ( canView( 'Control', $_REQUEST['id'] ) )
if ( !$socket )
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );
$sock_file = ZM_PATH_SOCKS.'/zmcontrol-'.$monitor['Id'].'.sock';
$sock_file = ZM_PATH_SOCKS.'/zmcontrol-'.$monitor->Id().'.sock';
if ( @socket_connect( $socket, $sock_file ) )
{
$options = array();
@ -36,7 +37,7 @@ if ( canView( 'Control', $_REQUEST['id'] ) )
}
else
{
$ctrlCommand .= " --id=".$monitor['Id'];
$ctrlCommand .= " --id=".$monitor->Id();
// Can't connect so use script
$ctrlStatus = '';

View File

@ -38,7 +38,7 @@ switch ( $_REQUEST['task'] )
$sortField = isset($_POST['sortField'])?$_POST['sortField']:'TimeKey';
$sortOrder = (isset($_POST['sortOrder']) and $_POST['sortOrder']) == 'asc' ? 'asc':'desc';
$filterFields = array( 'Component', 'Pid', 'Level', 'File', 'Line' );
$filterFields = array( 'Component', 'ServerId', 'Pid', 'Level', 'File', 'Line' );
$total = dbFetchOne( "SELECT count(*) AS Total FROM Logs", 'Total' );
$sql = 'SELECT * FROM Logs';
@ -136,6 +136,13 @@ switch ( $_REQUEST['task'] )
$sortField = isset($_POST['sortField'])?$_POST['sortField']:'TimeKey';
$sortOrder = isset($_POST['sortOrder'])?$_POST['sortOrder']:'asc';
$servers = Server::find_all();
$servers_by_Id = array();
# There is probably a better way to do this.
foreach ( $servers as $server ) {
$servers_by_Id[$server->Id()] = $server;
}
$sql = "select * from Logs";
$where = array();
$values = array();
@ -212,10 +219,20 @@ switch ( $_REQUEST['task'] )
}
case 'tsv' :
{
fprintf( $exportFP, translate('DateTime')."\t".translate('Component')."\t".translate('Pid')."\t".translate('Level')."\t".translate('Message')."\t".translate('File')."\t".translate('Line')."\n" );
# This line doesn't need fprintf, it could use fwrite
fprintf( $exportFP, join( "\t",
translate('DateTime'),
translate('Component'),
translate('Server'),
translate('Pid'),
translate('Level'),
translate('Message'),
translate('File'),
translate('Line')
)."\n" );
foreach ( $logs as $log )
{
fprintf( $exportFP, "%s\t%s\t%d\t%s\t%s\t%s\t%s\n", $log['DateTime'], $log['Component'], $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
fprintf( $exportFP, "%s\t%s\t%s\t%d\t%s\t%s\t%s\t%s\n", $log['DateTime'], $log['Component'], $servers_by_Id[$log['ServerId']]->Name(),$log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
}
break;
}
@ -265,7 +282,7 @@ tr.log-dbg td {
<p>'.count($logs).' '.translate('Logs').'</p>
<table>
<tbody>
<tr><th>'.translate('DateTime').'</th><th>'.translate('Component').'</th><th>'.translate('Pid').'</th><th>'.translate('Level').'</th><th>'.translate('Message').'</th><th>'.translate('File').'</th><th>'.translate('Line').'</th></tr>
<tr><th>'.translate('DateTime').'</th><th>'.translate('Component').'</th><th>'.translate('Server').'</th><th>'.translate('Pid').'</th><th>'.translate('Level').'</th><th>'.translate('Message').'</th><th>'.translate('File').'</th><th>'.translate('Line').'</th></tr>
' );
foreach ( $logs as $log )
{
@ -275,7 +292,7 @@ tr.log-dbg td {
elseif ( $classLevel > Logger::DEBUG )
$classLevel = Logger::DEBUG;
$logClass = 'log-'.strtolower(Logger::$codes[$classLevel]);
fprintf( $exportFP, " <tr class=\"%s\"><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $logClass, $log['DateTime'], $log['Component'], $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
fprintf( $exportFP, " <tr class=\"%s\"><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $logClass, $log['DateTime'], $log['Component'], $servers_by_Id[$log['ServerId']]->Name(), $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
}
fwrite( $exportFP,
' </tbody>
@ -298,7 +315,7 @@ tr.log-dbg td {
</filter>' );
fwrite( $exportFP,
' <columns>
<column field="datetime">'.translate('DateTime').'</column><column field="component">'.translate('Component').'</column><column field="pid">'.translate('Pid').'</column><column field="level">'.translate('Level').'</column><column field="message">'.translate('Message').'</column><column field="file">'.translate('File').'</column><column field="line">'.translate('Line').'</column>
<column field="datetime">'.translate('DateTime').'</column><column field="component">'.translate('Component').'</column><column field="'.translate('Server').'</column><column field="pid">'.translate('Pid').'</column><column field="level">'.translate('Level').'</column><column field="message">'.translate('Message').'</column><column field="file">'.translate('File').'</column><column field="line">'.translate('Line').'</column>
</columns>
<logs count="'.count($logs).'">
' );
@ -308,12 +325,13 @@ tr.log-dbg td {
" <log>
<datetime>%s</datetime>
<component>%s</component>
<server>%s</server>
<pid>%d</pid>
<level>%s</level>
<message><![CDATA[%s]]></message>
<file>%s</file>
<line>%d</line>
</log>\n", $log['DateTime'], $log['Component'], $log['Pid'], $log['Code'], utf8_decode( $log['Message'] ), $log['File'], $log['Line'] );
</log>\n", $log['DateTime'], $log['Component'], $log['Server'], $log['Pid'], $log['Code'], utf8_decode( $log['Message'] ), $log['File'], $log['Line'] );
}
fwrite( $exportFP,
' </logs>

View File

@ -6,6 +6,8 @@ web_DATA = \
config.php
dist_web_DATA = \
Monitor.php \
Server.php \
actions.php \
database.php \
functions.php \

84
web/includes/Monitor.php Normal file
View File

@ -0,0 +1,84 @@
<?php
require_once( 'database.php' );
require_once( 'Server.php' );
class Monitor {
public function __construct( $IdOrRow ) {
$row = NULL;
if ( $IdOrRow ) {
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) );
if ( ! $row ) {
Error("Unable to load Server record for Id=" . $IdOrRow );
}
} elseif ( is_array( $IdOrRow ) ) {
$row = $IdOrRow;
} else {
Error("Unknown argument passed to Monitor Constructor ($IdOrRow)");
return;
}
} # end if isset($IdOrRow)
if ( $row ) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
if ( $this->{'Controllable'} ) {
$s = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $this->{'ControlId'} ) );
foreach ($s as $k => $v) {
if ( $k == 'Id' ) {
continue;
}
$this->{$k} = $v;
}
}
} else {
Error("No row for Monitor " . $IdOrRow );
}
} // end function __construct
public function Server() {
return new Server( $this->{'ServerId'} );
}
public function __call( $fn, array $args){
if(isset($this->{$fn})){
return $this->{$fn};
#array_unshift($args, $this);
#call_user_func_array( $this->{$fn}, $args);
}
}
public function getStreamSrc( $args, $querySep='&amp;' ) {
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
$Server = new Server( $this->{'ServerId'} );
$streamSrc = ZM_BASE_PROTOCOL.'://'.$Server->Hostname().ZM_PATH_ZMS;
} else {
$streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;
}
$args[] = "monitor=".$this->{'Id'};
if ( ZM_OPT_USE_AUTH ) {
if ( ZM_AUTH_RELAY == "hashed" ) {
$args[] = "auth=".generateAuthHash( ZM_AUTH_HASH_IPS );
} elseif ( ZM_AUTH_RELAY == "plain" ) {
$args[] = "user=".$_SESSION['username'];
$args[] = "pass=".$_SESSION['password'];
} elseif ( ZM_AUTH_RELAY == "none" ) {
$args[] = "user=".$_SESSION['username'];
}
}
if ( !in_array( "mode=single", $args ) && !empty($GLOBALS['connkey']) ) {
$args[] = "connkey=".$GLOBALS['connkey'];
}
if ( ZM_RAND_STREAM ) {
$args[] = "rand=".time();
}
if ( count($args) ) {
$streamSrc .= "?".join( $querySep, $args );
}
return( $streamSrc );
} // end function etStreamSrc
}
?>

53
web/includes/Server.php Normal file
View File

@ -0,0 +1,53 @@
<?php
require_once( 'database.php' );
class Server {
public function __construct( $IdOrRow = NULL ) {
$row = NULL;
if ( $IdOrRow ) {
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
$row = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( $IdOrRow ) );
if ( ! $row ) {
Error("Unable to load Server record for Id=" . $IdOrRow );
}
} elseif ( is_array( $IdOrRow ) ) {
$row = $IdOrRow;
}
} # end if isset($IdOrRow)
if ( $row ) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
} else {
$this->{'Name'} = '';
$this->{'Hostname'} = '';
}
}
public static function find_all() {
$servers = array();
$result = dbQuery( 'SELECT * FROM Servers ORDER BY Name');
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' );
foreach ( $results as $row => $server_obj ) {
$servers[] = $server_obj;
}
return $servers;
}
public function Url() {
return ZM_BASE_PROTOCOL . '://'. $this->Hostname();
}
public function Hostname() {
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
return $this->{'Hostname'};
}
return $this->{'Name'};
}
public function __call( $fn, array $args= NULL){
if(isset($this->{$fn})){
return $this->{$fn};
#array_unshift($args, $this);
#call_user_func_array( $this->{$fn}, $args);
}
}
}
?>

View File

@ -246,13 +246,14 @@ if ( !empty($action) )
if ( !empty($_REQUEST['mid']) && canView( 'Control', $_REQUEST['mid'] ) )
{
require_once( 'control_functions.php' );
require_once( 'Monitor.php' );
$mid = validInt($_REQUEST['mid']);
if ( $action == "control" )
{
$monitor = dbFetchOne( "select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id) where M.Id = ?", NULL, array($mid) );
$monitor = new Monitor( $mid );
$ctrlCommand = buildControlCommand( $monitor );
sendControlCommand( $monitor['Id'], $ctrlCommand );
sendControlCommand( $monitor->Id(), $ctrlCommand );
}
elseif ( $action == "settings" )
{
@ -768,7 +769,7 @@ if ( !empty($action) )
{
if ( isset( $_REQUEST['object'] ) and ( $_REQUEST['object'] == 'server' ) ) {
if ( $action == "save" ) {
if ( $action == "Save" ) {
if ( !empty($_REQUEST['id']) )
$dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) );
else
@ -792,6 +793,8 @@ if ( !empty($action) )
dbQuery( "DELETE FROM Servers WHERE Id=?", array($Id) );
}
$refreshParent = true;
} else {
Error( "Unknown action $action in saving Server" );
}
} else if ( $action == "version" && isset($_REQUEST['option']) )

View File

@ -167,4 +167,25 @@ function loadConfig( $defineConsts=true )
//print_r( $configCats );
}
require_once( 'logger.php' );
// For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID
if ( ! defined('ZM_SERVER_ID') ) {
if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME));
if ( ! $server_id ) {
Error("ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in config, but not found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
} else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST));
if ( ! $server_id ) {
Error("ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in config, but not found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
}
}
?>

View File

@ -20,9 +20,9 @@ function buildControlCommand( $monitor )
case 'focus' :
{
$factor = $_REQUEST['yge']/100;
if ( $monitor['HasFocusSpeed'] )
if ( $monitor->HasFocusSpeed() )
{
$speed = intval(round($monitor['MinFocusSpeed']+(($monitor['MaxFocusSpeed']-$monitor['MinFocusSpeed'])*$factor)));
$speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -30,15 +30,15 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinFocusStep']+(($monitor['MaxFocusStep']-$monitor['MinFocusStep'])*$factor)));
$step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowSpeed = intval(round($monitor['MinFocusSpeed']+(($monitor['MaxFocusSpeed']-$monitor['MinFocusSpeed'])*$slow)));
$slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow)));
if ( $speed < $slowSpeed )
{
$ctrlCommand .= " --autostop";
@ -52,9 +52,9 @@ function buildControlCommand( $monitor )
case 'zoom' :
{
$factor = $_REQUEST['yge']/100;
if ( $monitor['HasZoomSpeed'] )
if ( $monitor->HasZoomSpeed() )
{
$speed = intval(round($monitor['MinZoomSpeed']+(($monitor['MaxZoomSpeed']-$monitor['MinZoomSpeed'])*$factor)));
$speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -62,15 +62,15 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinZoomStep']+(($monitor['MaxZoomStep']-$monitor['MinZoomStep'])*$factor)));
$step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowSpeed = intval(round($monitor['MinZoomSpeed']+(($monitor['MaxZoomSpeed']-$monitor['MinZoomSpeed'])*$slow)));
$slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow)));
if ( $speed < $slowSpeed )
{
$ctrlCommand .= " --autostop";
@ -84,9 +84,9 @@ function buildControlCommand( $monitor )
case 'iris' :
{
$factor = $_REQUEST['yge']/100;
if ( $monitor['HasIrisSpeed'] )
if ( $monitor->HasIrisSpeed() )
{
$speed = intval(round($monitor['MinIrisSpeed']+(($monitor['MaxIrisSpeed']-$monitor['MinIrisSpeed'])*$factor)));
$speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -94,7 +94,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinIrisStep']+(($monitor['MaxIrisStep']-$monitor['MinIrisStep'])*$factor)));
$step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -104,9 +104,9 @@ function buildControlCommand( $monitor )
case 'white' :
{
$factor = $_REQUEST['yge']/100;
if ( $monitor['HasWhiteSpeed'] )
if ( $monitor->HasWhiteSpeed() )
{
$speed = intval(round($monitor['MinWhiteSpeed']+(($monitor['MaxWhiteSpeed']-$monitor['MinWhiteSpeed'])*$factor)));
$speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -114,7 +114,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinWhiteStep']+(($monitor['MaxWhiteStep']-$monitor['MinWhiteStep'])*$factor)));
$step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -124,9 +124,9 @@ function buildControlCommand( $monitor )
case 'gain' :
{
$factor = $_REQUEST['yge']/100;
if ( $monitor['HasGainSpeed'] )
if ( $monitor->HasGainSpeed() )
{
$speed = intval(round($monitor['MinGainSpeed']+(($monitor['MaxGainSpeed']-$monitor['MinGainSpeed'])*$factor)));
$speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -134,7 +134,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinGainStep']+(($monitor['MaxGainStep']-$monitor['MinGainStep'])*$factor)));
$step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -146,7 +146,7 @@ function buildControlCommand( $monitor )
$xFactor = empty($_REQUEST['xge'])?0:$_REQUEST['xge']/100;
$yFactor = empty($_REQUEST['yge'])?0:$_REQUEST['yge']/100;
if ( $monitor['Orientation'] != '0' )
if ( $monitor->Orientation() != '0' )
{
$conversions = array(
'90' => array(
@ -200,48 +200,48 @@ function buildControlCommand( $monitor )
'DownRight' => 'UpRight',
),
);
$new_dirn = $conversions[$monitor['Orientation']][$dirn];
$new_dirn = $conversions[$monitor->Orientation()][$dirn];
$_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] );
$dirn = $new_dirn;
}
if ( $monitor['HasPanSpeed'] && $xFactor )
if ( $monitor->HasPanSpeed() && $xFactor )
{
if ( $monitor['HasTurboPan'] )
if ( $monitor->HasTurboPan() )
{
if ( $xFactor >= $turbo )
{
$panSpeed = $monitor['TurboPanSpeed'];
$panSpeed = $monitor->TurboPanSpeed();
}
else
{
$xFactor = $xFactor/$turbo;
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
else
{
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
$ctrlCommand .= " --panspeed=".$panSpeed;
}
if ( $monitor['HasTiltSpeed'] && $yFactor )
if ( $monitor->HasTiltSpeed() && $yFactor )
{
if ( $monitor['HasTurboTilt'] )
if ( $monitor->HasTurboTilt() )
{
if ( $yFactor >= $turbo )
{
$tiltSpeed = $monitor['TurboTiltSpeed'];
$tiltSpeed = $monitor->TurboTiltSpeed();
}
else
{
$yFactor = $yFactor/$turbo;
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
else
{
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
$ctrlCommand .= " --tiltspeed=".$tiltSpeed;
}
@ -252,22 +252,22 @@ function buildControlCommand( $monitor )
{
if ( preg_match( '/(Left|Right)$/', $dirn ) )
{
$panStep = intval(round($monitor['MinPanStep']+(($monitor['MaxPanStep']-$monitor['MinPanStep'])*$xFactor)));
$panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor)));
$ctrlCommand .= " --panstep=".$panStep;
}
if ( preg_match( '/^(Up|Down)/', $dirn ) )
{
$tiltStep = intval(round($monitor['MinTiltStep']+(($monitor['MaxTiltStep']-$monitor['MinTiltStep'])*$yFactor)));
$tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor)));
$ctrlCommand .= " --tiltstep=".$tiltStep;
}
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowPanSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$slow)));
$slowTiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$slow)));
$slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow)));
$slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow)));
if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) )
{
$ctrlCommand .= " --autostop";
@ -286,22 +286,22 @@ function buildControlCommand( $monitor )
{
$x = deScale( $_REQUEST['x'], $_REQUEST['scale'] );
$y = deScale( $_REQUEST['y'], $_REQUEST['scale'] );
switch ( $monitor['Orientation'] )
switch ( $monitor->Orientation() )
{
case '0' :
case '180' :
case 'hori' :
case 'vert' :
$width = $monitor['Width'];
$height = $monitor['Height'];
$width = $monitor->Width();
$height = $monitor->Height();
break;
case '90' :
case '270' :
$width = $monitor['Height'];
$height = $monitor['Width'];
$width = $monitor->Height();
$height = $monitor->Width();
break;
}
switch ( $monitor['Orientation'] )
switch ( $monitor->Orientation() )
{
case '90' :
$tempY = $y;
@ -332,12 +332,12 @@ function buildControlCommand( $monitor )
$x = deScale( $_REQUEST['x'], $_REQUEST['scale'] );
$y = deScale( $_REQUEST['y'], $_REQUEST['scale'] );
$halfWidth = $monitor['Width'] / 2;
$halfHeight = $monitor['Height'] / 2;
$halfWidth = $monitor->Width() / 2;
$halfHeight = $monitor->Height() / 2;
$xFactor = ($x - $halfWidth)/$halfWidth;
$yFactor = ($y - $halfHeight)/$halfHeight;
switch ( $monitor['Orientation'] )
switch ( $monitor->Orientation() )
{
case '90' :
$tempYFactor = $y;
@ -396,52 +396,52 @@ function buildControlCommand( $monitor )
$xFactor = abs($xFactor);
$yFactor = abs($yFactor);
if ( $monitor['HasPanSpeed'] && $xFactor )
if ( $monitor->HasPanSpeed() && $xFactor )
{
if ( $monitor['HasTurboPan'] )
if ( $monitor->HasTurboPan() )
{
if ( $xFactor >= $turbo )
{
$panSpeed = $monitor['TurboPanSpeed'];
$panSpeed = $monitor->TurboPanSpeed();
}
else
{
$xFactor = $xFactor/$turbo;
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
else
{
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
if ( $monitor['HasTiltSpeed'] && $yFactor )
if ( $monitor->HasTiltSpeed() && $yFactor )
{
if ( $monitor['HasTurboTilt'] )
if ( $monitor->HasTurboTilt() )
{
if ( $yFactor >= $turbo )
{
$tiltSpeed = $monitor['TurboTiltSpeed'];
$tiltSpeed = $monitor->TurboTiltSpeed();
}
else
{
$yFactor = $yFactor/$turbo;
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
else
{
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
if ( preg_match( '/(Left|Right)$/', $dirn ) )
{
$panStep = intval(round($monitor['MinPanStep']+(($monitor['MaxPanStep']-$monitor['MinPanStep'])*$xFactor)));
$panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor)));
$ctrlCommand .= " --panstep=".$panStep." --panspeed=".$panSpeed;
}
if ( preg_match( '/^(Up|Down)/', $dirn ) )
{
$tiltStep = intval(round($monitor['MinTiltStep']+(($monitor['MaxTiltStep']-$monitor['MinTiltStep'])*$yFactor)));
$tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor)));
$ctrlCommand .= " --tiltstep=".$tiltStep." --tiltspeed=".$tiltSpeed;
}
}
@ -451,12 +451,12 @@ function buildControlCommand( $monitor )
$x = deScale( $_REQUEST['x'], $_REQUEST['scale'] );
$y = deScale( $_REQUEST['y'], $_REQUEST['scale'] );
$halfWidth = $monitor['Width'] / 2;
$halfHeight = $monitor['Height'] / 2;
$halfWidth = $monitor->Width() / 2;
$halfHeight = $monitor->Height() / 2;
$xFactor = ($x - $halfWidth)/$halfWidth;
$yFactor = ($y - $halfHeight)/$halfHeight;
switch ( $monitor['Orientation'] )
switch ( $monitor->Orientation() )
{
case '90' :
$tempYFactor = $y;
@ -515,42 +515,42 @@ function buildControlCommand( $monitor )
$xFactor = abs($xFactor);
$yFactor = abs($yFactor);
if ( $monitor['HasPanSpeed'] && $xFactor )
if ( $monitor->HasPanSpeed() && $xFactor )
{
if ( $monitor['HasTurboPan'] )
if ( $monitor->HasTurboPan() )
{
if ( $xFactor >= $turbo )
{
$panSpeed = $monitor['TurboPanSpeed'];
$panSpeed = $monitor->TurboPanSpeed();
}
else
{
$xFactor = $xFactor/$turbo;
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
else
{
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
if ( $monitor['HasTiltSpeed'] && $yFactor )
if ( $monitor->HasTiltSpeed() && $yFactor )
{
if ( $monitor['HasTurboTilt'] )
if ( $monitor->HasTurboTilt() )
{
if ( $yFactor >= $turbo )
{
$tiltSpeed = $monitor['TurboTiltSpeed'];
$tiltSpeed = $monitor->TurboTiltSpeed();
}
else
{
$yFactor = $yFactor/$turbo;
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
else
{
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
if ( preg_match( '/(Left|Right)$/', $dirn ) )
@ -561,10 +561,10 @@ function buildControlCommand( $monitor )
{
$ctrlCommand .= " --tiltspeed=".$tiltSpeed;
}
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowPanSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$slow)));
$slowTiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$slow)));
$slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow)));
$slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow)));
if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) )
{
$ctrlCommand .= " --autostop";
@ -603,9 +603,9 @@ function buildControlCommand( $monitor )
break;
}
}
if ( $monitor['HasFocusSpeed'] )
if ( $monitor->HasFocusSpeed() )
{
$speed = intval(round($monitor['MinFocusSpeed']+(($monitor['MaxFocusSpeed']-$monitor['MinFocusSpeed'])*$factor)));
$speed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -613,15 +613,15 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinFocusStep']+(($monitor['MaxFocusStep']-$monitor['MinFocusStep'])*$factor)));
$step = intval(round($monitor->MinFocusStep()+(($monitor->MaxFocusStep()-$monitor->MinFocusStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowSpeed = intval(round($monitor['MinFocusSpeed']+(($monitor['MaxFocusSpeed']-$monitor['MinFocusSpeed'])*$slow)));
$slowSpeed = intval(round($monitor->MinFocusSpeed()+(($monitor->MaxFocusSpeed()-$monitor->MinFocusSpeed())*$slow)));
if ( $speed < $slowSpeed )
{
$ctrlCommand .= " --autostop";
@ -647,9 +647,9 @@ function buildControlCommand( $monitor )
break;
}
}
if ( $monitor['HasZoomSpeed'] )
if ( $monitor->HasZoomSpeed() )
{
$speed = intval(round($monitor['MinZoomSpeed']+(($monitor['MaxZoomSpeed']-$monitor['MinZoomSpeed'])*$factor)));
$speed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -657,15 +657,15 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinZoomStep']+(($monitor['MaxZoomStep']-$monitor['MinZoomStep'])*$factor)));
$step = intval(round($monitor->MinZoomStep()+(($monitor->MaxZoomStep()-$monitor->MinZoomStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowSpeed = intval(round($monitor['MinZoomSpeed']+(($monitor['MaxZoomSpeed']-$monitor['MinZoomSpeed'])*$slow)));
$slowSpeed = intval(round($monitor->MinZoomSpeed()+(($monitor->MaxZoomSpeed()-$monitor->MinZoomSpeed())*$slow)));
if ( $speed < $slowSpeed )
{
$ctrlCommand .= " --autostop";
@ -691,9 +691,9 @@ function buildControlCommand( $monitor )
break;
}
}
if ( $monitor['HasIrisSpeed'] )
if ( $monitor->HasIrisSpeed() )
{
$speed = intval(round($monitor['MinIrisSpeed']+(($monitor['MaxIrisSpeed']-$monitor['MinIrisSpeed'])*$factor)));
$speed = intval(round($monitor->MinIrisSpeed()+(($monitor->MaxIrisSpeed()-$monitor->MinIrisSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -701,7 +701,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinIrisStep']+(($monitor['MaxIrisStep']-$monitor['MinIrisStep'])*$factor)));
$step = intval(round($monitor->MinIrisStep()+(($monitor->MaxIrisStep()-$monitor->MinIrisStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -723,9 +723,9 @@ function buildControlCommand( $monitor )
break;
}
}
if ( $monitor['HasWhiteSpeed'] )
if ( $monitor->HasWhiteSpeed() )
{
$speed = intval(round($monitor['MinWhiteSpeed']+(($monitor['MaxWhiteSpeed']-$monitor['MinWhiteSpeed'])*$factor)));
$speed = intval(round($monitor->MinWhiteSpeed()+(($monitor->MaxWhiteSpeed()-$monitor->MinWhiteSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -733,7 +733,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinWhiteStep']+(($monitor['MaxWhiteStep']-$monitor['MinWhiteStep'])*$factor)));
$step = intval(round($monitor->MinWhiteStep()+(($monitor->MaxWhiteStep()-$monitor->MinWhiteStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -755,9 +755,9 @@ function buildControlCommand( $monitor )
break;
}
}
if ( $monitor['HasGainSpeed'] )
if ( $monitor->HasGainSpeed() )
{
$speed = intval(round($monitor['MinGainSpeed']+(($monitor['MaxGainSpeed']-$monitor['MinGainSpeed'])*$factor)));
$speed = intval(round($monitor->MinGainSpeed()+(($monitor->MaxGainSpeed()-$monitor->MinGainSpeed())*$factor)));
$ctrlCommand .= " --speed=".$speed;
}
switch( $mode )
@ -765,7 +765,7 @@ function buildControlCommand( $monitor )
case 'Abs' :
case 'Rel' :
{
$step = intval(round($monitor['MinGainStep']+(($monitor['MaxGainStep']-$monitor['MinGainStep'])*$factor)));
$step = intval(round($monitor->MinGainStep()+(($monitor->MaxGainStep()-$monitor->MinGainStep())*$factor)));
$ctrlCommand .= " --step=".$step;
break;
}
@ -794,7 +794,7 @@ function buildControlCommand( $monitor )
$xFactor = ($x+1)/$short_x;
}
if ( $monitor['Orientation'] != '0' )
if ( $monitor->Orientation() != '0' )
{
$conversions = array(
'90' => array(
@ -848,48 +848,48 @@ function buildControlCommand( $monitor )
'DownRight' => 'UpRight',
),
);
$new_dirn = $conversions[$monitor['Orientation']][$dirn];
$new_dirn = $conversions[$monitor->Orientation()][$dirn];
$_REQUEST['control'] = preg_replace( "/_$dirn\$/", "_$new_dirn", $_REQUEST['control'] );
$dirn = $new_dirn;
}
if ( $monitor['HasPanSpeed'] && $xFactor )
if ( $monitor->HasPanSpeed() && $xFactor )
{
if ( $monitor['HasTurboPan'] )
if ( $monitor->HasTurboPan() )
{
if ( $xFactor >= $turbo )
{
$panSpeed = $monitor['TurboPanSpeed'];
$panSpeed = $monitor->TurboPanSpeed();
}
else
{
$xFactor = $xFactor/$turbo;
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
}
else
{
$panSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$xFactor)));
$panSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$xFactor)));
}
$ctrlCommand .= " --panspeed=".$panSpeed;
}
if ( $monitor['HasTiltSpeed'] && $yFactor )
if ( $monitor->HasTiltSpeed() && $yFactor )
{
if ( $monitor['HasTurboTilt'] )
if ( $monitor->HasTurboTilt() )
{
if ( $yFactor >= $turbo )
{
$tiltSpeed = $monitor['TurboTiltSpeed'];
$tiltSpeed = $monitor->TurboTiltSpeed();
}
else
{
$yFactor = $yFactor/$turbo;
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
}
else
{
$tiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$yFactor)));
$tiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$yFactor)));
}
$ctrlCommand .= " --tiltspeed=".$tiltSpeed;
}
@ -900,22 +900,22 @@ function buildControlCommand( $monitor )
{
if ( preg_match( '/(Left|Right)$/', $dirn ) )
{
$panStep = intval(round($monitor['MinPanStep']+(($monitor['MaxPanStep']-$monitor['MinPanStep'])*$xFactor)));
$panStep = intval(round($monitor->MinPanStep()+(($monitor->MaxPanStep()-$monitor->MinPanStep())*$xFactor)));
$ctrlCommand .= " --panstep=".$panStep;
}
if ( preg_match( '/^(Up|Down)/', $dirn ) )
{
$tiltStep = intval(round($monitor['MinTiltStep']+(($monitor['MaxTiltStep']-$monitor['MinTiltStep'])*$yFactor)));
$tiltStep = intval(round($monitor->MinTiltStep()+(($monitor->MaxTiltStep()-$monitor->MinTiltStep())*$yFactor)));
$ctrlCommand .= " --tiltstep=".$tiltStep;
}
break;
}
case 'Con' :
{
if ( $monitor['AutoStopTimeout'] )
if ( $monitor->AutoStopTimeout() )
{
$slowPanSpeed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$slow)));
$slowTiltSpeed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$slow)));
$slowPanSpeed = intval(round($monitor->MinPanSpeed()+(($monitor->MaxPanSpeed()-$monitor->MinPanSpeed())*$slow)));
$slowTiltSpeed = intval(round($monitor->MinTiltSpeed()+(($monitor->MaxTiltSpeed()-$monitor->MinTiltSpeed())*$slow)));
if ( (!isset($panSpeed) || ($panSpeed < $slowPanSpeed)) && (!isset($tiltSpeed) || ($tiltSpeed < $slowTiltSpeed)) )
{
$ctrlCommand .= " --autostop";
@ -943,12 +943,12 @@ function buildControlCommand( $monitor )
if ( canEdit( 'Control' ) ) {
$preset = validInt($_REQUEST['preset']);
$newLabel = validJsStr($_REQUEST['newLabel']);
$row = dbFetchOne( 'SELECT * FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', NULL, array( $monitor['Id'], $preset ) );
$row = dbFetchOne( 'SELECT * FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', NULL, array( $monitor->Id(), $preset ) );
if ( $newLabel != $row['Label'] ) {
if ( $newLabel ) {
dbQuery( 'REPLACE INTO ControlPresets ( MonitorId, Preset, Label ) VALUES ( ?, ?, ? )', array( $monitor['Id'], $preset, $newLabel ) );
dbQuery( 'REPLACE INTO ControlPresets ( MonitorId, Preset, Label ) VALUES ( ?, ?, ? )', array( $monitor->Id(), $preset, $newLabel ) );
} else {
dbQuery( 'DELETE FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', array( $monitor['Id'], $preset ) );
dbQuery( 'DELETE FROM ControlPresets WHERE MonitorId = ? AND Preset = ?', array( $monitor->Id(), $preset ) );
}
}
$ctrlCommand .= " --preset=".$preset;

View File

@ -94,6 +94,25 @@ function noCacheHeaders()
header("Pragma: no-cache"); // HTTP/1.0
}
function CORSHeaders() {
if ( isset( $_SERVER['HTTP_ORIGIN'] ) ) {
# The following is left for future reference/use.
$valid = false;
foreach( dbFetchAll( 'SELECT * FROM Servers' ) as $row ) {
$Server = new Server( $row );
if ( $_SERVER['HTTP_ORIGIN'] == $Server->Url() ) {
$valid = true;
header("Access-Control-Allow-Origin: " . $Server->Url() );
header("Access-Control-Allow-Headers: x-requested-with,x-request");
}
}
if ( ! $valid ) {
Warning( $_SERVER['HTTP_ORIGIN'] . " is not found in servers list." );
}
}
}
function getAuthUser( $auth )
{
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" && !empty($auth) )

View File

@ -48,6 +48,7 @@ if ( false )
require_once( 'includes/config.php' );
require_once( 'includes/logger.php' );
require_once( 'includes/Server.php' );
if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' )
{
@ -136,6 +137,9 @@ else
require_once( 'includes/lang.php' );
require_once( 'includes/functions.php' );
# Add Cross domain access headers
CORSHeaders();
// Check for valid content dirs
if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) )
{

View File

@ -124,6 +124,8 @@ $SLANG = array(
'AttrMaxScore' => 'Max. Score',
'AttrMonitorId' => 'Monitor Id',
'AttrMonitorName' => 'Monitor Name',
'AttrServerId' => 'Server Id',
'AttrServerName' => 'Server Name',
'AttrName' => 'Name',
'AttrNotes' => 'Notes',
'AttrSystemLoad' => 'System Load',

View File

@ -30,13 +30,13 @@ function getControlCommands( $monitor )
$cmds['PresetGoto'] = "presetGoto";
$cmds['PresetHome'] = "presetHome";
if ( !empty($monitor['CanZoom']) )
if ( !empty($monitor->CanZoom) )
{
if ( $monitor['CanZoomCon'] )
if ( $monitor->CanZoomCon() )
$cmds['ZoomRoot'] = "zoomCon";
elseif ( $monitor['CanZoomRel'] )
elseif ( $monitor->CanZoomRel() )
$cmds['ZoomRoot'] = "zoomRel";
elseif ( $monitor['CanZoomAbs'] )
elseif ( $monitor->CanZoomAbs() )
$cmds['ZoomRoot'] = "zoomAbs";
$cmds['ZoomTele'] = $cmds['ZoomRoot']."Tele";
$cmds['ZoomWide'] = $cmds['ZoomRoot']."Wide";
@ -45,13 +45,13 @@ function getControlCommands( $monitor )
$cmds['ZoomMan'] = "zoomMan";
}
if ( !empty($monitor['CanFocus']) )
if ( !empty($monitor->CanFocus) )
{
if ( $monitor['CanFocusCon'] )
if ( $monitor->CanFocusCon() )
$cmds['FocusRoot'] = "focusCon";
elseif ( $monitor['CanFocusRel'] )
elseif ( $monitor->CanFocusRel() )
$cmds['FocusRoot'] = "focusRel";
elseif ( $monitor['CanFocusAbs'] )
elseif ( $monitor->CanFocusAbs() )
$cmds['FocusRoot'] = "focusAbs";
$cmds['FocusFar'] = $cmds['FocusRoot']."Far";
$cmds['FocusNear'] = $cmds['FocusRoot']."Near";
@ -60,13 +60,13 @@ function getControlCommands( $monitor )
$cmds['FocusMan'] = "focusMan";
}
if ( !empty($monitor['CanIris']) )
if ( !empty($monitor->CanIris) )
{
if ( $monitor['CanIrisCon'] )
if ( $monitor->CanIrisCon() )
$cmds['IrisRoot'] = "irisCon";
elseif ( $monitor['CanIrisRel'] )
elseif ( $monitor->CanIrisRel() )
$cmds['IrisRoot'] = "irisRel";
elseif ( $monitor['CanIrisAbs'] )
elseif ( $monitor->CanIrisAbs() )
$cmds['IrisRoot'] = "irisAbs";
$cmds['IrisOpen'] = $cmds['IrisRoot']."Open";
$cmds['IrisClose'] = $cmds['IrisRoot']."Close";
@ -75,13 +75,13 @@ function getControlCommands( $monitor )
$cmds['IrisMan'] = "irisMan";
}
if ( !empty($monitor['CanWhite']) )
if ( !empty($monitor->CanWhite) )
{
if ( $monitor['CanWhiteCon'] )
if ( $monitor->CanWhiteCon() )
$cmds['WhiteRoot'] = "whiteCon";
elseif ( $monitor['CanWhiteRel'] )
elseif ( $monitor->CanWhiteRel() )
$cmds['WhiteRoot'] = "whiteRel";
elseif ( $monitor['CanWhiteAbs'] )
elseif ( $monitor->CanWhiteAbs() )
$cmds['WhiteRoot'] = "whiteAbs";
$cmds['WhiteIn'] = $cmds['WhiteRoot']."In";
$cmds['WhiteOut'] = $cmds['WhiteRoot']."Out";
@ -89,13 +89,13 @@ function getControlCommands( $monitor )
$cmds['WhiteMan'] = "whiteMan";
}
if ( !empty($monitor['CanGain']) )
if ( !empty($monitor->CanGain) )
{
if ( $monitor['CanGainCon'] )
if ( $monitor->CanGainCon() )
$cmds['GainRoot'] = "gainCon";
elseif ( $monitor['CanGainRel'] )
elseif ( $monitor->CanGainRel() )
$cmds['GainRoot'] = "gainRel";
elseif ( $monitor['CanGainAbs'] )
elseif ( $monitor->CanGainAbs() )
$cmds['GainRoot'] = "gainAbs";
$cmds['GainUp'] = $cmds['GainRoot']."Up";
$cmds['GainDown'] = $cmds['GainRoot']."Down";
@ -103,19 +103,19 @@ function getControlCommands( $monitor )
$cmds['GainMan'] = "gainMan";
}
if ( !empty($monitor['CanMove']) )
if ( !empty($monitor->CanMove) )
{
if ( $monitor['CanMoveCon'] )
if ( $monitor->CanMoveCon() )
{
$cmds['MoveRoot'] = "moveCon";
$cmds['Center'] = "moveStop";
}
elseif ( $monitor['CanMoveRel'] )
elseif ( $monitor->CanMoveRel() )
{
$cmds['MoveRoot'] = "moveRel";
$cmds['Center'] = $cmds['PresetHome'];
}
elseif ( $monitor['CanMoveAbs'] )
elseif ( $monitor->CanMoveAbs() )
{
$cmds['MoveRoot'] = "moveAbs";
$cmds['Center'] = $cmds['PresetHome'];
@ -142,11 +142,11 @@ function controlFocus( $monitor, $cmds )
<div class="arrowControl focusControls">
<div class="arrowLabel"><?php echo translate('Near') ?></div>
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['FocusNear'] ?>',event,0,-1)"></div>
<div class="arrowCenter"<?php if ( $monitor['CanFocusCon'] ) { ?> onclick="controlCmd('<?php echo $cmds['FocusStop'] ?>')"<?php } ?>><?php echo translate('Focus') ?></div>
<div class="arrowCenter"<?php if ( $monitor->CanFocusCon() ) { ?> onclick="controlCmd('<?php echo $cmds['FocusStop'] ?>')"<?php } ?>><?php echo translate('Focus') ?></div>
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['FocusFar'] ?>',event,0,1)"></div>
<div class="arrowLabel"><?php echo translate('Far') ?></div>
<?php
if ( $monitor['CanAutoFocus'] )
if ( $monitor->CanAutoFocus() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['FocusAuto'] ?>')"/>
@ -168,11 +168,11 @@ function controlZoom( $monitor, $cmds )
<div class="arrowControl zoomControls">
<div class="arrowLabel"><?php echo translate('Tele') ?></div>
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['ZoomTele'] ?>',event,0,-1)"></div>
<div class="arrowCenter"<?php if ( $monitor['CanZoomCon'] ) { ?> onclick="controlCmd('<?php echo $cmds['ZoomStop'] ?>')"<?php } ?>><?php echo translate('Zoom') ?></div>
<div class="arrowCenter"<?php if ( $monitor->CanZoomCon() ) { ?> onclick="controlCmd('<?php echo $cmds['ZoomStop'] ?>')"<?php } ?>><?php echo translate('Zoom') ?></div>
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['ZoomWide'] ?>',event,0,1)"></div>
<div class="arrowLabel"><?php echo translate('Wide') ?></div>
<?php
if ( $monitor['CanAutoZoom'] )
if ( $monitor->CanAutoZoom() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['ZoomAuto'] ?>')"/>
@ -193,11 +193,11 @@ function controlIris( $monitor, $cmds )
<div class="arrowControl irisControls">
<div class="arrowLabel"><?php echo translate('Open') ?></div>
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['IrisOpen'] ?>',event,0,-1)"></div>
<div class="arrowCenter"<?php if ( $monitor['CanIrisCon'] ) { ?> onclick="controlCmd('<?php echo $cmds['IrisStop'] ?>')"<?php } ?>><?php echo translate('Iris') ?></div>
<div class="arrowCenter"<?php if ( $monitor->CanIrisCon() ) { ?> onclick="controlCmd('<?php echo $cmds['IrisStop'] ?>')"<?php } ?>><?php echo translate('Iris') ?></div>
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['IrisClose'] ?>',event,0,1)"></div>
<div class="arrowLabel"><?php echo translate('Close') ?></div>
<?php
if ( $monitor['CanAutoIris'] )
if ( $monitor->CanAutoIris() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['IrisAuto'] ?>')"/>
@ -219,11 +219,11 @@ function controlWhite( $monitor, $cmds )
<div class="arrowControl whiteControls">
<div class="arrowLabel"><?php echo translate('In') ?></div>
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['WhiteIn'] ?>',event,0,-1)"></div>
<div class="arrowCenter"<?php if ( $monitor['CanWhiteCon'] ) { ?> onclick="controlCmd('<?php echo $cmds['WhiteStop'] ?>')"<?php } ?>><?php echo translate('White') ?></div>
<div class="arrowCenter"<?php if ( $monitor->CanWhiteCon() ) { ?> onclick="controlCmd('<?php echo $cmds['WhiteStop'] ?>')"<?php } ?>><?php echo translate('White') ?></div>
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['WhiteOut'] ?>',event,0,1)"></div>
<div class="arrowLabel"><?php echo translate('Out') ?></div>
<?php
if ( $monitor['CanAutoWhite'] )
if ( $monitor->CanAutoWhite() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['WhiteAuto'] ?>')"/>
@ -246,9 +246,9 @@ function controlPanTilt( $monitor, $cmds )
<div class="pantilLabel"><?php echo translate('PanTilt') ?></div>
<div class="pantiltButtons">
<?php
$hasPan = $monitor['CanPan'];
$hasTilt = $monitor['CanTilt'];
$hasDiag = $hasPan && $hasTilt && $monitor['CanMoveDiag'];
$hasPan = $monitor->CanPan;
$hasTilt = $monitor->CanTilt;
$hasDiag = $hasPan && $hasTilt && $monitor->CanMoveDiag;
?>
<div class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></div>
<div class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></div>
@ -271,14 +271,14 @@ function controlPresets( $monitor, $cmds )
define( "MAX_PRESETS", "12" );
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."'";
$sql = 'select * from ControlPresets where MonitorId = ?';
$labels = array();
foreach( dbFetchAll( $sql ) as $row )
foreach( dbFetchAll( $sql, NULL, array( $monitor->Id() ) ) as $row )
{
$labels[$row['Preset']] = $row['Label'];
}
$presetBreak = (int)(($monitor['NumPresets']+1)/((int)(($monitor['NumPresets']-1)/MAX_PRESETS)+1));
$presetBreak = (int)(($monitor->NumPresets+1)/((int)(($monitor->NumPresets-1)/MAX_PRESETS)+1));
ob_start();
?>
@ -286,7 +286,7 @@ function controlPresets( $monitor, $cmds )
<!--<div><?php echo translate('Presets') ?></div>-->
<div>
<?php
for ( $i = 1; $i <= $monitor['NumPresets']; $i++ )
for ( $i = 1; $i <= $monitor->NumPresets; $i++ )
{
?><input type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?$labels[$i]:"" ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/><?php
if ( $i && (($i%$presetBreak) == 0) )
@ -298,16 +298,16 @@ function controlPresets( $monitor, $cmds )
</div>
<div>
<?php
if ( $monitor['HasHomePreset'] )
if ( $monitor->HasHomePreset() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/>
<?php
}
if ( canEdit( 'Monitors') && $monitor['CanSetPresets'] )
if ( canEdit( 'Monitors') && $monitor->CanSetPresets() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Set') ?>" onclick="createPopup( '?view=controlpreset&amp;mid=<?php echo $monitor['Id'] ?>', 'zmPreset', 'preset' );"/>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Set') ?>" onclick="createPopup( '?view=controlpreset&amp;mid=<?php echo $monitor->Id() ?>', 'zmPreset', 'preset' );"/>
<?php
}
?>
@ -327,19 +327,19 @@ function controlPower( $monitor, $cmds )
<div class="powerLabel"><?php echo translate('Control') ?></div>
<div>
<?php
if ( $monitor['CanWake'] )
if ( $monitor->CanWake() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Wake') ?>" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"/>
<?php
}
if ( $monitor['CanSleep'] )
if ( $monitor->CanSleep() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Sleep') ?>" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"/>
<?php
}
if ( $monitor['CanReset'] )
if ( $monitor->CanReset() )
{
?>
<input type="button" class="ptzTextBtn" value="<?php echo translate('Reset') ?>" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"/>
@ -359,22 +359,22 @@ function ptzControls( $monitor )
?>
<div class="controlsPanel">
<?php
if ( $monitor['CanFocus'] )
if ( $monitor->CanFocus() )
echo controlFocus( $monitor, $cmds );
if ( $monitor['CanZoom'] )
if ( $monitor->CanZoom() )
echo controlZoom( $monitor, $cmds );
if ( $monitor['CanIris'] )
if ( $monitor->CanIris() )
echo controlIris( $monitor, $cmds );
if ( $monitor['CanWhite'] )
if ( $monitor->CanWhite() )
echo controlWhite( $monitor, $cmds );
if ( $monitor['CanMove'] || ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] ) )
if ( $monitor->CanMove() || ( $monitor->CanWake() || $monitor->CanSleep() || $monitor->CanReset() ) )
{
?>
<div class="pantiltPanel">
<?php
if ( $monitor['CanMove'] )
if ( $monitor->CanMove() )
echo controlPanTilt( $monitor, $cmds );
if ( $monitor['CanWake'] || $monitor['CanSleep'] || $monitor['CanReset'] )
if ( $monitor->CanWake() || $monitor->CanSleep() || $monitor->CanReset() )
echo controlPower( $monitor, $cmds );
?>
</div>
@ -383,7 +383,7 @@ function ptzControls( $monitor )
?>
</div>
<?php
if ( $monitor['HasPresets'] )
if ( $monitor->HasPresets() )
echo controlPresets( $monitor, $cmds );
return( ob_get_clean() );
}

View File

@ -48,7 +48,7 @@ var popupSizes = {
'log': { 'width': 1080, 'height': 720 },
'login': { 'width': 720, 'height': 480 },
'logout': { 'width': 260, 'height': 100 },
'monitor': { 'width': 525, 'height': 700 },
'monitor': { 'width': 550, 'height': 700 },
'monitorpreset':{ 'width': 440, 'height': 200 },
'monitorprobe': { 'width': 500, 'height': 240 },
'monitorselect':{ 'width': 160, 'height': 200 },

View File

@ -18,6 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once('includes/Server.php');
$eventCounts = array(
array(
"title" => translate('Events'),
@ -235,6 +237,7 @@ else
<tr>
<th class="colName"><?php echo translate('Name') ?></th>
<th class="colFunction"><?php echo translate('Function') ?></th>
<th class="colServer"><?php echo translate('Server') ?></th>
<th class="colSource"><?php echo translate('Source') ?></th>
<?php
for ( $i = 0; $i < count($eventCounts); $i++ )
@ -258,7 +261,7 @@ if ( canEdit('Monitors') )
</thead>
<tfoot>
<tr>
<td class="colLeftButtons" colspan="3">
<td class="colLeftButtons" colspan="4">
<input type="button" value="<?php echo translate('Refresh') ?>" onclick="location.reload(true);"/>
<?php echo makePopupButton( '?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), (canEdit( 'Monitors' ) && !$user['MonitorIds']) ) ?>
<?php echo makePopupButton( '?view=filter&amp;filter[terms][0][attr]=DateTime&amp;filter[terms][0][op]=%3c&amp;filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?>
@ -305,6 +308,10 @@ foreach( $displayMonitors as $monitor )
?>
<td class="colName"><?php echo makePopupLink( '?view=watch&amp;mid='.$monitor['Id'], 'zmWatch'.$monitor['Id'], array( 'watch', reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ) ), $monitor['Name'], $running && ($monitor['Function'] != 'None') && canView( 'Stream' ) ) ?></td>
<td class="colFunction"><?php echo makePopupLink( '?view=function&amp;mid='.$monitor['Id'], 'zmFunction', 'function', '<span class="'.$fclass.'">'.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'</span>', canEdit( 'Monitors' ) ) ?></td>
<td class="colServer"><?php
$Server = new Server( $monitor['ServerId'] );
echo $Server->Name();
?></td>
<?php if ( $monitor['Type'] == "Local" ) { ?>
<td class="colSource"><?php echo makePopupLink( '?view=monitor&amp;mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.$monitor['Device'].' ('.$monitor['Channel'].')</span>', canEdit( 'Monitors' ) ) ?></td>
<?php } elseif ( $monitor['Type'] == "Remote" ) { ?>

View File

@ -84,6 +84,8 @@ $attrTypes = array(
'DiskPercent' => translate('AttrDiskPercent'),
'DiskBlocks' => translate('AttrDiskBlocks'),
'SystemLoad' => translate('AttrSystemLoad'),
'ServerId' => translate('AttrServerId'),
'ServerName' => translate('AttrServerName'),
);
$opTypes = array(
'=' => translate('OpEq'),

View File

@ -22,7 +22,7 @@ var logTimeout = maxSampleTime;
var firstLoad = true;
var initialDisplayLimit = 200;
var sortReversed = false;
var filterFields = [ 'Component', 'Pid', 'Level', 'File', 'Line'];
var filterFields = [ 'Component', 'Server', 'Pid', 'Level', 'File', 'Line'];
var options = {};
function buildFetchParms( parms )
@ -68,7 +68,7 @@ function logResponse( respObj )
maxLogTime = log.TimeKey;
if ( !minLogTime || log.TimeKey < minLogTime )
minLogTime = log.TimeKey;
var row = logTable.push( [ { content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Pid, log.Code, log.Message, log.File, log.Line ] );
var row = logTable.push( [ { content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Server, log.Pid, log.Code, log.Message, log.File, log.Line ] );
delete log.Message;
row.tr.store( 'log', log );
if ( log.Level <= -3 )

View File

@ -31,7 +31,12 @@ var monitorData = new Array();
foreach ( $monitors as $monitor )
{
?>
monitorData[monitorData.length] = { 'id': <?php echo $monitor['Id'] ?>, 'connKey': <?php echo $monitor['connKey'] ?>, 'width': <?php echo $monitor['Width'] ?>,'height':<?php echo $monitor['Height'] ?> };
monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>,
'connKey': <?php echo $monitor->connKey() ?>,
'width': <?php echo $monitor->Width() ?>,
'height':<?php echo $monitor->Height() ?>
};
<?php
}
?>

View File

@ -0,0 +1,14 @@
function validateForm( form, newServer )
{
var errors = new Array();
if ( !form.elements['newServer[Name]'].value )
{
errors[errors.length] = "You must supply a name";
}
if ( errors.length )
{
alert( errors.join( "\n" ) );
return( false );
}
return( true );
}

View File

@ -100,7 +100,7 @@ function setAlarmState( currentAlarmState )
}
var streamCmdParms = "view=request&request=stream&connkey="+connKey;
var streamCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStreamCmdResponse } );
var streamCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStreamCmdResponse } );
var streamCmdTimer = null;
var streamStatus;
@ -348,7 +348,7 @@ function streamCmdQuery()
}
var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate";
var statusCmdReq = new Request.JSON( { url: thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } );
var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } );
var statusCmdTimer = null;
function getStatusCmdResponse( respObj, respText )
@ -377,7 +377,7 @@ function statusCmdQuery()
}
var alarmCmdParms = "view=request&request=alarm&id="+monitorId;
var alarmCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } );
var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } );
var alarmCmdFirst = true;
function getAlarmCmdResponse( respObj, respText )

View File

@ -44,9 +44,11 @@ var showMode = "<?php echo ($showPtzControls && !empty($control))?"control":"eve
var connKey = '<?php echo $connkey ?>';
var maxDisplayEvents = <?php echo 2 * MAX_EVENTS ?>;
var monitorId = <?php echo $monitor['Id'] ?>;
var monitorWidth = <?php echo $monitor['Width'] ?>;
var monitorHeight = <?php echo $monitor['Height'] ?>;
var monitorId = <?php echo $monitor->Id() ?>;
var monitorWidth = <?php echo $monitor->Width() ?>;
var monitorHeight = <?php echo $monitor->Height() ?>;
var monitorUrl = '<?php echo ( $monitor->Server()->Url() ) ?>';
var scale = <?php echo $scale ?>;
@ -61,11 +63,11 @@ var canStreamNative = <?php echo canStreamNative()?'true':'false' ?>;
var canPlayPauseAudio = Browser.ie;
<?php if ( $monitor['CanMoveMap'] ) { ?>
<?php if ( $monitor->CanMoveMap() ) { ?>
var imageControlMode = "moveMap";
<?php } elseif ( $monitor['CanMoveRel'] ) { ?>
<?php } elseif ( $monitor->CanMoveRel() ) { ?>
var imageControlMode = "movePseudoMap";
<?php } elseif ( $monitor['CanMoveCon'] ) { ?>
<?php } elseif ( $monitor->CanMoveCon() ) { ?>
var imageControlMode = "moveConMap";
<?php } else { ?>
var imageControlMode = null;

View File

@ -54,6 +54,7 @@ xhtmlHeaders(__FILE__, translate('SystemLog') );
<div id="content">
<div id="filters"><?php echo translate('FilterLog') ?> -
<?php echo translate('Component') ?> <select id="filter[Component]" onchange="filterLog(this)"><option value="">-----</option></select>
<?php echo translate('Server') ?> <select id="filter[Server]" onchange="filterLog(this)"><option value="">-----</option></select>
<?php echo translate('Pid') ?> <select id="filter[Pid]" onchange="filterLog(this)"><option value="">-----</option></select>
<?php echo translate('Level') ?> <select id="filter[Level]" onchange="filterLog(this)"><option value="">---</option></select>
<?php echo translate('File') ?> <select id="filter[File]" onchange="filterLog(this)"><option value="">------</option></select>
@ -67,6 +68,7 @@ xhtmlHeaders(__FILE__, translate('SystemLog') );
<tr>
<th><?php echo translate('DateTime') ?></th>
<th class="table-th-nosort"><?php echo translate('Component') ?></th>
<th class="table-th-nosort"><?php echo translate('Server') ?></th>
<th class="table-th-nosort"><?php echo translate('Pid') ?></th>
<th class="table-th-nosort"><?php echo translate('Level') ?></th>
<th class="table-th-nosort"><?php echo translate('Message') ?></th>

View File

@ -18,6 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once( 'includes/Server.php');
if ( !canView( 'Monitors' ) )
{
$view = "error";
@ -40,6 +42,7 @@ if ( isset($_REQUEST['tab']) )
else
$tab = "general";
$Server = null;
if ( defined( 'ZM_SERVER_ID' ) ) {
$Server = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( ZM_SERVER_ID ) );
}
@ -646,8 +649,12 @@ switch ( $tab )
<tr><td><?php echo translate('Name') ?></td><td><input type="text" name="newMonitor[Name]" value="<?php echo validHtmlStr($newMonitor['Name']) ?>" size="16"/></td></tr>
<tr><td><?php echo translate('Server') ?></td><td>
<?php
$servers = dbFetchAssoc( 'SELECT Id,Name FROM Servers ORDER BY Name', 'Id', 'Name' );
array_unshift( $servers, 'None' );
$servers = array(''=>'None');
$result = dbQuery( 'SELECT * FROM Servers ORDER BY Name');
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' );
foreach ( $results as $row => $server_obj ) {
$servers[$server_obj->Id] = $server_obj->Name();
}
?>
<?php echo buildSelect( "newMonitor[ServerId]", $servers ); ?>
</td></tr>

View File

@ -24,6 +24,8 @@ if ( !canView( 'Stream' ) )
return;
}
require_once( 'includes/Monitor.php' );
$groupSql = "";
if ( !empty($_REQUEST['group']) )
{
@ -64,7 +66,7 @@ foreach( dbFetchAll( $sql ) as $row )
$row['scaleWidth'] = $scaleWidth;
$row['scaleHeight'] = $scaleHeight;
$row['connKey'] = generateConnKey();
$monitors[] = $row;
$monitors[] = new Monitor( $row );
}
$focusWindow = true;
@ -107,29 +109,29 @@ if ( $showControl )
<?php
foreach ( $monitors as $monitor )
{
$connkey = $monitor['connKey']; // Minor hack
$connkey = $monitor->connKey(); // Minor hack
if ( !isset( $scale ) )
$scale = reScale( SCALE_BASE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$scale = reScale( SCALE_BASE, $monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE );
?>
<div id="monitorFrame<?php echo $monitor['index'] ?>" class="monitorFrame">
<div id="monitor<?php echo $monitor['index'] ?>" class="monitor idle">
<div id="imageFeed<?php echo $monitor['index'] ?>" class="imageFeed" onclick="createPopup( '?view=watch&amp;mid=<?php echo $monitor['Id'] ?>', 'zmWatch<?php echo $monitor['Id'] ?>', 'watch', <?php echo $monitor['scaleWidth'] ?>, <?php echo $monitor['scaleHeight'] ?> );">
<div id="monitorFrame<?php echo $monitor->index() ?>" class="monitorFrame">
<div id="monitor<?php echo $monitor->index() ?>" class="monitor idle">
<div id="imageFeed<?php echo $monitor->index() ?>" class="imageFeed" onclick="createPopup( '?view=watch&amp;mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo $monitor->scaleWidth() ?>, <?php echo $monitor->scaleHeight() ?> );">
<?php
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
{
$streamSrc = getStreamSrc( array( "mode=mpeg", "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
outputVideoStream( "liveStream".$monitor['Id'], $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT );
$streamSrc = $monitor->getStreamSrc( array( "mode=mpeg", "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
outputVideoStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), ZM_MPEG_LIVE_FORMAT );
}
else
{
$streamSrc = getStreamSrc( array( "mode=jpeg", "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) );
$streamSrc = $monitor->getStreamSrc( array( "mode=jpeg", "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) );
if ( canStreamNative() )
{
outputImageStream( "liveStream".$monitor['Id'], $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
outputImageStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), validHtmlStr($monitor->Name()) );
}
else
{
outputHelperStream( "liveStream".$monitor['Id'], $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ) );
outputHelperStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ) );
}
}
?>
@ -138,7 +140,7 @@ else
if ( !ZM_WEB_COMPACT_MONTAGE )
{
?>
<div id="monitorState<?php echo $monitor['index'] ?>" class="monitorState idle"><?php echo translate('State') ?>:&nbsp;<span id="stateValue<?php echo $monitor['index'] ?>"></span>&nbsp;-&nbsp;<span id="fpsValue<?php echo $monitor['index'] ?>"></span>&nbsp;fps</div>
<div id="monitorState<?php echo $monitor->index() ?>" class="monitorState idle"><?php echo translate('State') ?>:&nbsp;<span id="stateValue<?php echo $monitor->index() ?>"></span>&nbsp;-&nbsp;<span id="fpsValue<?php echo $monitor->index() ?>"></span>&nbsp;fps</div>
<?php
}
?>

View File

@ -227,7 +227,7 @@ elseif ( $tab == "users" )
<tbody>
<?php foreach( dbFetchAll( 'SELECT * FROM Servers' ) as $row ) { ?>
<tr>
<td class="colName"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Name']).($user['Name']==$row['Name']?"*":""), $canEdit ) ?></td>
<td class="colName"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Name']), $canEdit ) ?></td>
<td class="colMark"><input type="checkbox" name="markIds[]" value="<?php echo $row['Id'] ?>" onclick="configureDeleteButton( this );"<?php if ( !$canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
</tr>
<?php } #end foreach Server ?>

View File

@ -32,6 +32,7 @@ if ( $_REQUEST['id'] ) {
} else {
$newServer = array();
$newServer['Name'] = translate('NewServer');
$newServer['Hostname'] = '';
}
$focusWindow = true;
@ -54,11 +55,16 @@ xhtmlHeaders(__FILE__, translate('Server')." - ".$newServer['Name'] );
<th scope="row"><?php echo translate('ServerName') ?></th>
<td><input type="text" name="newServer[Name]" value="<?php echo $newServer['Name'] ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('ServerHostname') ?></th>
<td><input type="text" name="newServer[Hostname]" value="<?php echo $newServer['Hostname'] ?>"/></td>
</tr>
</tbody>
</table>
<div id="contentButtons">
<input type="submit" name="action" value="<?php echo translate('Save') ?>"/>
<input type="button" value="<?php echo translate('Cancel') ?>" onclick="closeWindow()"/>
<input type="hidden" name="action" value="Save"/>
<input type="submit" value="<?php echo translate('Save') ?>"/>
<input type="button" value="<?php echo translate('Cancel') ?>" onclick="closeWindow();"/>
</div>
</form>
</div>

View File

@ -18,61 +18,67 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once('includes/Monitor.php');
if ( !canView( 'Stream' ) )
{
$view = "error";
return;
}
if ( ! visibleMonitor( $_REQUEST['mid'] ) ) {
// This is for input sanitation
$mid = intval( $_REQUEST['mid'] );
if ( ! visibleMonitor( $mid ) ) {
$view = "error";
return;
}
$sql = 'SELECT C.*, M.* FROM Monitors AS M LEFT JOIN Controls AS C ON (M.ControlId = C.Id ) WHERE M.Id = ?';
$monitor = dbFetchOne( $sql, NULL, array( $_REQUEST['mid'] ) );
$monitor = new Monitor( $mid );
#dbFetchOne( $sql, NULL, array( $_REQUEST['mid'] ) );
if ( isset($_REQUEST['showControls']) )
$showControls = validInt($_REQUEST['showControls']);
else
$showControls = (canView( 'Control' ) && ($monitor['DefaultView'] == 'Control'));
$showControls = (canView( 'Control' ) && ($monitor->DefaultView() == 'Control'));
$showPtzControls = ( ZM_OPT_CONTROL && $monitor['Controllable'] && canView( 'Control' ) );
$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView( 'Control' ) );
if ( isset( $_REQUEST['scale'] ) )
$scale = validInt($_REQUEST['scale']);
else
$scale = reScale( SCALE_BASE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE );
$connkey = generateConnKey();
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
{
$streamMode = "mpeg";
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
$streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
}
elseif ( canStream() )
{
$streamMode = "jpeg";
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor['StreamReplayBuffer'] ) );
$streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "buffer=".$monitor->StreamReplayBuffer() ) );
}
else
{
$streamMode = "single";
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale ) );
$streamSrc = $monitor->getStreamSrc( array( "mode=".$streamMode, "scale=".$scale ) );
Info( "The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.");
}
$showDvrControls = ( $streamMode == 'jpeg' && $monitor['StreamReplayBuffer'] != 0 );
$showDvrControls = ( $streamMode == 'jpeg' && $monitor->StreamReplayBuffer() != 0 );
noCacheHeaders();
xhtmlHeaders( __FILE__, $monitor['Name']." - ".translate('Feed') );
xhtmlHeaders( __FILE__, $monitor->Name()." - ".translate('Feed') );
?>
<body>
<div id="page">
<div id="content">
<div id="menuBar">
<div id="monitorName"><?php echo $monitor['Name'] ?></div>
<div id="monitorName"><?php echo $monitor->Name() ?></div>
<div id="closeControl"><a href="#" onclick="closeWindow(); return( false );"><?php echo translate('Close') ?></a></div>
<div id="menuControls">
<?php
@ -93,10 +99,10 @@ if ( $showPtzControls )
}
?>
<?php
if ( canView( 'Control' ) && $monitor['Type'] == "Local" )
if ( canView( 'Control' ) && $monitor->Type() == "Local" )
{
?>
<div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor['Id'], 'zmSettings'.$monitor['Id'], 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div>
<div id="settingsControl"><?php echo makePopupLink( '?view=settings&amp;mid='.$monitor->Id(), 'zmSettings'.$monitor->Id(), 'settings', translate('Settings'), true, 'id="settingsLink"' ) ?></div>
<?php
}
?>
@ -107,18 +113,18 @@ if ( canView( 'Control' ) && $monitor['Type'] == "Local" )
<?php
if ( $streamMode == "mpeg" )
{
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT, $monitor['Name'] );
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
}
elseif ( $streamMode == "jpeg" )
{
if ( canStreamNative() )
outputImageStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
outputImageStream( "liveStream", $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
elseif ( canStreamApplet() )
outputHelperStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
outputHelperStream( "liveStream", $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
}
else
{
outputImageStill( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
outputImageStill( "liveStream", $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
}
?>
</div>