Merge branch 'storageareas' into zma_to_thread
This commit is contained in:
commit
279e0d8bcf
|
@ -3,7 +3,7 @@ ZoneMinder
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/ZoneMinder/zoneminder.png)](https://travis-ci.org/ZoneMinder/zoneminder) [![Bountysource](https://api.bountysource.com/badge/team?team_id=204&style=bounties_received)](https://www.bountysource.com/teams/zoneminder/issues?utm_source=ZoneMinder&utm_medium=shield&utm_campaign=bounties_received)
|
[![Build Status](https://travis-ci.org/ZoneMinder/zoneminder.png)](https://travis-ci.org/ZoneMinder/zoneminder) [![Bountysource](https://api.bountysource.com/badge/team?team_id=204&style=bounties_received)](https://www.bountysource.com/teams/zoneminder/issues?utm_source=ZoneMinder&utm_medium=shield&utm_campaign=bounties_received)
|
||||||
|
|
||||||
[![Join Slack](https://github.com/ozonesecurity/ozonebase/blob/master/img/slacksm.png?raw=true)](https://zoneminder-chat.herokuapp.com)
|
[![Join Slack](https://github.com/ozonesecurity/ozonebase/blob/master/img/slacksm.png?raw=true)](https://join.slack.com/t/zoneminder-chat/shared_invite/enQtNTU0NDkxMDM5NDQwLTlhZDU2MGU4MmZmN2MxOTg1MmNmNmZjZGRmY2EzMThhNGQ0MWNmZTg1ZmYzNDQ4YjliMzVmYTQ3MDc5MTkzODE)
|
||||||
|
|
||||||
All documentation for ZoneMinder is now online at https://zoneminder.readthedocs.org
|
All documentation for ZoneMinder is now online at https://zoneminder.readthedocs.org
|
||||||
|
|
||||||
|
|
|
@ -790,6 +790,7 @@ INSERT INTO `Controls` VALUES (NULL,'Trendnet','Remote','Trendnet',1,1,1,0,0,0,0
|
||||||
INSERT INTO `Controls` VALUES (NULL,'PSIA','Remote','PSIA',0,0,0,1,0,0,1,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,-100,100,0,0,1,0,0,0,0,1,-100,100,0,0,0,0);
|
INSERT INTO `Controls` VALUES (NULL,'PSIA','Remote','PSIA',0,0,0,1,0,0,1,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,-100,100,0,0,1,0,0,0,0,1,-100,100,0,0,0,0);
|
||||||
INSERT INTO `Controls` VALUES (NULL,'Dahua','Remote','Dahua',0,0,0,1,0,0,1,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,1,8,0,0,1,0,0,0,0,1,1,8,0,0,0,0);
|
INSERT INTO `Controls` VALUES (NULL,'Dahua','Remote','Dahua',0,0,0,1,0,0,1,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,1,8,0,0,1,0,0,0,0,1,1,8,0,0,0,0);
|
||||||
INSERT INTO `Controls` VALUES (NULL,'FOSCAMR2C','Libvlc','FOSCAMR2C',1,1,1,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,1,12,0,1,1,1,0,0,0,1,1,NULL,NULL,NULL,NULL,1,0,4,0,NULL,1,NULL,NULL,NULL,NULL,1,0,4,0,NULL,0,0);
|
INSERT INTO `Controls` VALUES (NULL,'FOSCAMR2C','Libvlc','FOSCAMR2C',1,1,1,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,1,12,0,1,1,1,0,0,0,1,1,NULL,NULL,NULL,NULL,1,0,4,0,NULL,1,NULL,NULL,NULL,NULL,1,0,4,0,NULL,0,0);
|
||||||
|
INSERT INTO `Controls` VALUES (NULL,'Amcrest HTTP API','Ffmpeg','Amcrest_HTTP',0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,5,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,5);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Add some monitor preset values
|
-- Add some monitor preset values
|
||||||
|
|
|
@ -0,0 +1,403 @@
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# ZoneMinder Acrest HTTP API Control Protocol Module, 20180214, Rev 3.0
|
||||||
|
#
|
||||||
|
# Change Log
|
||||||
|
#
|
||||||
|
# Rev 3.0:
|
||||||
|
# - Fixes incorrect method names
|
||||||
|
# - Updates control sequences to Amcrest HTTP Protocol API v 2.12
|
||||||
|
# - Extends control features
|
||||||
|
#
|
||||||
|
# Rev 2.0:
|
||||||
|
# - Fixed installation instructions text, no changes to functionality.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# ==========================================================================
|
||||||
|
|
||||||
|
package ZoneMinder::Control::Amcrest_HTTP;
|
||||||
|
|
||||||
|
use 5.006;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Time::HiRes qw( usleep );
|
||||||
|
|
||||||
|
require ZoneMinder::Base;
|
||||||
|
require ZoneMinder::Control;
|
||||||
|
|
||||||
|
our @ISA = qw(ZoneMinder::Control);
|
||||||
|
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# Amcrest HTTP API Control Protocol
|
||||||
|
#
|
||||||
|
# ==========================================================================
|
||||||
|
|
||||||
|
use ZoneMinder::Logger qw(:all);
|
||||||
|
use ZoneMinder::Config qw(:all);
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $class = shift;
|
||||||
|
my $id = shift;
|
||||||
|
my $self = ZoneMinder::Control->new( $id );
|
||||||
|
bless( $self, $class );
|
||||||
|
srand( time() );
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
our $AUTOLOAD;
|
||||||
|
|
||||||
|
sub AUTOLOAD
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $class = ref($self) || croak( "$self not object" );
|
||||||
|
my $name = $AUTOLOAD;
|
||||||
|
$name =~ s/.*://;
|
||||||
|
Debug( "Received command: $name" );
|
||||||
|
if ( exists($self->{$name}) )
|
||||||
|
{
|
||||||
|
return( $self->{$name} );
|
||||||
|
}
|
||||||
|
Fatal( "Can't access $name member of object of class $class" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub open
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->loadMonitor();
|
||||||
|
$self->{state} = 'open';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub initUA
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $user = undef;
|
||||||
|
my $password = undef;
|
||||||
|
my $address = undef;
|
||||||
|
|
||||||
|
if ( $self->{Monitor}->{ControlAddress} =~ /(.*):(.*)@(.*)/ )
|
||||||
|
{
|
||||||
|
$user = $1;
|
||||||
|
$password = $2;
|
||||||
|
$address = $3;
|
||||||
|
}
|
||||||
|
|
||||||
|
use LWP::UserAgent;
|
||||||
|
$self->{ua} = LWP::UserAgent->new;
|
||||||
|
$self->{ua}->credentials("$address", "Login to " . $self->{Monitor}->{ControlDevice}, "$user", "$password");
|
||||||
|
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub destroyUA
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->{ua} = undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub close
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
$self->{state} = 'closed';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub printMsg
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $msg = shift;
|
||||||
|
my $msg_len = length($msg);
|
||||||
|
|
||||||
|
Debug( $msg."[".$msg_len."]" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub sendCmd
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $cmd = shift;
|
||||||
|
my $result = undef;
|
||||||
|
|
||||||
|
destroyUA($self);
|
||||||
|
initUA($self);
|
||||||
|
|
||||||
|
my $user = undef;
|
||||||
|
my $password = undef;
|
||||||
|
my $address = undef;
|
||||||
|
|
||||||
|
if ( $self->{Monitor}->{ControlAddress} =~ /(.*):(.*)@(.*)/ )
|
||||||
|
{
|
||||||
|
$user = $1;
|
||||||
|
$password = $2;
|
||||||
|
$address = $3;
|
||||||
|
}
|
||||||
|
|
||||||
|
printMsg( $cmd, "Tx" );
|
||||||
|
|
||||||
|
my $req = HTTP::Request->new( GET=>"http://$address/$cmd" );
|
||||||
|
my $res = $self->{ua}->request($req);
|
||||||
|
|
||||||
|
if ( $res->is_success )
|
||||||
|
{
|
||||||
|
$result = !undef;
|
||||||
|
# Command to camera appears successful, write Info item to log
|
||||||
|
Info( "Camera control: '".$res->status_line()."' for URL ".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
||||||
|
# TODO: Add code to retrieve $res->message_decode or some such. Then we could do things like check the camera status.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Error( "Camera control command FAILED: '".$res->status_line()."' for URL ".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( $result );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub reset
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
# This reboots the camera effectively resetting it
|
||||||
|
Debug( "Camera Reset" );
|
||||||
|
$self->sendCmd( 'cgi-bin/magicBox.cgi?action=reboot' );
|
||||||
|
##FIXME: Exit is a bad idea as it appears to cause zmc to run away.
|
||||||
|
#Exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# NOTE: I'm putting this in, but absolute camera movement does not seem to be well supported in the classic skin ATM.
|
||||||
|
# Reading www/skins/classic/include/control_functions.php seems to indicate a faulty implementation, unless I'm
|
||||||
|
# reading it wrong. I see nowhere where the user is able to specify the absolute location to move to. Rather,
|
||||||
|
# the call is passed back movement in increments of 1 unit. At least with the Amcrest/Duhua API this would result
|
||||||
|
# in the camera moving to the 1* or 0* etc. position.
|
||||||
|
|
||||||
|
sub moveAbs ## Up, Down, Left, Right, etc. ??? Doesn't make sense here...
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $pan_degrees = shift || 0;
|
||||||
|
my $tilt_degrees = shift || 0;
|
||||||
|
my $speed = shift || 1;
|
||||||
|
Debug( "Move ABS" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1='.$pan_degress.'&arg2='.$tilt_degrees.'&arg3=0&arg4='.$speed );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConUp
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Up" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=Up&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
usleep (500); ##XXX Should this be passed in as a "speed" parameter?
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=Up&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConDown
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Down" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=Down&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=Down&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Left" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=Left&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=Left&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Right" );
|
||||||
|
# $self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1=270&arg2=5&arg3=0' );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=Right&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
Debug( "Move Right Stop" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=Right&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConUpRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Up Right" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=RightUp&channel=0&arg1=1&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=RightUp&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConDownRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Down Right" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=RightDown&channel=0&arg1=1&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=RightDown&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConUpLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Up Left" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=LeftUp&channel=0&arg1=1&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=LeftUp&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub moveConDownLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Down Left" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=LeftDown&channel=0&arg1=1&arg2=1&arg3=0' );
|
||||||
|
usleep (500);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=LeftDown&channel=0&arg1=0&arg2=1&arg3=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop is not "correctly" implemented as control_functions.php translates this to "Center"
|
||||||
|
# So we'll just send the camera to 0* Horz, 0* Vert, zoom out; Also, Amcrest does not seem to
|
||||||
|
# support a generic stop-all-current-action command.
|
||||||
|
|
||||||
|
sub moveStop
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Stop/Center" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1=0&arg2=0&arg3=0&arg4=1' );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Move Camera to Home Position
|
||||||
|
# The current API does not support a Home per se, so we'll just send the camera to preset #1
|
||||||
|
# NOTE: It goes without saying that the user must have set up preset #1 for this to work.
|
||||||
|
|
||||||
|
sub presetHome
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Home Preset" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=GotoPreset&&arg1=0&arg2=1&arg3=0&arg4=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub presetGoto
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
my $preset = $self->getParam( $params, 'preset' );
|
||||||
|
Debug( "Go To Preset $preset" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=GotoPreset&&arg1=0&arg2='.$preset.'&arg3=0&arg4=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub presetSet
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
my $preset = $self->getParam( $params, 'preset' );
|
||||||
|
Debug( "Set Preset" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=SetPreset&arg1=0&arg2='.$preset.'&arg3=0&arg4=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
# NOTE: This does not appear to be implemented in the classic skin. But we'll leave it here for later.
|
||||||
|
|
||||||
|
sub moveMap
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
|
||||||
|
my $xcoord = $self->getParam( $params, 'xcoord', $self->{Monitor}{Width}/2 );
|
||||||
|
my $ycoord = $self->getParam( $params, 'ycoord', $self->{Monitor}{Height}/2 );
|
||||||
|
# if the camera is mounted upside down, you may have to inverse these coordinates
|
||||||
|
# just use 360 minus pan instead of pan, 90 minus tilt instead of tilt
|
||||||
|
# Convert xcoord into pan position 0 to 359
|
||||||
|
my $pan = int(360 * $xcoord / $self->{Monitor}{Width});
|
||||||
|
# Convert ycoord into tilt position 0 to 89
|
||||||
|
my $tilt = 90 - int(90 * $ycoord / $self->{Monitor}{Height});
|
||||||
|
# Now get the following url:
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1='.$pan.'&arg2='.$tilt.'&arg3=1&arg4=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
sub zoomConTele
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Zoom continuous tele" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=ZoomTele&arg1=0&arg2=0&arg3=0&arg4=0' );
|
||||||
|
usleep (100000);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&channel=0&code=ZoomTele&arg1=0&arg2=0&arg3=0&arg4=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub zoomConWide
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Zoom continuous wide" );
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=ZoomWide&arg1=0&arg2=0&arg3=0&arg4=0' );
|
||||||
|
usleep (100000);
|
||||||
|
$self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&channel=0&code=ZoomWide&arg1=0&arg2=0&arg3=0&arg4=0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
ZoneMinder::Control::Amcrest_HTTP - Amcrest camera control
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This module contains the implementation of the Amcrest Camera
|
||||||
|
controllable SDK API.
|
||||||
|
|
||||||
|
NOTE: This module implements interaction with the camera in clear text.
|
||||||
|
|
||||||
|
The login and password are transmitted from ZM to the camera in clear text,
|
||||||
|
and as such, this module should be used ONLY on a blind LAN implementation
|
||||||
|
where interception of the packets is very low risk.
|
||||||
|
|
||||||
|
The "usleep (X);" lines throughout the script may need adjustments for your
|
||||||
|
situation. This is the time that the script waits between sending a "start"
|
||||||
|
and a "stop" signal to the camera. For example, the pan left arrow would
|
||||||
|
result in the camera panning full to its leftmost position if there were no
|
||||||
|
stop signal. So the usleep time sets how long the script waits to allow the
|
||||||
|
camera to start moving before issuing a stop. The X value of usleep is in
|
||||||
|
microseconds, so "usleep (100000);" is equivalent to wait one second.
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf
|
||||||
|
|
||||||
|
=head1 AUTHORS
|
||||||
|
|
||||||
|
Herndon Elliott alabamatoy at gmail dot com
|
||||||
|
Chris Nighswonger chris dot nighswonger at gmail dot com
|
||||||
|
|
||||||
|
=head1 COPYRIGHT AND LICENSE
|
||||||
|
|
||||||
|
(C) 2016 Herndon Elliott alabamatoy at gmail dot com
|
||||||
|
(C) 2018 Chris Nighswonger chris dot nighswonger at gmail dot com
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
=cut
|
|
@ -57,14 +57,8 @@ Camera::Camera(
|
||||||
imagesize = pixels * colours;
|
imagesize = pixels * colours;
|
||||||
|
|
||||||
Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",
|
Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",
|
||||||
monitor_id,width,height,colours,subpixelorder,capture);
|
monitor_id, width, height, colours, subpixelorder, capture);
|
||||||
|
|
||||||
/* Because many loops are unrolled and work on 16 colours/time or 4 pixels/time, we have to meet requirements */
|
|
||||||
if ( (colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB32) && (imagesize % 64) != 0 ) {
|
|
||||||
Fatal("Image size is not multiples of 64");
|
|
||||||
} else if ( colours == ZM_COLOUR_RGB24 && ((imagesize % 64) != 0 || (imagesize % 12) != 0) ) {
|
|
||||||
Fatal("Image size is not multiples of 12 and 64");
|
|
||||||
}
|
|
||||||
monitor = NULL;
|
monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,30 +242,19 @@ Event::~Event() {
|
||||||
videoStore = NULL;
|
videoStore = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( frame_data.size() )
|
|
||||||
WriteDbFrames();
|
|
||||||
|
|
||||||
// Should not be static because we are multi-threaded
|
|
||||||
char sql[ZM_SQL_MED_BUFSIZ];
|
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2);
|
DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2);
|
||||||
Debug(2, "start_time:%d.%d end_time%d.%d", start_time.tv_sec, start_time.tv_usec, end_time.tv_sec, end_time.tv_usec);
|
Debug(2, "start_time:%d.%d end_time%d.%d", start_time.tv_sec, start_time.tv_usec, end_time.tv_sec, end_time.tv_usec);
|
||||||
|
|
||||||
if ( frames > last_db_frame ) {
|
if ( frames > last_db_frame ) {
|
||||||
Debug(1, "Adding closing frame %d to DB", frames);
|
Debug(1, "Adding closing frame %d to DB", frames);
|
||||||
snprintf(sql, sizeof(sql),
|
frame_data.push(new Frame(id, frames, NORMAL, end_time, delta_time, 0));
|
||||||
"INSERT INTO Frames ( EventId, FrameId, TimeStamp, Delta ) VALUES ( %" PRIu64 ", %d, from_unixtime( %ld ), %s%ld.%02ld )",
|
|
||||||
id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec);
|
|
||||||
db_mutex.lock();
|
|
||||||
if ( mysql_query(&dbconn, sql) ) {
|
|
||||||
db_mutex.unlock();
|
|
||||||
Error("Can't insert frame: %s", mysql_error(&dbconn));
|
|
||||||
} else {
|
|
||||||
db_mutex.unlock();
|
|
||||||
Debug(1,"Success writing last frame");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ( frame_data.size() )
|
||||||
|
WriteDbFrames();
|
||||||
|
|
||||||
|
// Should not be static because we might be multi-threaded
|
||||||
|
char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
snprintf(sql, sizeof(sql),
|
snprintf(sql, sizeof(sql),
|
||||||
"UPDATE Events SET Name='%s %" PRIu64 "', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d, DefaultVideo = '%s' WHERE Id = %" PRIu64,
|
"UPDATE Events SET Name='%s %" PRIu64 "', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d, DefaultVideo = '%s' WHERE Id = %" PRIu64,
|
||||||
monitor->EventPrefix(), id, end_time.tv_sec,
|
monitor->EventPrefix(), id, end_time.tv_sec,
|
||||||
|
@ -537,13 +526,12 @@ void Event::WriteDbFrames() {
|
||||||
*(sql_ptr-2) = '\0';
|
*(sql_ptr-2) = '\0';
|
||||||
db_mutex.lock();
|
db_mutex.lock();
|
||||||
if ( mysql_query(&dbconn, sql) ) {
|
if ( mysql_query(&dbconn, sql) ) {
|
||||||
Error("Can't insert frames: %s", mysql_error(&dbconn));
|
|
||||||
Error("SQL was %s", sql);
|
|
||||||
db_mutex.unlock();
|
db_mutex.unlock();
|
||||||
|
Error("Can't insert frames: %s, sql was %s", mysql_error(&dbconn), sql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
db_mutex.unlock();
|
db_mutex.unlock();
|
||||||
}
|
} // end void Event::WriteDbFrames()
|
||||||
|
|
||||||
void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *alarm_image) {
|
void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *alarm_image) {
|
||||||
if ( !timestamp.tv_sec ) {
|
if ( !timestamp.tv_sec ) {
|
||||||
|
@ -591,10 +579,10 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
|
|
||||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
|
|
||||||
frame_data.push( new Frame(id, frames, frame_type, timestamp, delta_time, score ) );
|
frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score));
|
||||||
if ( frame_data.size() > 10 ) {
|
if ( frame_data.size() > 20 ) {
|
||||||
WriteDbFrames();
|
WriteDbFrames();
|
||||||
Debug(1, "Adding 10 frames to DB");
|
Debug(1, "Adding 20 frames to DB");
|
||||||
last_db_frame = frames;
|
last_db_frame = frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
425
src/zm_image.cpp
425
src/zm_image.cpp
|
@ -75,6 +75,32 @@ static deinterlace_4field_fptr_t fptr_deinterlace_4field_gray8;
|
||||||
/* Pointer to image buffer memory copy function */
|
/* Pointer to image buffer memory copy function */
|
||||||
imgbufcpy_fptr_t fptr_imgbufcpy;
|
imgbufcpy_fptr_t fptr_imgbufcpy;
|
||||||
|
|
||||||
|
void Image::update_function_pointers() {
|
||||||
|
/* Because many loops are unrolled and work on 16 colours/time or 4 pixels/time, we have to meet requirements */
|
||||||
|
if ( pixels % 16 || pixels % 12 ) {
|
||||||
|
// have to use non-loop unrolled functions
|
||||||
|
delta8_rgb = &std_delta8_rgb;
|
||||||
|
delta8_bgr = &std_delta8_bgr;
|
||||||
|
delta8_rgba = &std_delta8_rgba;
|
||||||
|
delta8_bgra = &std_delta8_bgra;
|
||||||
|
delta8_argb = &std_delta8_argb;
|
||||||
|
delta8_abgr = &std_delta8_abgr;
|
||||||
|
delta8_gray8 = &std_delta8_gray8;
|
||||||
|
blend = &std_blend;
|
||||||
|
} else {
|
||||||
|
// Use either sse or neon, or loop unrolled version
|
||||||
|
delta8_rgb = fptr_delta8_rgb;
|
||||||
|
delta8_bgr = fptr_delta8_bgr;
|
||||||
|
delta8_rgba = fptr_delta8_rgba;
|
||||||
|
delta8_bgra = fptr_delta8_bgra;
|
||||||
|
delta8_argb = fptr_delta8_argb;
|
||||||
|
delta8_abgr = fptr_delta8_abgr;
|
||||||
|
delta8_gray8 = fptr_delta8_gray8;
|
||||||
|
blend = fptr_blend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This constructor is not used anywhere
|
||||||
Image::Image() {
|
Image::Image() {
|
||||||
if ( !initialised )
|
if ( !initialised )
|
||||||
Initialise();
|
Initialise();
|
||||||
|
@ -89,6 +115,7 @@ Image::Image() {
|
||||||
buffertype = 0;
|
buffertype = 0;
|
||||||
holdbuffer = 0;
|
holdbuffer = 0;
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
|
blend = fptr_blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image( const char *filename ) {
|
Image::Image( const char *filename ) {
|
||||||
|
@ -104,8 +131,9 @@ Image::Image( const char *filename ) {
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
buffertype = 0;
|
buffertype = 0;
|
||||||
holdbuffer = 0;
|
holdbuffer = 0;
|
||||||
ReadJpeg( filename, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB);
|
ReadJpeg(filename, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB);
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
|
update_function_pointers();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer ) {
|
Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer ) {
|
||||||
|
@ -127,6 +155,8 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin
|
||||||
AllocImgBuffer(size);
|
AllocImgBuffer(size);
|
||||||
}
|
}
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
|
|
||||||
|
update_function_pointers();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image( const AVFrame *frame ) {
|
Image::Image( const AVFrame *frame ) {
|
||||||
|
@ -176,6 +206,7 @@ void Image::Assign( const AVFrame *frame ) {
|
||||||
av_frame_free( &dest_frame );
|
av_frame_free( &dest_frame );
|
||||||
sws_freeContext(mConvertContext);
|
sws_freeContext(mConvertContext);
|
||||||
mConvertContext = NULL;
|
mConvertContext = NULL;
|
||||||
|
update_function_pointers();
|
||||||
} // end Image::Image( const AVFrame *frame )
|
} // end Image::Image( const AVFrame *frame )
|
||||||
|
|
||||||
Image::Image( const Image &p_image ) {
|
Image::Image( const Image &p_image ) {
|
||||||
|
@ -192,6 +223,7 @@ Image::Image( const Image &p_image ) {
|
||||||
AllocImgBuffer(size);
|
AllocImgBuffer(size);
|
||||||
(*fptr_imgbufcpy)(buffer, p_image.buffer, size);
|
(*fptr_imgbufcpy)(buffer, p_image.buffer, size);
|
||||||
strncpy( text, p_image.text, sizeof(text) );
|
strncpy( text, p_image.text, sizeof(text) );
|
||||||
|
update_function_pointers();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::~Image() {
|
Image::~Image() {
|
||||||
|
@ -327,20 +359,20 @@ void Image::Initialise() {
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* No suitable SSE version available */
|
/* No suitable SSE version available */
|
||||||
fptr_delta8_rgba = &std_delta8_rgba;
|
fptr_delta8_rgba = &fast_delta8_rgba;
|
||||||
fptr_delta8_bgra = &std_delta8_bgra;
|
fptr_delta8_bgra = &fast_delta8_bgra;
|
||||||
fptr_delta8_argb = &std_delta8_argb;
|
fptr_delta8_argb = &fast_delta8_argb;
|
||||||
fptr_delta8_abgr = &std_delta8_abgr;
|
fptr_delta8_abgr = &fast_delta8_abgr;
|
||||||
fptr_delta8_gray8 = &std_delta8_gray8;
|
fptr_delta8_gray8 = &fast_delta8_gray8;
|
||||||
Debug(4,"Delta: Using standard delta functions");
|
Debug(4,"Delta: Using standard delta functions");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* CPU extensions disabled */
|
/* CPU extensions disabled */
|
||||||
fptr_delta8_rgba = &std_delta8_rgba;
|
fptr_delta8_rgba = &fast_delta8_rgba;
|
||||||
fptr_delta8_bgra = &std_delta8_bgra;
|
fptr_delta8_bgra = &fast_delta8_bgra;
|
||||||
fptr_delta8_argb = &std_delta8_argb;
|
fptr_delta8_argb = &fast_delta8_argb;
|
||||||
fptr_delta8_abgr = &std_delta8_abgr;
|
fptr_delta8_abgr = &fast_delta8_abgr;
|
||||||
fptr_delta8_gray8 = &std_delta8_gray8;
|
fptr_delta8_gray8 = &fast_delta8_gray8;
|
||||||
Debug(4,"Delta: CPU extensions disabled, using standard delta functions");
|
Debug(4,"Delta: CPU extensions disabled, using standard delta functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1604,7 +1636,7 @@ void Image::Blend( const Image &image, int transparency ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Do the blending */
|
/* Do the blending */
|
||||||
(*fptr_blend)(buffer, image.buffer, new_buffer, size, transparency);
|
(*blend)(buffer, image.buffer, new_buffer, size, transparency);
|
||||||
|
|
||||||
#ifdef ZM_IMAGE_PROFILING
|
#ifdef ZM_IMAGE_PROFILING
|
||||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&end);
|
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&end);
|
||||||
|
@ -1631,7 +1663,7 @@ Image *Image::Merge( unsigned int n_images, Image *images[] ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image *result = new Image( width, height, images[0]->colours, images[0]->subpixelorder);
|
Image *result = new Image(width, height, images[0]->colours, images[0]->subpixelorder);
|
||||||
unsigned int size = result->size;
|
unsigned int size = result->size;
|
||||||
for ( unsigned int i = 0; i < size; i++ ) {
|
for ( unsigned int i = 0; i < size; i++ ) {
|
||||||
unsigned int total = 0;
|
unsigned int total = 0;
|
||||||
|
@ -1737,37 +1769,33 @@ void Image::Delta( const Image &image, Image* targetimage) const {
|
||||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&start);
|
clock_gettime(CLOCK_THREAD_CPUTIME_ID,&start);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(colours) {
|
switch (colours) {
|
||||||
case ZM_COLOUR_RGB24:
|
case ZM_COLOUR_RGB24:
|
||||||
{
|
if ( subpixelorder == ZM_SUBPIX_ORDER_BGR ) {
|
||||||
if(subpixelorder == ZM_SUBPIX_ORDER_BGR) {
|
/* BGR subpixel order */
|
||||||
/* BGR subpixel order */
|
(*delta8_bgr)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_bgr)(buffer, image.buffer, pdiff, pixels);
|
} else {
|
||||||
} else {
|
/* Assume RGB subpixel order */
|
||||||
/* Assume RGB subpixel order */
|
(*delta8_rgb)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_rgb)(buffer, image.buffer, pdiff, pixels);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ZM_COLOUR_RGB32:
|
case ZM_COLOUR_RGB32:
|
||||||
{
|
if ( subpixelorder == ZM_SUBPIX_ORDER_ARGB ) {
|
||||||
if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) {
|
/* ARGB subpixel order */
|
||||||
/* ARGB subpixel order */
|
(*delta8_argb)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_argb)(buffer, image.buffer, pdiff, pixels);
|
} else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) {
|
||||||
} else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) {
|
/* ABGR subpixel order */
|
||||||
/* ABGR subpixel order */
|
(*delta8_abgr)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_abgr)(buffer, image.buffer, pdiff, pixels);
|
} else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) {
|
||||||
} else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) {
|
/* BGRA subpixel order */
|
||||||
/* BGRA subpixel order */
|
(*delta8_bgra)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_bgra)(buffer, image.buffer, pdiff, pixels);
|
} else {
|
||||||
} else {
|
/* Assume RGBA subpixel order */
|
||||||
/* Assume RGBA subpixel order */
|
(*delta8_rgba)(buffer, image.buffer, pdiff, pixels);
|
||||||
(*fptr_delta8_rgba)(buffer, image.buffer, pdiff, pixels);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ZM_COLOUR_GRAY8:
|
case ZM_COLOUR_GRAY8:
|
||||||
(*fptr_delta8_gray8)(buffer, image.buffer, pdiff, pixels);
|
(*delta8_gray8)(buffer, image.buffer, pdiff, pixels);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Panic("Delta called with unexpected colours: %d",colours);
|
Panic("Delta called with unexpected colours: %d",colours);
|
||||||
|
@ -1780,7 +1808,7 @@ void Image::Delta( const Image &image, Image* targetimage) const {
|
||||||
|
|
||||||
executetime = (1000000000ull * diff.tv_sec) + diff.tv_nsec;
|
executetime = (1000000000ull * diff.tv_sec) + diff.tv_nsec;
|
||||||
milpixels = (unsigned long)((long double)pixels)/((((long double)executetime)/1000));
|
milpixels = (unsigned long)((long double)pixels)/((((long double)executetime)/1000));
|
||||||
Debug(5, "Delta: %u delta pixels generated in %llu nanoseconds, %lu million pixels/s\n",pixels,executetime,milpixels);
|
Debug(5, "Delta: %u delta pixels generated in %llu nanoseconds, %lu million pixels/s",pixels,executetime,milpixels);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2069,9 +2097,9 @@ void Image::DeColourise() {
|
||||||
subpixelorder = ZM_SUBPIX_ORDER_NONE;
|
subpixelorder = ZM_SUBPIX_ORDER_NONE;
|
||||||
size = width * height;
|
size = width * height;
|
||||||
|
|
||||||
if(colours == ZM_COLOUR_RGB32 && config.cpu_extensions && sseversion >= 35) {
|
if ( colours == ZM_COLOUR_RGB32 && config.cpu_extensions && sseversion >= 35 ) {
|
||||||
/* Use SSSE3 functions */
|
/* Use SSSE3 functions */
|
||||||
switch(subpixelorder) {
|
switch (subpixelorder) {
|
||||||
case ZM_SUBPIX_ORDER_BGRA:
|
case ZM_SUBPIX_ORDER_BGRA:
|
||||||
ssse3_convert_bgra_gray8(buffer,buffer,pixels);
|
ssse3_convert_bgra_gray8(buffer,buffer,pixels);
|
||||||
break;
|
break;
|
||||||
|
@ -2089,32 +2117,62 @@ void Image::DeColourise() {
|
||||||
} else {
|
} else {
|
||||||
/* Use standard functions */
|
/* Use standard functions */
|
||||||
if ( colours == ZM_COLOUR_RGB32 ) {
|
if ( colours == ZM_COLOUR_RGB32 ) {
|
||||||
switch(subpixelorder) {
|
if ( pixels % 16 ) {
|
||||||
case ZM_SUBPIX_ORDER_BGRA:
|
switch (subpixelorder) {
|
||||||
std_convert_bgra_gray8(buffer,buffer,pixels);
|
case ZM_SUBPIX_ORDER_BGRA:
|
||||||
break;
|
std_convert_bgra_gray8(buffer,buffer,pixels);
|
||||||
case ZM_SUBPIX_ORDER_ARGB:
|
break;
|
||||||
std_convert_argb_gray8(buffer,buffer,pixels);
|
case ZM_SUBPIX_ORDER_ARGB:
|
||||||
break;
|
std_convert_argb_gray8(buffer,buffer,pixels);
|
||||||
case ZM_SUBPIX_ORDER_ABGR:
|
break;
|
||||||
std_convert_abgr_gray8(buffer,buffer,pixels);
|
case ZM_SUBPIX_ORDER_ABGR:
|
||||||
break;
|
std_convert_abgr_gray8(buffer,buffer,pixels);
|
||||||
case ZM_SUBPIX_ORDER_RGBA:
|
break;
|
||||||
default:
|
case ZM_SUBPIX_ORDER_RGBA:
|
||||||
std_convert_rgba_gray8(buffer,buffer,pixels);
|
default:
|
||||||
break;
|
std_convert_rgba_gray8(buffer,buffer,pixels);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (subpixelorder) {
|
||||||
|
case ZM_SUBPIX_ORDER_BGRA:
|
||||||
|
fast_convert_bgra_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
case ZM_SUBPIX_ORDER_ARGB:
|
||||||
|
fast_convert_argb_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
case ZM_SUBPIX_ORDER_ABGR:
|
||||||
|
fast_convert_abgr_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
case ZM_SUBPIX_ORDER_RGBA:
|
||||||
|
default:
|
||||||
|
fast_convert_rgba_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // end if pixels % 16 to use loop unrolled functions
|
||||||
} else {
|
} else {
|
||||||
/* Assume RGB24 */
|
/* Assume RGB24 */
|
||||||
switch(subpixelorder) {
|
if ( pixels % 12 ) {
|
||||||
case ZM_SUBPIX_ORDER_BGR:
|
switch (subpixelorder) {
|
||||||
std_convert_bgr_gray8(buffer,buffer,pixels);
|
case ZM_SUBPIX_ORDER_BGR:
|
||||||
break;
|
std_convert_bgr_gray8(buffer,buffer,pixels);
|
||||||
case ZM_SUBPIX_ORDER_RGB:
|
break;
|
||||||
default:
|
case ZM_SUBPIX_ORDER_RGB:
|
||||||
std_convert_rgb_gray8(buffer,buffer,pixels);
|
default:
|
||||||
break;
|
std_convert_rgb_gray8(buffer,buffer,pixels);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (subpixelorder) {
|
||||||
|
case ZM_SUBPIX_ORDER_BGR:
|
||||||
|
fast_convert_bgr_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
case ZM_SUBPIX_ORDER_RGB:
|
||||||
|
default:
|
||||||
|
fast_convert_rgb_gray8(buffer,buffer,pixels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // end if pixels % 12 to use loop unrolled functions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2122,7 +2180,7 @@ void Image::DeColourise() {
|
||||||
/* RGB32 compatible: complete */
|
/* RGB32 compatible: complete */
|
||||||
void Image::Fill( Rgb colour, const Box *limits ) {
|
void Image::Fill( Rgb colour, const Box *limits ) {
|
||||||
if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) {
|
if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) {
|
||||||
Panic( "Attempt to fill image with unexpected colours %d", colours );
|
Panic("Attempt to fill image with unexpected colours %d", colours);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the colour's RGBA subpixel order into the image's subpixel order */
|
/* Convert the colour's RGBA subpixel order into the image's subpixel order */
|
||||||
|
@ -3279,7 +3337,7 @@ __attribute__((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col
|
||||||
/************************************************* DELTA FUNCTIONS *************************************************/
|
/************************************************* DELTA FUNCTIONS *************************************************/
|
||||||
|
|
||||||
/* Grayscale */
|
/* Grayscale */
|
||||||
__attribute__((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */
|
/* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -3307,8 +3365,20 @@ __attribute__((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
result[0] = abs(col1[0] - col2[0]);
|
||||||
|
|
||||||
|
col1 += 1;
|
||||||
|
col2 += 1;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB24: RGB */
|
/* RGB24: RGB */
|
||||||
__attribute__((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3337,8 +3407,25 @@ __attribute__((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while (result < max_ptr) {
|
||||||
|
r = abs(col1[0] - col2[0]);
|
||||||
|
g = abs(col1[1] - col2[1]);
|
||||||
|
b = abs(col1[2] - col2[2]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 3;
|
||||||
|
col2 += 3;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB24: BGR */
|
/* RGB24: BGR */
|
||||||
__attribute__((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3367,8 +3454,25 @@ __attribute__((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
/* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = abs(col1[0] - col2[0]);
|
||||||
|
g = abs(col1[1] - col2[1]);
|
||||||
|
r = abs(col1[2] - col2[2]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 3;
|
||||||
|
col2 += 3;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB32: RGBA */
|
/* RGB32: RGBA */
|
||||||
__attribute__((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3397,8 +3501,25 @@ __attribute__((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
r = abs(col1[0] - col2[0]);
|
||||||
|
g = abs(col1[1] - col2[1]);
|
||||||
|
b = abs(col1[2] - col2[2]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
col2 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB32: BGRA */
|
/* RGB32: BGRA */
|
||||||
__attribute__((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3426,9 +3547,25 @@ __attribute__((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = abs(col1[0] - col2[0]);
|
||||||
|
g = abs(col1[1] - col2[1]);
|
||||||
|
r = abs(col1[2] - col2[2]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
col2 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB32: ARGB */
|
/* RGB32: ARGB */
|
||||||
__attribute__((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3456,9 +3593,25 @@ __attribute__((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
r = abs(col1[1] - col2[1]);
|
||||||
|
g = abs(col1[2] - col2[2]);
|
||||||
|
b = abs(col1[3] - col2[3]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
col2 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB32: ABGR */
|
/* RGB32: ABGR */
|
||||||
__attribute__((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
/* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
@ -3486,6 +3639,21 @@ __attribute__((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) {
|
||||||
|
int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = abs(col1[1] - col2[1]);
|
||||||
|
g = abs(col1[2] - col2[2]);
|
||||||
|
r = abs(col1[3] - col2[3]);
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
col2 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Grayscale Neon for AArch32 */
|
/* Grayscale Neon for AArch32 */
|
||||||
#if (defined(__arm__) && defined(__ARM_PCS_VFP) && !defined(ZM_STRIP_NEON))
|
#if (defined(__arm__) && defined(__ARM_PCS_VFP) && !defined(ZM_STRIP_NEON))
|
||||||
|
@ -4054,7 +4222,7 @@ void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result
|
||||||
/************************************************* CONVERT FUNCTIONS *************************************************/
|
/************************************************* CONVERT FUNCTIONS *************************************************/
|
||||||
|
|
||||||
/* RGB24 to grayscale */
|
/* RGB24 to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4080,9 +4248,23 @@ __attribute__((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
r = col1[0];
|
||||||
|
g = col1[1];
|
||||||
|
b = col1[2];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 3;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* BGR24 to grayscale */
|
/* BGR24 to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4108,9 +4290,23 @@ __attribute__((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = col1[0];
|
||||||
|
g = col1[1];
|
||||||
|
r = col1[2];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 3;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGBA to grayscale */
|
/* RGBA to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4136,9 +4332,23 @@ __attribute__((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
r = col1[0];
|
||||||
|
g = col1[1];
|
||||||
|
b = col1[2];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* BGRA to grayscale */
|
/* BGRA to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4165,8 +4375,22 @@ __attribute__((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = col1[0];
|
||||||
|
g = col1[1];
|
||||||
|
r = col1[2];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* ARGB to grayscale */
|
/* ARGB to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4192,9 +4416,23 @@ __attribute__((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
r = col1[1];
|
||||||
|
g = col1[2];
|
||||||
|
b = col1[3];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ABGR to grayscale */
|
/* ABGR to grayscale */
|
||||||
__attribute__((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
unsigned int r,g,b;
|
unsigned int r,g,b;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4220,9 +4458,23 @@ __attribute__((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8
|
||||||
result += 4;
|
result += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
unsigned int r,g,b;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
b = col1[1];
|
||||||
|
g = col1[2];
|
||||||
|
r = col1[3];
|
||||||
|
result[0] = (r + r + b + g + g + g + g + g)>>3;
|
||||||
|
|
||||||
|
col1 += 4;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Converts a YUYV image into grayscale by extracting the Y channel */
|
/* Converts a YUYV image into grayscale by extracting the Y channel */
|
||||||
__attribute__((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
__attribute__((noinline)) void fast_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
const uint16_t* yuvbuf = (const uint16_t*)col1;
|
const uint16_t* yuvbuf = (const uint16_t*)col1;
|
||||||
const uint8_t* const max_ptr = result + count;
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
@ -4248,6 +4500,17 @@ __attribute__((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8
|
||||||
result += 16;
|
result += 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__attribute__((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) {
|
||||||
|
const uint16_t* yuvbuf = (const uint16_t*)col1;
|
||||||
|
const uint8_t* const max_ptr = result + count;
|
||||||
|
|
||||||
|
while(result < max_ptr) {
|
||||||
|
result[0] = (uint8_t)yuvbuf[0];
|
||||||
|
|
||||||
|
yuvbuf += 1;
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* RGB32 to grayscale SSSE3 */
|
/* RGB32 to grayscale SSSE3 */
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
|
|
@ -86,6 +86,19 @@ inline static void DumpBuffer(uint8_t* buffer, int buffertype) {
|
||||||
// camera in raw form.
|
// camera in raw form.
|
||||||
//
|
//
|
||||||
class Image {
|
class Image {
|
||||||
|
private:
|
||||||
|
delta_fptr_t delta8_rgb;
|
||||||
|
delta_fptr_t delta8_bgr;
|
||||||
|
delta_fptr_t delta8_rgba;
|
||||||
|
delta_fptr_t delta8_bgra;
|
||||||
|
delta_fptr_t delta8_argb;
|
||||||
|
delta_fptr_t delta8_abgr;
|
||||||
|
delta_fptr_t delta8_gray8;
|
||||||
|
|
||||||
|
// Per object function pointer that we can set once we know the image dimensions
|
||||||
|
blend_fptr_t blend;
|
||||||
|
|
||||||
|
void update_function_pointers();
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct Edge {
|
struct Edge {
|
||||||
|
@ -297,6 +310,14 @@ void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result,
|
||||||
void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
|
||||||
|
void fast_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void fast_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
|
||||||
void neon32_armv7_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void neon32_armv7_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void neon32_armv7_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void neon32_armv7_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void neon32_armv7_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void neon32_armv7_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
@ -325,6 +346,15 @@ void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long
|
||||||
void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
|
||||||
|
void fast_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void fast_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
|
||||||
void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void ssse3_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void ssse3_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void ssse3_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void ssse3_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
|
|
@ -124,7 +124,11 @@ PPA="";
|
||||||
if [ "$RELEASE" != "" ]; then
|
if [ "$RELEASE" != "" ]; then
|
||||||
# We need to use our official tarball for the original source, so grab it and overwrite our generated one.
|
# We need to use our official tarball for the original source, so grab it and overwrite our generated one.
|
||||||
IFS='.' read -r -a VERSION <<< "$RELEASE"
|
IFS='.' read -r -a VERSION <<< "$RELEASE"
|
||||||
PPA="ppa:iconnor/zoneminder-${VERSION[0]}.${VERSION[1]}"
|
if [ "${VERSION[0]}.${VERSION[1]}" == "1.30" ]; then
|
||||||
|
PPA="ppa:iconnor/zoneminder-stable"
|
||||||
|
else
|
||||||
|
PPA="ppa:iconnor/zoneminder-${VERSION[0]}.${VERSION[1]}"
|
||||||
|
fi;
|
||||||
else
|
else
|
||||||
if [ "$BRANCH" == "" ]; then
|
if [ "$BRANCH" == "" ]; then
|
||||||
PPA="ppa:iconnor/zoneminder-master";
|
PPA="ppa:iconnor/zoneminder-master";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
|
||||||
$defaultMonitor = new Monitor();
|
$defaultMonitor = new ZM\Monitor();
|
||||||
$defaultMonitor->set(array(
|
$defaultMonitor->set(array(
|
||||||
'StorageId' => 1,
|
'StorageId' => 1,
|
||||||
'ServerId' => 'auto',
|
'ServerId' => 'auto',
|
||||||
|
@ -27,11 +27,11 @@ function probe( &$url_bits ) {
|
||||||
|
|
||||||
$cam_list_html = file_get_contents('http://'.$url_bits['host'].':5000/monitoring/');
|
$cam_list_html = file_get_contents('http://'.$url_bits['host'].':5000/monitoring/');
|
||||||
if ( $cam_list_html ) {
|
if ( $cam_list_html ) {
|
||||||
Logger::Debug("Have content at port 5000/monitoring");
|
ZM\Logger::Debug("Have content at port 5000/monitoring");
|
||||||
$matches_count = preg_match_all(
|
$matches_count = preg_match_all(
|
||||||
'/<a href="http:\/\/([.[:digit:]]+):([[:digit:]]+)\/\?action=stream" target="_blank">([^<]+)<\/a>/',
|
'/<a href="http:\/\/([.[:digit:]]+):([[:digit:]]+)\/\?action=stream" target="_blank">([^<]+)<\/a>/',
|
||||||
$cam_list_html, $cam_list );
|
$cam_list_html, $cam_list );
|
||||||
Logger::Debug(print_r($cam_list,true));
|
ZM\Logger::Debug(print_r($cam_list,true));
|
||||||
}
|
}
|
||||||
if ( $matches_count ) {
|
if ( $matches_count ) {
|
||||||
for( $index = 0; $index < $matches_count; $index ++ ) {
|
for( $index = 0; $index < $matches_count; $index ++ ) {
|
||||||
|
@ -41,10 +41,10 @@ function probe( &$url_bits ) {
|
||||||
if ( ! isset($new_stream['scheme'] ) )
|
if ( ! isset($new_stream['scheme'] ) )
|
||||||
$new_stream['scheme'] = 'http';
|
$new_stream['scheme'] = 'http';
|
||||||
$available_streams[] = $new_stream;
|
$available_streams[] = $new_stream;
|
||||||
Logger::Debug("Have new stream " . print_r($new_stream,true) );
|
ZM\Logger::Debug("Have new stream " . print_r($new_stream,true) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Info('No matches');
|
ZM\Info('No matches');
|
||||||
}
|
}
|
||||||
if ( 0 ) {
|
if ( 0 ) {
|
||||||
// No port given, do a port scan
|
// No port given, do a port scan
|
||||||
|
@ -65,7 +65,7 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
|
||||||
$new_stream['port'] = $port;
|
$new_stream['port'] = $port;
|
||||||
} else {
|
} else {
|
||||||
socket_close($socket);
|
socket_close($socket);
|
||||||
Info("No connection to ".$url_bits['host'] . " on port $port");
|
ZM\Info("No connection to ".$url_bits['host'] . " on port $port");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( $new_stream ) {
|
if ( $new_stream ) {
|
||||||
|
@ -73,7 +73,7 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
|
||||||
$new_stream['scheme'] = 'http';
|
$new_stream['scheme'] = 'http';
|
||||||
$url = unparse_url($new_stream, array('path'=>'/', 'query'=>'action=snapshot'));
|
$url = unparse_url($new_stream, array('path'=>'/', 'query'=>'action=snapshot'));
|
||||||
list($width, $height, $type, $attr) = getimagesize( $url );
|
list($width, $height, $type, $attr) = getimagesize( $url );
|
||||||
Info("Got $width x $height from $url");
|
ZM\Info("Got $width x $height from $url");
|
||||||
$new_stream['Width'] = $width;
|
$new_stream['Width'] = $width;
|
||||||
$new_stream['Height'] = $height;
|
$new_stream['Height'] = $height;
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ Info("Testing connection to " . $url_bits['host'].':'.$port);
|
||||||
foreach ( $available_streams as &$stream ) {
|
foreach ( $available_streams as &$stream ) {
|
||||||
# check for existence in db.
|
# check for existence in db.
|
||||||
$stream['url'] = unparse_url( $stream, array('path'=>'/','query'=>'action=stream') );
|
$stream['url'] = unparse_url( $stream, array('path'=>'/','query'=>'action=stream') );
|
||||||
$monitors = Monitor::find( array('Path'=>$stream['url']) );
|
$monitors = ZM\Monitor::find( array('Path'=>$stream['url']) );
|
||||||
if ( count($monitors) ) {
|
if ( count($monitors) ) {
|
||||||
Info("Found monitors matching " . $stream['url'] );
|
ZM\Info("Found monitors matching " . $stream['url'] );
|
||||||
$stream['Monitor'] = $monitors[0];
|
$stream['Monitor'] = $monitors[0];
|
||||||
if ( isset( $stream['Width'] ) and ( $stream['Monitor']->Width() != $stream['Width'] ) ) {
|
if ( isset( $stream['Width'] ) and ( $stream['Monitor']->Width() != $stream['Width'] ) ) {
|
||||||
$stream['Warning'] .= 'Monitor width ('.$stream['Monitor']->Width().') and stream width ('.$stream['Width'].") do not match!\n";
|
$stream['Warning'] .= 'Monitor width ('.$stream['Monitor']->Width().') and stream width ('.$stream['Width'].") do not match!\n";
|
||||||
|
@ -143,9 +143,9 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
|
|
||||||
if ( 0 ) {
|
if ( 0 ) {
|
||||||
// Shortcut test
|
// Shortcut test
|
||||||
$monitors = Monitor::find( array('Path'=>$_REQUEST['url']) );
|
$monitors = ZM\Monitor::find( array('Path'=>$_REQUEST['url']) );
|
||||||
if ( count( $monitors ) ) {
|
if ( count( $monitors ) ) {
|
||||||
Info("Monitor found for " . $_REQUEST['url']);
|
ZM\Info("Monitor found for " . $_REQUEST['url']);
|
||||||
$url_bits['url'] = $_REQUEST['url'];
|
$url_bits['url'] = $_REQUEST['url'];
|
||||||
$url_bits['Monitor'] = $monitors[0];
|
$url_bits['Monitor'] = $monitors[0];
|
||||||
$available_stream[] = $url_bits;
|
$available_stream[] = $url_bits;
|
||||||
|
@ -182,7 +182,7 @@ if ( 0 ) {
|
||||||
$name = $data[0];
|
$name = $data[0];
|
||||||
$url = $data[1];
|
$url = $data[1];
|
||||||
$group = $data[2];
|
$group = $data[2];
|
||||||
Info("Have the following line data $name $url $group");
|
ZM\Info("Have the following line data $name $url $group");
|
||||||
|
|
||||||
$url_bits = null;
|
$url_bits = null;
|
||||||
if ( preg_match('/(\d+)\.(\d+)\.(\d+)\.(\d+)/', $url) ) {
|
if ( preg_match('/(\d+)\.(\d+)\.(\d+)\.(\d+)/', $url) ) {
|
||||||
|
@ -191,7 +191,7 @@ if ( 0 ) {
|
||||||
$url_bits = parse_url( $url );
|
$url_bits = parse_url( $url );
|
||||||
}
|
}
|
||||||
if ( ! $url_bits ) {
|
if ( ! $url_bits ) {
|
||||||
Info("Bad url, skipping line $name $url $group");
|
ZM\Info("Bad url, skipping line $name $url $group");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +215,11 @@ if ( 0 ) {
|
||||||
} // end case import
|
} // end case import
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Warning("unknown action " . $_REQUEST['action'] );
|
ZM\Warning("unknown action " . $_REQUEST['action'] );
|
||||||
} // end ddcase default
|
} // end ddcase default
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Warning("Cannot edit monitors" );
|
ZM\Warning("Cannot edit monitors" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxError( 'Unrecognised action or insufficient permissions' );
|
ajaxError( 'Unrecognised action or insufficient permissions' );
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
define("MSG_TIMEOUT", 2.0);
|
define('MSG_TIMEOUT', 2.0);
|
||||||
define("MSG_DATA_SIZE", 4+256);
|
define('MSG_DATA_SIZE', 4+256);
|
||||||
|
|
||||||
if ( canEdit('Monitors') ) {
|
if ( canEdit('Monitors') ) {
|
||||||
$zmuCommand = getZmuCommand(' -m '.validInt($_REQUEST['id']));
|
$zmuCommand = getZmuCommand(' -m '.validInt($_REQUEST['id']));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
if ( canEdit('Monitors') ) {
|
||||||
if ( canEdit( 'Monitors' ) ) {
|
|
||||||
switch ( $_REQUEST['action'] ) {
|
switch ( $_REQUEST['action'] ) {
|
||||||
case 'sort' :
|
case 'sort' :
|
||||||
{
|
{
|
||||||
|
@ -8,15 +7,15 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
# Two concurrent sorts could generate odd sortings... so lock the table.
|
# Two concurrent sorts could generate odd sortings... so lock the table.
|
||||||
global $dbConn;
|
global $dbConn;
|
||||||
$dbConn->beginTransaction();
|
$dbConn->beginTransaction();
|
||||||
$dbConn->exec( 'LOCK TABLES Monitors WRITE' );
|
$dbConn->exec('LOCK TABLES Monitors WRITE');
|
||||||
for ( $i = 0; $i < count($monitor_ids); $i += 1 ) {
|
for ( $i = 0; $i < count($monitor_ids); $i += 1 ) {
|
||||||
$monitor_id = $monitor_ids[$i];
|
$monitor_id = $monitor_ids[$i];
|
||||||
$monitor_id = preg_replace( '/^monitor_id-/', '', $monitor_id );
|
$monitor_id = preg_replace( '/^monitor_id-/', '', $monitor_id );
|
||||||
if ( ( ! $monitor_id ) or ! ( is_integer( $monitor_id ) or ctype_digit( $monitor_id ) ) ) {
|
if ( ( ! $monitor_id ) or ! ( is_integer( $monitor_id ) or ctype_digit( $monitor_id ) ) ) {
|
||||||
Warning( "Got $monitor_id from " . $monitor_ids[$i] );
|
Warning("Got $monitor_id from " . $monitor_ids[$i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dbQuery( 'UPDATE Monitors SET Sequence=? WHERE Id=?', array( $i, $monitor_id ) );
|
dbQuery('UPDATE Monitors SET Sequence=? WHERE Id=?', array($i, $monitor_id));
|
||||||
} // end for each monitor_id
|
} // end for each monitor_id
|
||||||
$dbConn->commit();
|
$dbConn->commit();
|
||||||
$dbConn->exec('UNLOCK TABLES');
|
$dbConn->exec('UNLOCK TABLES');
|
||||||
|
@ -25,13 +24,12 @@ if ( canEdit( 'Monitors' ) ) {
|
||||||
} // end case sort
|
} // end case sort
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Warning("unknown action " . $_REQUEST['action'] );
|
ZM\Warning('unknown action ' . $_REQUEST['action']);
|
||||||
} // end ddcase default
|
} // end ddcase default
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Warning("Cannot edit monitors" );
|
ZM\Warning('Cannot edit monitors');
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxError( 'Unrecognised action or insufficient permissions' );
|
ajaxError('Unrecognised action or insufficient permissions');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -8,7 +8,7 @@ if ( empty($_REQUEST['id']) )
|
||||||
|
|
||||||
if ( canView( 'Control', $_REQUEST['id'] ) )
|
if ( canView( 'Control', $_REQUEST['id'] ) )
|
||||||
{
|
{
|
||||||
$monitor = new Monitor( $_REQUEST['id'] );
|
$monitor = new ZM\Monitor( $_REQUEST['id'] );
|
||||||
|
|
||||||
$ctrlCommand = buildControlCommand( $monitor );
|
$ctrlCommand = buildControlCommand( $monitor );
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
{
|
{
|
||||||
// Silently ignore bogus requests
|
// Silently ignore bogus requests
|
||||||
if ( !empty($_POST['level']) && !empty($_POST['message']) ) {
|
if ( !empty($_POST['level']) && !empty($_POST['message']) ) {
|
||||||
logInit(array('id'=>'web_js'));
|
ZM\logInit(array('id'=>'web_js'));
|
||||||
|
|
||||||
$string = $_POST['message'];
|
$string = $_POST['message'];
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ switch ( $_REQUEST['task'] ) {
|
||||||
|
|
||||||
$levels = array_flip(Logger::$codes);
|
$levels = array_flip(Logger::$codes);
|
||||||
if ( !isset($levels[$_POST['level']]) )
|
if ( !isset($levels[$_POST['level']]) )
|
||||||
Panic("Unexpected logger level '".$_POST['level']."'");
|
ZM\Panic("Unexpected logger level '".$_POST['level']."'");
|
||||||
$level = $levels[$_POST['level']];
|
$level = $levels[$_POST['level']];
|
||||||
Logger::fetch()->logPrint($level, $string, $file, $line);
|
ZM\Logger::fetch()->logPrint($level, $string, $file, $line);
|
||||||
}
|
}
|
||||||
ajaxResponse();
|
ajaxResponse();
|
||||||
break;
|
break;
|
||||||
|
@ -33,7 +33,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
if ( !canView('System') )
|
if ( !canView('System') )
|
||||||
ajaxError('Insufficient permissions to view log entries');
|
ajaxError('Insufficient permissions to view log entries');
|
||||||
|
|
||||||
$servers = Server::find();
|
$servers = ZM\Server::find();
|
||||||
$servers_by_Id = array();
|
$servers_by_Id = array();
|
||||||
# There is probably a better way to do this.
|
# There is probably a better way to do this.
|
||||||
foreach ( $servers as $server ) {
|
foreach ( $servers as $server ) {
|
||||||
|
@ -46,7 +46,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$limit = 100;
|
$limit = 100;
|
||||||
if ( isset($_REQUEST['limit']) ) {
|
if ( isset($_REQUEST['limit']) ) {
|
||||||
if ( ( !is_integer($_REQUEST['limit']) and !ctype_digit($_REQUEST['limit']) ) ) {
|
if ( ( !is_integer($_REQUEST['limit']) and !ctype_digit($_REQUEST['limit']) ) ) {
|
||||||
Error('Invalid value for limit ' . $_REQUEST['limit']);
|
ZM\Error('Invalid value for limit ' . $_REQUEST['limit']);
|
||||||
} else {
|
} else {
|
||||||
$limit = $_REQUEST['limit'];
|
$limit = $_REQUEST['limit'];
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$sortField = 'TimeKey';
|
$sortField = 'TimeKey';
|
||||||
if ( isset($_REQUEST['sortField']) ) {
|
if ( isset($_REQUEST['sortField']) ) {
|
||||||
if ( !in_array($_REQUEST['sortField'], $filterFields) and ( $_REQUEST['sortField'] != 'TimeKey' ) ) {
|
if ( !in_array($_REQUEST['sortField'], $filterFields) and ( $_REQUEST['sortField'] != 'TimeKey' ) ) {
|
||||||
Error("Invalid sort field " . $_REQUEST['sortField']);
|
ZM\Error("Invalid sort field " . $_REQUEST['sortField']);
|
||||||
} else {
|
} else {
|
||||||
$sortField = $_REQUEST['sortField'];
|
$sortField = $_REQUEST['sortField'];
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
|
|
||||||
foreach ( $filter as $field=>$value ) {
|
foreach ( $filter as $field=>$value ) {
|
||||||
if ( ! in_array($field, $filterFields) ) {
|
if ( ! in_array($field, $filterFields) ) {
|
||||||
Error("$field is not in valid filter fields");
|
ZM\Error("$field is not in valid filter fields");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( $field == 'Level' ){
|
if ( $field == 'Level' ){
|
||||||
|
@ -105,8 +105,8 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$value = $log[$field];
|
$value = $log[$field];
|
||||||
|
|
||||||
if ( $field == 'Level' ) {
|
if ( $field == 'Level' ) {
|
||||||
if ( $value <= Logger::INFO )
|
if ( $value <= ZM\Logger::INFO )
|
||||||
$options[$field][$value] = Logger::$codes[$value];
|
$options[$field][$value] = ZM\Logger::$codes[$value];
|
||||||
else
|
else
|
||||||
$options[$field][$value] = 'DB'.$value;
|
$options[$field][$value] = 'DB'.$value;
|
||||||
} else if ( $field == 'ServerId' ) {
|
} else if ( $field == 'ServerId' ) {
|
||||||
|
@ -146,14 +146,14 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$sortField = 'TimeKey';
|
$sortField = 'TimeKey';
|
||||||
if ( isset($_POST['sortField']) ) {
|
if ( isset($_POST['sortField']) ) {
|
||||||
if ( ! in_array( $_POST['sortField'], $filterFields ) and ( $_POST['sortField'] != 'TimeKey' ) ) {
|
if ( ! in_array( $_POST['sortField'], $filterFields ) and ( $_POST['sortField'] != 'TimeKey' ) ) {
|
||||||
Error("Invalid sort field " . $_POST['sortField'] );
|
ZM\Error("Invalid sort field " . $_POST['sortField'] );
|
||||||
} else {
|
} else {
|
||||||
$sortField = $_POST['sortField'];
|
$sortField = $_POST['sortField'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sortOrder = (isset($_POST['sortOrder']) and $_POST['sortOrder']) == 'asc' ? 'asc':'desc';
|
$sortOrder = (isset($_POST['sortOrder']) and $_POST['sortOrder']) == 'asc' ? 'asc':'desc';
|
||||||
|
|
||||||
$servers = Server::find();
|
$servers = ZM\Server::find();
|
||||||
$servers_by_Id = array();
|
$servers_by_Id = array();
|
||||||
# There is probably a better way to do this.
|
# There is probably a better way to do this.
|
||||||
foreach ( $servers as $server ) {
|
foreach ( $servers as $server ) {
|
||||||
|
@ -164,11 +164,11 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$where = array();
|
$where = array();
|
||||||
$values = array();
|
$values = array();
|
||||||
if ( $minTime ) {
|
if ( $minTime ) {
|
||||||
Logger::Debug("MinTime: $minTime");
|
ZM\Logger::Debug("MinTime: $minTime");
|
||||||
if ( preg_match('/(.+)(\.\d+)/', $minTime, $matches) ) {
|
if ( preg_match('/(.+)(\.\d+)/', $minTime, $matches) ) {
|
||||||
# This handles sub second precision
|
# This handles sub second precision
|
||||||
$minTime = strtotime($matches[1]).$matches[2];
|
$minTime = strtotime($matches[1]).$matches[2];
|
||||||
Logger::Debug("MinTime: $minTime");
|
ZM\Logger::Debug("MinTime: $minTime");
|
||||||
} else {
|
} else {
|
||||||
$minTime = strtotime($minTime);
|
$minTime = strtotime($minTime);
|
||||||
}
|
}
|
||||||
|
@ -214,27 +214,27 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$exportExt = 'xml';
|
$exportExt = 'xml';
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
Fatal("Unrecognised log export format '$format'");
|
ZM\Fatal("Unrecognised log export format '$format'");
|
||||||
}
|
}
|
||||||
$exportKey = substr(md5(rand()),0,8);
|
$exportKey = substr(md5(rand()),0,8);
|
||||||
$exportFile = "zm-log.$exportExt";
|
$exportFile = "zm-log.$exportExt";
|
||||||
if ( ! file_exists(ZM_DIR_EXPORTS) ) {
|
if ( ! file_exists(ZM_DIR_EXPORTS) ) {
|
||||||
Logger::Debug('Creating ' . ZM_DIR_EXPORTS);
|
ZM\Logger::Debug('Creating ' . ZM_DIR_EXPORTS);
|
||||||
if ( ! mkdir(ZM_DIR_EXPORTS) ) {
|
if ( ! mkdir(ZM_DIR_EXPORTS) ) {
|
||||||
Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'");
|
ZM\Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt";
|
$exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt";
|
||||||
Logger::Debug("Exporting to $exportPath");
|
ZM\Logger::Debug("Exporting to $exportPath");
|
||||||
if ( !($exportFP = fopen($exportPath, 'w')) )
|
if ( !($exportFP = fopen($exportPath, 'w')) )
|
||||||
Fatal("Unable to open log export file $exportPath");
|
ZM\Fatal("Unable to open log export file $exportPath");
|
||||||
$logs = array();
|
$logs = array();
|
||||||
foreach ( dbFetchAll($sql, NULL, $values) as $log ) {
|
foreach ( dbFetchAll($sql, NULL, $values) as $log ) {
|
||||||
$log['DateTime'] = preg_replace('/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey']);
|
$log['DateTime'] = preg_replace('/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey']);
|
||||||
$log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : '';
|
$log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : '';
|
||||||
$logs[] = $log;
|
$logs[] = $log;
|
||||||
}
|
}
|
||||||
Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values));
|
ZM\Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values));
|
||||||
|
|
||||||
switch( $format ) {
|
switch( $format ) {
|
||||||
case 'text' :
|
case 'text' :
|
||||||
|
@ -318,10 +318,10 @@ switch ( $_REQUEST['task'] ) {
|
||||||
' );
|
' );
|
||||||
foreach ( $logs as $log ) {
|
foreach ( $logs as $log ) {
|
||||||
$classLevel = $log['Level'];
|
$classLevel = $log['Level'];
|
||||||
if ( $classLevel < Logger::FATAL )
|
if ( $classLevel < ZM\Logger::FATAL )
|
||||||
$classLevel = Logger::FATAL;
|
$classLevel = ZM\Logger::FATAL;
|
||||||
elseif ( $classLevel > Logger::DEBUG )
|
elseif ( $classLevel > ZM\Logger::DEBUG )
|
||||||
$classLevel = Logger::DEBUG;
|
$classLevel = ZM\Logger::DEBUG;
|
||||||
$logClass = 'log-'.strtolower(Logger::$codes[$classLevel]);
|
$logClass = 'log-'.strtolower(Logger::$codes[$classLevel]);
|
||||||
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'], $log['Server'], $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'], $log['Server'], $log['Pid'], $log['Code'], $log['Message'], $log['File'], $log['Line'] );
|
||||||
}
|
}
|
||||||
|
@ -384,10 +384,10 @@ switch ( $_REQUEST['task'] ) {
|
||||||
ajaxError('Insufficient permissions to download logs');
|
ajaxError('Insufficient permissions to download logs');
|
||||||
|
|
||||||
if ( empty($_REQUEST['key']) )
|
if ( empty($_REQUEST['key']) )
|
||||||
Fatal('No log export key given');
|
ZM\Fatal('No log export key given');
|
||||||
$exportKey = $_REQUEST['key'];
|
$exportKey = $_REQUEST['key'];
|
||||||
if ( empty($_REQUEST['format']) )
|
if ( empty($_REQUEST['format']) )
|
||||||
Fatal('No log export format given');
|
ZM\Fatal('No log export format given');
|
||||||
$format = $_REQUEST['format'];
|
$format = $_REQUEST['format'];
|
||||||
|
|
||||||
switch( $format ) {
|
switch( $format ) {
|
||||||
|
@ -404,7 +404,7 @@ switch ( $_REQUEST['task'] ) {
|
||||||
$exportExt = 'xml';
|
$exportExt = 'xml';
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
Fatal("Unrecognised log export format '$format'");
|
ZM\Fatal("Unrecognised log export format '$format'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$exportFile = "zm-log.$exportExt";
|
$exportFile = "zm-log.$exportExt";
|
||||||
|
|
|
@ -284,7 +284,7 @@ function collectData() {
|
||||||
if ( in_array($matches[1], $fieldSql) ) {
|
if ( in_array($matches[1], $fieldSql) ) {
|
||||||
$sql .= $matches[1];
|
$sql .= $matches[1];
|
||||||
} else {
|
} else {
|
||||||
Error('Sort field ' . $matches[1] . ' not in SQL Fields');
|
ZM\Error('Sort field ' . $matches[1] . ' not in SQL Fields');
|
||||||
}
|
}
|
||||||
if ( count($matches) > 2 ) {
|
if ( count($matches) > 2 ) {
|
||||||
$sql .= ' '.strtoupper($matches[2]);
|
$sql .= ' '.strtoupper($matches[2]);
|
||||||
|
@ -292,7 +292,7 @@ function collectData() {
|
||||||
$sql .= ' '.strtoupper($matches[3]);
|
$sql .= ' '.strtoupper($matches[3]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("Sort field didn't match regexp $sort_field");
|
ZM\Error("Sort field didn't match regexp $sort_field");
|
||||||
}
|
}
|
||||||
} # end foreach sort field
|
} # end foreach sort field
|
||||||
} # end if has sort
|
} # end if has sort
|
||||||
|
@ -323,7 +323,7 @@ function collectData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#Logger::Debug(print_r($data, true));
|
#ZM\Logger::Debug(print_r($data, true));
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
|
|
||||||
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
|
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
|
||||||
if ( file_exists( $localSocketFile ) ) {
|
if ( file_exists( $localSocketFile ) ) {
|
||||||
Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
|
ZM\Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
|
||||||
// They could be. We can maybe have concurrent requests from a browser.
|
// They could be. We can maybe have concurrent requests from a browser.
|
||||||
}
|
}
|
||||||
if ( ! socket_bind( $socket, $localSocketFile ) ) {
|
if ( ! socket_bind( $socket, $localSocketFile ) ) {
|
||||||
|
@ -32,23 +32,23 @@ if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
|
|
||||||
switch ( $_REQUEST['command'] ) {
|
switch ( $_REQUEST['command'] ) {
|
||||||
case CMD_VARPLAY :
|
case CMD_VARPLAY :
|
||||||
Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
ZM\Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
||||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||||
break;
|
break;
|
||||||
case CMD_ZOOMIN :
|
case CMD_ZOOMIN :
|
||||||
Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
ZM\Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||||
break;
|
break;
|
||||||
case CMD_PAN :
|
case CMD_PAN :
|
||||||
Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
ZM\Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||||
break;
|
break;
|
||||||
case CMD_SCALE :
|
case CMD_SCALE :
|
||||||
Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
|
ZM\Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
|
||||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
||||||
break;
|
break;
|
||||||
case CMD_SEEK :
|
case CMD_SEEK :
|
||||||
Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
|
ZM\Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
|
||||||
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
@ -84,18 +84,18 @@ if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
$numSockets = socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
$numSockets = socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
||||||
|
|
||||||
if ( $numSockets === false ) {
|
if ( $numSockets === false ) {
|
||||||
Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
|
ZM\Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
|
||||||
ajaxError( 'socket_select failed: '.socket_strerror(socket_last_error()) );
|
ajaxError( 'socket_select failed: '.socket_strerror(socket_last_error()) );
|
||||||
} else if ( $numSockets < 0 ) {
|
} else if ( $numSockets < 0 ) {
|
||||||
Error( "Socket closed $remSockFile" );
|
ZM\Error( "Socket closed $remSockFile" );
|
||||||
ajaxError( "Socket closed $remSockFile" );
|
ajaxError( "Socket closed $remSockFile" );
|
||||||
} else if ( $numSockets == 0 ) {
|
} else if ( $numSockets == 0 ) {
|
||||||
Error( "Timed out waiting for msg $remSockFile" );
|
ZM\Error( "Timed out waiting for msg $remSockFile" );
|
||||||
socket_Set_nonblock($socket);
|
socket_Set_nonblock($socket);
|
||||||
#ajaxError( "Timed out waiting for msg $remSockFile" );
|
#ajaxError( "Timed out waiting for msg $remSockFile" );
|
||||||
} else if ( $numSockets > 0 ) {
|
} else if ( $numSockets > 0 ) {
|
||||||
if ( count($rSockets) != 1 ) {
|
if ( count($rSockets) != 1 ) {
|
||||||
Error( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
ZM\Error( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
||||||
ajaxError( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
ajaxError( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,9 @@ if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
case MSG_DATA_WATCH :
|
case MSG_DATA_WATCH :
|
||||||
{
|
{
|
||||||
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
|
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
|
||||||
Logger::Debug("FPS: " . $data['fps'] );
|
ZM\Logger::Debug("FPS: " . $data['fps'] );
|
||||||
$data['fps'] = round( $data['fps'], 2 );
|
$data['fps'] = round( $data['fps'], 2 );
|
||||||
Logger::Debug("FPS: " . $data['fps'] );
|
ZM\Logger::Debug("FPS: " . $data['fps'] );
|
||||||
$data['rate'] /= RATE_BASE;
|
$data['rate'] /= RATE_BASE;
|
||||||
$data['delay'] = round( $data['delay'], 2 );
|
$data['delay'] = round( $data['delay'], 2 );
|
||||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||||
|
@ -164,7 +164,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
}
|
}
|
||||||
sem_release($semaphore);
|
sem_release($semaphore);
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("Couldn't get semaphore");
|
ZM\Logger::Debug("Couldn't get semaphore");
|
||||||
ajaxResponse( array() );
|
ajaxResponse( array() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class HostController extends AppController {
|
||||||
|
|
||||||
if ( $isZmAuth ) {
|
if ( $isZmAuth ) {
|
||||||
// In future, we may want to completely move to AUTH_HASH_LOGINS and return &auth= for all cases
|
// In future, we may want to completely move to AUTH_HASH_LOGINS and return &auth= for all cases
|
||||||
require_once __DIR__ ."../../../includes/auth.php"; # in the event we directly call getCredentials.json
|
require_once __DIR__ .'/../../../includes/auth.php'; # in the event we directly call getCredentials.json
|
||||||
$this->Session->read('user'); # this is needed for command line/curl to recognize a session
|
$this->Session->read('user'); # this is needed for command line/curl to recognize a session
|
||||||
$zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value'];
|
$zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value'];
|
||||||
if ( $zmAuthRelay == 'hashed' ) {
|
if ( $zmAuthRelay == 'hashed' ) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
|
|
||||||
$event_cache = array();
|
$event_cache = array();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
require_once( 'Event.php' );
|
require_once( 'Event.php' );
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
|
|
||||||
$group_cache = array();
|
$group_cache = array();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
require_once('database.php');
|
require_once('database.php');
|
||||||
require_once('Server.php');
|
require_once('Server.php');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
|
|
||||||
require_once('database.php');
|
require_once('database.php');
|
||||||
|
|
||||||
|
@ -98,9 +99,9 @@ class MontageLayout {
|
||||||
}
|
}
|
||||||
$result = dbQuery($sql, $values);
|
$result = dbQuery($sql, $values);
|
||||||
if ( $result ) {
|
if ( $result ) {
|
||||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'MontageLayout');
|
$results = $result->fetchALL();
|
||||||
foreach ( $results as $row => $obj ) {
|
foreach ( $results as $row ) {
|
||||||
$filters[] = $obj;
|
$filters[] = new MontageLayout($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $filters;
|
return $filters;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
require_once('database.php');
|
require_once('database.php');
|
||||||
|
|
||||||
$server_cache = array();
|
$server_cache = array();
|
||||||
|
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
private $defaults = array(
|
private $defaults = array(
|
||||||
'Id' => null,
|
'Id' => null,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace ZM;
|
||||||
require_once('database.php');
|
require_once('database.php');
|
||||||
|
require_once('Event.php');
|
||||||
|
|
||||||
$storage_cache = array();
|
$storage_cache = array();
|
||||||
class Storage {
|
class Storage {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( ! canEdit('Monitors') ) {
|
if ( ! canEdit('Monitors') ) {
|
||||||
Warning("No permission to delete monitors");
|
ZM\Warning('No permission to delete monitors');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ if ( $action == 'delete' ) {
|
||||||
if ( canEdit('Monitors', $markMid) ) {
|
if ( canEdit('Monitors', $markMid) ) {
|
||||||
// This could be faster as a select all
|
// This could be faster as a select all
|
||||||
if ( $monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($markMid)) ) {
|
if ( $monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($markMid)) ) {
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new ZM\Monitor($monitor);
|
||||||
$Monitor->delete();
|
$Monitor->delete();
|
||||||
} // end if monitor found in db
|
} // end if monitor found in db
|
||||||
} // end if canedit this monitor
|
} // end if canedit this monitor
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
|
|
||||||
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
||||||
if ( empty($_REQUEST['mid']) ) {
|
if ( empty($_REQUEST['mid']) ) {
|
||||||
Warning("Settings requires a monitor id");
|
ZM\Warning('Settings requires a monitor id');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ! canView('Control', $_REQUEST['mid']) ) {
|
if ( ! canView('Control', $_REQUEST['mid']) ) {
|
||||||
Warning("Settings requires the Control permission");
|
ZM\Warning('Settings requires the Control permission');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ require_once('control_functions.php');
|
||||||
require_once('Monitor.php');
|
require_once('Monitor.php');
|
||||||
$mid = validInt($_REQUEST['mid']);
|
$mid = validInt($_REQUEST['mid']);
|
||||||
if ( $action == 'control' ) {
|
if ( $action == 'control' ) {
|
||||||
$monitor = new Monitor($mid);
|
$monitor = new ZM\Monitor($mid);
|
||||||
|
|
||||||
$ctrlCommand = buildControlCommand($monitor);
|
$ctrlCommand = buildControlCommand($monitor);
|
||||||
sendControlCommand($monitor->Id(), $ctrlCommand);
|
sendControlCommand($monitor->Id(), $ctrlCommand);
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
|
|
||||||
|
|
||||||
if ( !canEdit('Control') ) {
|
if ( !canEdit('Control') ) {
|
||||||
Warning("Need Control permissions to edit control capabilities");
|
ZM\Warning('Need Control permissions to edit control capabilities');
|
||||||
return;
|
return;
|
||||||
} // end if !canEdit Controls
|
} // end if !canEdit Controls
|
||||||
|
|
||||||
if ( $action == 'controlcap' ) {
|
if ( $action == 'controlcap' ) {
|
||||||
require_once('includes/Control.php');
|
require_once('includes/Control.php');
|
||||||
$Control = new Control( !empty($_REQUEST['cid']) ? $_REQUEST['cid'] : null );
|
$Control = new ZM\Control( !empty($_REQUEST['cid']) ? $_REQUEST['cid'] : null );
|
||||||
|
|
||||||
//$changes = getFormChanges( $control, $_REQUEST['newControl'], $types, $columns );
|
//$changes = getFormChanges( $control, $_REQUEST['newControl'], $types, $columns );
|
||||||
$Control->save($_REQUEST['newControl']);
|
$Control->save($_REQUEST['newControl']);
|
||||||
|
|
|
@ -20,16 +20,15 @@
|
||||||
|
|
||||||
|
|
||||||
if ( !canEdit('Control') ) {
|
if ( !canEdit('Control') ) {
|
||||||
Warning("Need Control permissions to edit control capabilities");
|
ZM\Warning('Need Control permissions to edit control capabilities');
|
||||||
return;
|
return;
|
||||||
} // end if !canEdit Controls
|
} // end if !canEdit Controls
|
||||||
}
|
|
||||||
|
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( isset($_REQUEST['markCids']) ) {
|
if ( isset($_REQUEST['markCids']) ) {
|
||||||
foreach( $_REQUEST['markCids'] as $markCid ) {
|
foreach( $_REQUEST['markCids'] as $markCid ) {
|
||||||
dbQuery('DELETE FROM Controls WHERE Id = ?', array($markCid));
|
|
||||||
dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($markCid));
|
dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($markCid));
|
||||||
|
dbQuery('DELETE FROM Controls WHERE Id = ?', array($markCid));
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// Device view actions
|
// Device view actions
|
||||||
if ( !canEdit('Devices') ) {
|
if ( !canEdit('Devices') ) {
|
||||||
Warning("No devices permission in editing device");
|
ZM\Warning('No devices permission in editing device');
|
||||||
return;
|
return;
|
||||||
} // end if !canEdit(Devices)
|
} // end if !canEdit(Devices)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ if ( $action == 'device' ) {
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("Unknown action in device");
|
ZM\Error('Unknown action in device');
|
||||||
} // end if action
|
} // end if action
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// Device view actions
|
// Device view actions
|
||||||
if ( !canEdit('Devices') ) {
|
if ( !canEdit('Devices') ) {
|
||||||
Warning("No devices permission in editing device");
|
ZM\Warning('No devices permission in editing device');
|
||||||
return;
|
return;
|
||||||
} // end if !canEdit(Devices)
|
} // end if !canEdit(Devices)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canEdit('System') ) {
|
if ( !canEdit('System') ) {
|
||||||
Warning("Need System permissions to update donation");
|
ZM\Warning('Need System permissions to update donation');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// If there is an action on an event, then we must have an id.
|
// If there is an action on an event, then we must have an id.
|
||||||
if ( !empty($_REQUEST['eid']) ) {
|
if ( !empty($_REQUEST['eid']) ) {
|
||||||
Warning("No eid in action on event view");
|
ZM\Warning('No eid in action on event view');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !isset($_REQUEST['markEids']) ) {
|
if ( !isset($_REQUEST['markEids']) ) {
|
||||||
Warning('Events actions require eids');
|
ZM\Warning('Events actions require eids');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scope actions, view permissions only required
|
// Event scope actions, view permissions only required
|
||||||
if ( !canEdit('Events') ) {
|
if ( !canEdit('Events') ) {
|
||||||
Warning("Events actions require Edit permissions");
|
ZM\Warning('Events actions require Edit permissions');
|
||||||
return;
|
return;
|
||||||
} // end if ! canEdit(Events)
|
} // end if ! canEdit(Events)
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !isset($_REQUEST['eids']) ) {
|
if ( !isset($_REQUEST['eids']) ) {
|
||||||
Warning('Events actions require eids');
|
ZM\Warning('Events actions require eids');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event scope actions, view permissions only required
|
// Event scope actions, view permissions only required
|
||||||
if ( !canEdit('Events') ) {
|
if ( !canEdit('Events') ) {
|
||||||
Warning("Events actions require Edit permissions");
|
ZM\Warning('Events actions require Edit permissions');
|
||||||
return;
|
return;
|
||||||
} // end if ! canEdit(Events)
|
} // end if ! canEdit(Events)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// Event scope actions, view permissions only required
|
// Event scope actions, view permissions only required
|
||||||
if ( !canView('Events') ) {
|
if ( !canView('Events') ) {
|
||||||
Warning('You do not have permission to view Events.');
|
ZM\Warning('You do not have permission to view Events.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,9 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
|
||||||
} elseif ( $action == 'delterm' ) {
|
} elseif ( $action == 'delterm' ) {
|
||||||
$_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']);
|
$_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']);
|
||||||
} else if ( canEdit('Events') ) {
|
} else if ( canEdit('Events') ) {
|
||||||
if ( empty($_REQUEST['Id']) ) {
|
|
||||||
Error("No filter id specified.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once('includes/Filter.php');
|
require_once('includes/Filter.php');
|
||||||
$filter = new Filter($_REQUEST['Id']);
|
$filter = new ZM\Filter($_REQUEST['Id']);
|
||||||
|
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( !empty($_REQUEST['Id']) ) {
|
if ( !empty($_REQUEST['Id']) ) {
|
||||||
|
@ -46,7 +42,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
|
||||||
$filter->delete();
|
$filter->delete();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Error("No filter id passed when deleting");
|
ZM\Error("No filter id passed when deleting");
|
||||||
}
|
}
|
||||||
} else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) {
|
} else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) {
|
||||||
|
|
||||||
|
@ -102,7 +98,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
|
||||||
) {
|
) {
|
||||||
$filter->control($_REQUEST['command'], $_REQUEST['ServerId']);
|
$filter->control($_REQUEST['command'], $_REQUEST['ServerId']);
|
||||||
} else {
|
} else {
|
||||||
Error('Invalid command for filter ('.$_REQUEST['command'].')');
|
ZM\Error('Invalid command for filter ('.$_REQUEST['command'].')');
|
||||||
}
|
}
|
||||||
} // end if save or execute
|
} // end if save or execute
|
||||||
} // end if canEdit(Events)
|
} // end if canEdit(Events)
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
|
|
||||||
// Monitor edit actions, require a monitor id and edit permissions for that monitor
|
// Monitor edit actions, require a monitor id and edit permissions for that monitor
|
||||||
if ( empty($_REQUEST['mid']) ) {
|
if ( empty($_REQUEST['mid']) ) {
|
||||||
Error("Must specify mid");
|
ZM\Error('Must specify mid');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mid = validInt($_REQUEST['mid']);
|
$mid = validInt($_REQUEST['mid']);
|
||||||
if ( !canEdit('Monitors', $mid) ) {
|
if ( !canEdit('Monitors', $mid) ) {
|
||||||
Error("You do not have permission to edit monitor $mid");
|
ZM\Error("You do not have permission to edit monitor $mid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ if ( $action == 'function' ) {
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("No change to function, not doing anything.");
|
ZM\Logger::Debug('No change to function, not doing anything.');
|
||||||
}
|
}
|
||||||
} // end if action
|
} // end if action
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
# Should probably verify that each monitor id is a valid monitor, that we have access to.
|
# Should probably verify that each monitor id is a valid monitor, that we have access to.
|
||||||
# However at the moment, you have to have System permissions to do this
|
# However at the moment, you have to have System permissions to do this
|
||||||
if ( ! canEdit('Groups') ) {
|
if ( ! canEdit('Groups') ) {
|
||||||
Warning("Need group edit permissions to edit groups");
|
ZM\Warning('Need group edit permissions to edit groups');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@ if ( ($action == 'setgroup') && canView('Groups')) {
|
||||||
# Should probably verify that each monitor id is a valid monitor, that we have access to.
|
# Should probably verify that each monitor id is a valid monitor, that we have access to.
|
||||||
# However at the moment, you have to have System permissions to do this
|
# However at the moment, you have to have System permissions to do this
|
||||||
if ( ! canEdit('Groups') ) {
|
if ( ! canEdit('Groups') ) {
|
||||||
Warning("Need group edit permissions to edit groups");
|
ZM\Warning('Need group edit permissions to edit groups');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( !empty($_REQUEST['gid']) ) {
|
if ( !empty($_REQUEST['gid']) ) {
|
||||||
foreach ( Group::find(array('Id'=>$_REQUEST['gid'])) as $Group ) {
|
foreach ( ZM\Group::find(array('Id'=>$_REQUEST['gid'])) as $Group ) {
|
||||||
$Group->delete();
|
$Group->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
|
||||||
foreach ( $_REQUEST['mids'] as $mid ) {
|
foreach ( $_REQUEST['mids'] as $mid ) {
|
||||||
$mid = ValidInt($mid);
|
$mid = ValidInt($mid);
|
||||||
if ( ! canEdit('Monitors', $mid) ) {
|
if ( ! canEdit('Monitors', $mid) ) {
|
||||||
Warning("Cannot edit monitor $mid");
|
ZM\Warning("Cannot edit monitor $mid");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$Monitor = new Monitor($mid);
|
$Monitor = new ZM\Monitor($mid);
|
||||||
if ( $Monitor->Type() != 'WebSite' ) {
|
if ( $Monitor->Type() != 'WebSite' ) {
|
||||||
$Monitor->zmaControl('stop');
|
$Monitor->zmaControl('stop');
|
||||||
$Monitor->zmcControl('stop');
|
$Monitor->zmcControl('stop');
|
||||||
|
@ -47,7 +47,7 @@ if ( isset($_REQUEST['object']) and $_REQUEST['object'] == 'Monitor' ) {
|
||||||
|
|
||||||
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
|
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
|
||||||
if ( ! canEdit('Monitors') ) {
|
if ( ! canEdit('Monitors') ) {
|
||||||
Warning("Monitor actions require Monitors Permissions");
|
ZM\Warning("Monitor actions require Monitors Permissions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ if ( $action == 'monitor' ) {
|
||||||
$x10Monitor = array();
|
$x10Monitor = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new ZM\Monitor($monitor);
|
||||||
|
|
||||||
// Define a field type for anything that's not simple text equivalent
|
// Define a field type for anything that's not simple text equivalent
|
||||||
$types = array(
|
$types = array(
|
||||||
|
@ -86,10 +86,10 @@ if ( $action == 'monitor' ) {
|
||||||
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
|
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
|
||||||
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne(
|
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne(
|
||||||
'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
|
'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
|
||||||
Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId'] );
|
ZM\Logger::Debug('Auto selecting server: Got ' . $_REQUEST['newMonitor']['ServerId'] );
|
||||||
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
|
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
|
||||||
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
|
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
|
||||||
Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
|
ZM\Logger::Debug('Auto selecting server to ' . ZM_SERVER_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +107,12 @@ if ( $action == 'monitor' ) {
|
||||||
dbQuery('UPDATE Monitors SET '.implode(', ', $changes).' WHERE Id=?', array($mid));
|
dbQuery('UPDATE Monitors SET '.implode(', ', $changes).' WHERE Id=?', array($mid));
|
||||||
// Groups will be added below
|
// Groups will be added below
|
||||||
if ( isset($changes['Name']) or isset($changes['StorageId']) ) {
|
if ( isset($changes['Name']) or isset($changes['StorageId']) ) {
|
||||||
$OldStorage = new Storage($monitor['StorageId']);
|
$OldStorage = new ZM\Storage($monitor['StorageId']);
|
||||||
$saferOldName = basename($monitor['Name']);
|
$saferOldName = basename($monitor['Name']);
|
||||||
if ( file_exists($OldStorage->Path().'/'.$saferOldName) )
|
if ( file_exists($OldStorage->Path().'/'.$saferOldName) )
|
||||||
unlink($OldStorage->Path().'/'.$saferOldName);
|
unlink($OldStorage->Path().'/'.$saferOldName);
|
||||||
|
|
||||||
$NewStorage = new Storage($_REQUEST['newMonitor']['StorageId']);
|
$NewStorage = new ZM\Storage($_REQUEST['newMonitor']['StorageId']);
|
||||||
if ( ! file_exists($NewStorage->Path().'/'.$mid) )
|
if ( ! file_exists($NewStorage->Path().'/'.$mid) )
|
||||||
mkdir($NewStorage->Path().'/'.$mid, 0755);
|
mkdir($NewStorage->Path().'/'.$mid, 0755);
|
||||||
$saferNewName = basename($_REQUEST['newMonitor']['Name']);
|
$saferNewName = basename($_REQUEST['newMonitor']['Name']);
|
||||||
|
@ -164,24 +164,24 @@ if ( $action == 'monitor' ) {
|
||||||
$zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height'];
|
$zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height'];
|
||||||
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
|
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
|
||||||
//$view = 'none';
|
//$view = 'none';
|
||||||
$Storage = new Storage($_REQUEST['newMonitor']['StorageId']);
|
$Storage = new ZM\Storage($_REQUEST['newMonitor']['StorageId']);
|
||||||
mkdir($Storage->Path().'/'.$mid, 0755);
|
mkdir($Storage->Path().'/'.$mid, 0755);
|
||||||
$saferName = basename($_REQUEST['newMonitor']['Name']);
|
$saferName = basename($_REQUEST['newMonitor']['Name']);
|
||||||
symlink($mid, $Storage->Path().'/'.$saferName);
|
symlink($mid, $Storage->Path().'/'.$saferName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Error('Error saving new Monitor.');
|
ZM\Error('Error saving new Monitor.');
|
||||||
$error_message = dbError($sql);
|
$error_message = dbError($sql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error('Users with Monitors restrictions cannot create new monitors.');
|
ZM\Error('Users with Monitors restrictions cannot create new monitors.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$restart = true;
|
$restart = true;
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug('No action due to no changes to Monitor');
|
ZM\Logger::Debug('No action due to no changes to Monitor');
|
||||||
} # end if count(changes)
|
} # end if count(changes)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -220,7 +220,7 @@ if ( $action == 'monitor' ) {
|
||||||
|
|
||||||
if ( $restart ) {
|
if ( $restart ) {
|
||||||
|
|
||||||
$new_monitor = new Monitor($mid);
|
$new_monitor = new ZM\Monitor($mid);
|
||||||
//fixDevices();
|
//fixDevices();
|
||||||
|
|
||||||
if ( $new_monitor->Type() != 'WebSite' ) {
|
if ( $new_monitor->Type() != 'WebSite' ) {
|
||||||
|
@ -238,6 +238,6 @@ if ( $action == 'monitor' ) {
|
||||||
} // end if restart
|
} // end if restart
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
} else {
|
} else {
|
||||||
Warning("Unknown action $action in Monitor");
|
ZM\Warning("Unknown action $action in Monitor");
|
||||||
} // end if action == Delete
|
} // end if action == Delete
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -22,7 +22,7 @@ if ( isset($_REQUEST['object']) ) {
|
||||||
if ( $_REQUEST['object'] == 'MontageLayout' ) {
|
if ( $_REQUEST['object'] == 'MontageLayout' ) {
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( ! canEdit('System') ) {
|
if ( ! canEdit('System') ) {
|
||||||
Warning("Need System permissions to edit layouts");
|
ZM\Warning('Need System permissions to edit layouts');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
require_once('includes/MontageLayout.php');
|
require_once('includes/MontageLayout.php');
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( !canEdit('System') ) {
|
if ( !canEdit('System') ) {
|
||||||
Warning("Must have System permissions to perform options actions");
|
ZM\Warning('Must have System permissions to perform options actions');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canEdit('System') ) {
|
if ( !canEdit('System') ) {
|
||||||
Warning("Need System permissions to update privacy");
|
ZM\Warning('Need System permissions to update privacy');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ($action == 'privacy') && isset($_REQUEST['option']) ) {
|
if ( ($action == 'privacy') && isset($_POST['option']) ) {
|
||||||
switch( $_REQUEST['option'] ) {
|
switch( $_POST['option'] ) {
|
||||||
case 'decline' :
|
case '0' :
|
||||||
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
||||||
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
||||||
$redirect = '?view=console';
|
$redirect = '?view=console';
|
||||||
break;
|
break;
|
||||||
case 'accept' :
|
case '1' :
|
||||||
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
|
||||||
dbQuery("UPDATE Config SET Value = '1' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
dbQuery("UPDATE Config SET Value = '1' WHERE Name = 'ZM_TELEMETRY_DATA'");
|
||||||
$redirect = '?view=console';
|
$redirect = '?view=console';
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( ! canEdit('System') ) {
|
if ( ! canEdit('System') ) {
|
||||||
Warning("Need System permissions to add servers");
|
ZM\Warning('Need System permissions to add servers');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,6 @@ if ( $action == 'Save' ) {
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
} else {
|
} else {
|
||||||
Error("Unknown action $action in saving Server");
|
ZM\Error("Unknown action $action in saving Server");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
|
|
||||||
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
||||||
if ( empty($_REQUEST['mid']) ) {
|
if ( empty($_REQUEST['mid']) ) {
|
||||||
Warning("Settings requires a monitor id");
|
ZM\Warning('Settings requires a monitor id');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ! canView('Control', $_REQUEST['mid']) ) {
|
if ( ! canView('Control', $_REQUEST['mid']) ) {
|
||||||
Warning("Settings requires the Control permission");
|
ZM\Warning('Settings requires the Control permission');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( !canEdit('System') ) {
|
if ( !canEdit('System') ) {
|
||||||
Warning('Need System Permission to edit states');
|
ZM\Warning('Need System Permission to edit states');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( $action == 'state' ) {
|
if ( $action == 'state' ) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( ! canEdit('System') ) {
|
if ( ! canEdit('System') ) {
|
||||||
Warning("Need System permission to edit Storage");
|
ZM\Warning('Need System permission to edit Storage');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ if ( $action == 'Save' ) {
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
} else {
|
} else {
|
||||||
Error("Unknown action $action in saving Storage");
|
ZM\Error("Unknown action $action in saving Storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
if ( !canEdit('System') ) {
|
if ( !canEdit('System') ) {
|
||||||
Warning("Need System permissions to update version");
|
ZM\Warning('Need System permissions to update version');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( $action == 'version' && isset($_REQUEST['option']) ) {
|
if ( $action == 'version' && isset($_REQUEST['option']) ) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
if ( !empty($_REQUEST['mid']) && canEdit('Monitors', $_REQUEST['mid']) ) {
|
if ( !empty($_REQUEST['mid']) && canEdit('Monitors', $_REQUEST['mid']) ) {
|
||||||
$mid = validInt($_REQUEST['mid']);
|
$mid = validInt($_REQUEST['mid']);
|
||||||
$monitor = new Monitor($mid);
|
$monitor = new ZM\Monitor($mid);
|
||||||
|
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( isset($_REQUEST['markZids']) ) {
|
if ( isset($_REQUEST['markZids']) ) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
|
||||||
}
|
}
|
||||||
$_SESSION['remoteAddr'] = $_SERVER['REMOTE_ADDR']; // To help prevent session hijacking
|
$_SESSION['remoteAddr'] = $_SERVER['REMOTE_ADDR']; // To help prevent session hijacking
|
||||||
if ( $dbUser = dbFetchOne($sql, NULL, $sql_values) ) {
|
if ( $dbUser = dbFetchOne($sql, NULL, $sql_values) ) {
|
||||||
Info("Login successful for user \"$username\"");
|
ZM\Info("Login successful for user \"$username\"");
|
||||||
$user = $dbUser;
|
$user = $dbUser;
|
||||||
unset($_SESSION['loginFailed']);
|
unset($_SESSION['loginFailed']);
|
||||||
if ( ZM_AUTH_TYPE == 'builtin' ) {
|
if ( ZM_AUTH_TYPE == 'builtin' ) {
|
||||||
|
@ -97,7 +97,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
|
||||||
}
|
}
|
||||||
zm_session_regenerate_id();
|
zm_session_regenerate_id();
|
||||||
} else {
|
} else {
|
||||||
Warning("Login denied for user \"$username\"");
|
ZM\Warning("Login denied for user \"$username\"");
|
||||||
$_SESSION['loginFailed'] = true;
|
$_SESSION['loginFailed'] = true;
|
||||||
unset($user);
|
unset($user);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ function userLogin($username='', $password='', $passwordHashed=false) {
|
||||||
|
|
||||||
function userLogout() {
|
function userLogout() {
|
||||||
global $user;
|
global $user;
|
||||||
Info('User "'.$user['Username'].'" logged out');
|
ZM\Info('User "'.$user['Username'].'" logged out');
|
||||||
unset($user);
|
unset($user);
|
||||||
zm_session_clear();
|
zm_session_clear();
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ function getAuthUser($auth) {
|
||||||
if ( ZM_AUTH_HASH_IPS ) {
|
if ( ZM_AUTH_HASH_IPS ) {
|
||||||
$remoteAddr = $_SERVER['REMOTE_ADDR'];
|
$remoteAddr = $_SERVER['REMOTE_ADDR'];
|
||||||
if ( !$remoteAddr ) {
|
if ( !$remoteAddr ) {
|
||||||
Error("Can't determine remote address for authentication, using empty string");
|
ZM\Error("Can't determine remote address for authentication, using empty string");
|
||||||
$remoteAddr = '';
|
$remoteAddr = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ function getAuthUser($auth) {
|
||||||
} // end foreach hour
|
} // end foreach hour
|
||||||
} // end foreach user
|
} // end foreach user
|
||||||
} // end if using auth hash
|
} // end if using auth hash
|
||||||
Error("Unable to authenticate user from auth hash '$auth'");
|
ZM\Error("Unable to authenticate user from auth hash '$auth'");
|
||||||
return false;
|
return false;
|
||||||
} // end getAuthUser($auth)
|
} // end getAuthUser($auth)
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ function generateAuthHash($useRemoteAddr, $force=false) {
|
||||||
} else {
|
} else {
|
||||||
$authKey = ZM_AUTH_HASH_SECRET.$_SESSION['username'].$_SESSION['passwordHash'].$local_time[2].$local_time[3].$local_time[4].$local_time[5];
|
$authKey = ZM_AUTH_HASH_SECRET.$_SESSION['username'].$_SESSION['passwordHash'].$local_time[2].$local_time[3].$local_time[4].$local_time[5];
|
||||||
}
|
}
|
||||||
#Logger::Debug("Generated using hour:".$local_time[2] . ' mday:' . $local_time[3] . ' month:'.$local_time[4] . ' year: ' . $local_time[5] );
|
#ZM\Logger::Debug("Generated using hour:".$local_time[2] . ' mday:' . $local_time[3] . ' month:'.$local_time[4] . ' year: ' . $local_time[5] );
|
||||||
$auth = md5($authKey);
|
$auth = md5($authKey);
|
||||||
if ( !$force ) {
|
if ( !$force ) {
|
||||||
$close_session = 0;
|
$close_session = 0;
|
||||||
|
@ -178,9 +178,9 @@ function generateAuthHash($useRemoteAddr, $force=false) {
|
||||||
} else {
|
} else {
|
||||||
return $auth;
|
return $auth;
|
||||||
}
|
}
|
||||||
#Logger::Debug("Generated new auth $auth at " . $_SESSION['AuthHashGeneratedAt']. " using $authKey" );
|
#ZM\Logger::Debug("Generated new auth $auth at " . $_SESSION['AuthHashGeneratedAt']. " using $authKey" );
|
||||||
#} else {
|
#} else {
|
||||||
#Logger::Debug("Using cached auth " . $_SESSION['AuthHash'] ." beacuse generatedat:" . $_SESSION['AuthHashGeneratedAt'] . ' < now:'. $time . ' - ' . ZM_AUTH_HASH_TTL . ' * 1800 = '. $mintime);
|
#ZM\Logger::Debug("Using cached auth " . $_SESSION['AuthHash'] ." beacuse generatedat:" . $_SESSION['AuthHashGeneratedAt'] . ' < now:'. $time . ' - ' . ZM_AUTH_HASH_TTL . ' * 1800 = '. $mintime);
|
||||||
} # end if AuthHash is not cached
|
} # end if AuthHash is not cached
|
||||||
return $_SESSION['AuthHash'.$_SESSION['remoteAddr']];
|
return $_SESSION['AuthHash'.$_SESSION['remoteAddr']];
|
||||||
} # end if using AUTH and AUTH_RELAY
|
} # end if using AUTH and AUTH_RELAY
|
||||||
|
|
|
@ -138,7 +138,7 @@ define( 'MYSQL_FMT_DATETIME_SHORT', '%y/%m/%d %H:%i:%S' ); // MySQL date_format
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
require_once( 'logger.php' );
|
require_once( 'logger.php' );
|
||||||
loadConfig();
|
loadConfig();
|
||||||
Logger::fetch()->initialise();
|
ZM\Logger::fetch()->initialise();
|
||||||
|
|
||||||
$GLOBALS['defaultUser'] = array(
|
$GLOBALS['defaultUser'] = array(
|
||||||
'Username' => 'admin',
|
'Username' => 'admin',
|
||||||
|
|
|
@ -93,7 +93,7 @@ function dbLog( $sql, $update=false ) {
|
||||||
global $dbLogLevel;
|
global $dbLogLevel;
|
||||||
$noExecute = $update && ($dbLogLevel >= DB_LOG_DEBUG);
|
$noExecute = $update && ($dbLogLevel >= DB_LOG_DEBUG);
|
||||||
if ( $dbLogLevel > DB_LOG_OFF )
|
if ( $dbLogLevel > DB_LOG_OFF )
|
||||||
Logger::Debug( "SQL-LOG: $sql".($noExecute?" (not executed)":"") );
|
ZM\Logger::Debug( "SQL-LOG: $sql".($noExecute?" (not executed)":"") );
|
||||||
return( $noExecute );
|
return( $noExecute );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ function dbError( $sql ) {
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
$message = "SQL-ERR '".implode("\n",$dbConn->errorInfo())."', statement was '".$sql."'";
|
$message = "SQL-ERR '".implode("\n",$dbConn->errorInfo())."', statement was '".$sql."'";
|
||||||
Error($message);
|
ZM\Error($message);
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,32 +130,32 @@ function dbQuery( $sql, $params=NULL ) {
|
||||||
try {
|
try {
|
||||||
if ( isset($params) ) {
|
if ( isset($params) ) {
|
||||||
if ( ! $result = $dbConn->prepare( $sql ) ) {
|
if ( ! $result = $dbConn->prepare( $sql ) ) {
|
||||||
Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
|
ZM\Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $result->execute( $params ) ) {
|
if ( ! $result->execute( $params ) ) {
|
||||||
Error("SQL: Error executing $sql: " . implode(',', $result->errorInfo() ) );
|
ZM\Error("SQL: Error executing $sql: " . implode(',', $result->errorInfo() ) );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( defined('ZM_DB_DEBUG') ) {
|
if ( defined('ZM_DB_DEBUG') ) {
|
||||||
Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') );
|
ZM\Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') );
|
||||||
}
|
}
|
||||||
$result = $dbConn->query($sql);
|
$result = $dbConn->query($sql);
|
||||||
if ( ! $result ) {
|
if ( ! $result ) {
|
||||||
Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
|
ZM\Error("SQL: Error preparing $sql: " . $pdo->errorInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( defined('ZM_DB_DEBUG') ) {
|
if ( defined('ZM_DB_DEBUG') ) {
|
||||||
if ( $params )
|
if ( $params )
|
||||||
Logger::Debug("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() );
|
ZM\Logger::Debug("SQL: $sql" . implode(',',$params) . ' rows: '.$result->rowCount() );
|
||||||
else
|
else
|
||||||
Logger::Debug("SQL: $sql: rows:" . $result->rowCount() );
|
ZM\Logger::Debug("SQL: $sql: rows:" . $result->rowCount() );
|
||||||
}
|
}
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):'') );
|
ZM\Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . ($params?implode(',',$params):'') );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -164,7 +164,7 @@ function dbQuery( $sql, $params=NULL ) {
|
||||||
function dbFetchOne( $sql, $col=false, $params=NULL ) {
|
function dbFetchOne( $sql, $col=false, $params=NULL ) {
|
||||||
$result = dbQuery( $sql, $params );
|
$result = dbQuery( $sql, $params );
|
||||||
if ( ! $result ) {
|
if ( ! $result ) {
|
||||||
Error( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" . ( $params ? 'params: ' . join(',',$params) : '' ) );
|
ZM\Error( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" . ( $params ? 'params: ' . join(',',$params) : '' ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( ! $result->rowCount() ) {
|
if ( ! $result->rowCount() ) {
|
||||||
|
@ -175,7 +175,7 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) {
|
||||||
if ( $result && $dbRow = $result->fetch(PDO::FETCH_ASSOC) ) {
|
if ( $result && $dbRow = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
if ( $col ) {
|
if ( $col ) {
|
||||||
if ( ! array_key_exists($col, $dbRow) ) {
|
if ( ! array_key_exists($col, $dbRow) ) {
|
||||||
Warning("$col does not exist in the returned row " . print_r($dbRow, true));
|
ZM\Warning("$col does not exist in the returned row " . print_r($dbRow, true));
|
||||||
}
|
}
|
||||||
return $dbRow[$col];
|
return $dbRow[$col];
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) {
|
||||||
function dbFetchAll( $sql, $col=false, $params=NULL ) {
|
function dbFetchAll( $sql, $col=false, $params=NULL ) {
|
||||||
$result = dbQuery( $sql, $params );
|
$result = dbQuery( $sql, $params );
|
||||||
if ( ! $result ) {
|
if ( ! $result ) {
|
||||||
Error( "SQL-ERR dbFetchAll no result, statement was '".$sql."'" . ( $params ? 'params: ' .join(',', $params) : '' ) );
|
ZM\Error( "SQL-ERR dbFetchAll no result, statement was '".$sql."'" . ( $params ? 'params: ' .join(',', $params) : '' ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ function getTableDescription( $table, $asString=1 ) {
|
||||||
//$desc['minLength'] = -128;
|
//$desc['minLength'] = -128;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
Error( "Unexpected text qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
|
ZM\Error( "Unexpected text qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif ( preg_match( "/^(enum|set)\((.*)\)$/", $row['Type'], $matches ) ) {
|
} elseif ( preg_match( "/^(enum|set)\((.*)\)$/", $row['Type'], $matches ) ) {
|
||||||
|
@ -326,7 +326,7 @@ function getTableDescription( $table, $asString=1 ) {
|
||||||
//$desc['maxValue'] = 127;
|
//$desc['maxValue'] = 127;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
Error( "Unexpected integer qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
|
ZM\Error( "Unexpected integer qualifier '".$matches[1]."' found for field '".$row['Field']."' in table '".$table."'" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( !empty($matches[1]) )
|
if ( !empty($matches[1]) )
|
||||||
|
@ -361,7 +361,7 @@ function getTableDescription( $table, $asString=1 ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error( "Can't parse database type '".$row['Type']."' found for field '".$row['Field']."' in table '".$table."'" );
|
ZM\Error( "Can't parse database type '".$row['Type']."' found for field '".$row['Field']."' in table '".$table."'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $asString )
|
if ( $asString )
|
||||||
|
|
|
@ -90,12 +90,12 @@ function CORSHeaders() {
|
||||||
|
|
||||||
# The following is left for future reference/use.
|
# The following is left for future reference/use.
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$Servers = Server::find();
|
$Servers = ZM\Server::find();
|
||||||
if ( sizeof($Servers) < 1 ) {
|
if ( sizeof($Servers) < 1 ) {
|
||||||
# Only need CORSHeaders in the event that there are multiple servers in use.
|
# Only need CORSHeaders in the event that there are multiple servers in use.
|
||||||
# ICON: Might not be true. multi-port?
|
# ICON: Might not be true. multi-port?
|
||||||
if ( ZM_MIN_STREAMING_PORT ) {
|
if ( ZM_MIN_STREAMING_PORT ) {
|
||||||
Logger::Debug("Setting default Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
|
ZM\Logger::Debug('Setting default Access-Control-Allow-Origin from ' . $_SERVER['HTTP_ORIGIN']);
|
||||||
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
|
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
|
||||||
header('Access-Control-Allow-Headers: x-requested-with,x-request');
|
header('Access-Control-Allow-Headers: x-requested-with,x-request');
|
||||||
}
|
}
|
||||||
|
@ -108,14 +108,14 @@ function CORSHeaders() {
|
||||||
preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN'])
|
preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN'])
|
||||||
) {
|
) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
|
ZM\Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
|
||||||
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
|
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
|
||||||
header('Access-Control-Allow-Headers: x-requested-with,x-request');
|
header('Access-Control-Allow-Headers: x-requested-with,x-request');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !$valid ) {
|
if ( !$valid ) {
|
||||||
Warning($_SERVER['HTTP_ORIGIN'] . ' is not found in servers list.');
|
ZM\Warning($_SERVER['HTTP_ORIGIN'] . ' is not found in servers list.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ function getZmuCommand( $args ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEventDefaultVideoPath( $event ) {
|
function getEventDefaultVideoPath( $event ) {
|
||||||
$Event = new Event( $event );
|
$Event = new ZM\Event( $event );
|
||||||
return $Event->getStreamSrc( array( 'mode'=>'mpeg', 'format'=>'h264' ) );
|
return $Event->getStreamSrc( array( 'mode'=>'mpeg', 'format'=>'h264' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,15 +424,15 @@ function deletePath( $path ) {
|
||||||
function deleteEvent( $event ) {
|
function deleteEvent( $event ) {
|
||||||
|
|
||||||
if ( empty($event) ) {
|
if ( empty($event) ) {
|
||||||
Error( 'Empty event passed to deleteEvent.');
|
ZM\Error('Empty event passed to deleteEvent.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gettype($event) != 'array' ) {
|
if ( gettype($event) != 'array' ) {
|
||||||
# $event could be an eid, so turn it into an event hash
|
# $event could be an eid, so turn it into an event hash
|
||||||
$event = new Event( $event );
|
$event = new ZM\Event( $event );
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("Event type: " . gettype($event));
|
ZM\Logger::Debug("Event type: " . gettype($event));
|
||||||
}
|
}
|
||||||
|
|
||||||
global $user;
|
global $user;
|
||||||
|
@ -527,7 +527,7 @@ function htmlOptions($contents, $values) {
|
||||||
|
|
||||||
if ( isset($option['disabled']) ) {
|
if ( isset($option['disabled']) ) {
|
||||||
$disabled = $option['disabled'];
|
$disabled = $option['disabled'];
|
||||||
Error("Setting to disabled");
|
ZM\Error("Setting to disabled");
|
||||||
}
|
}
|
||||||
} else if ( is_object($option) ) {
|
} else if ( is_object($option) ) {
|
||||||
$text = $option->Name();
|
$text = $option->Name();
|
||||||
|
@ -556,7 +556,7 @@ function buildSelect( $name, $contents, $behaviours=false ) {
|
||||||
elseif ( isset($_REQUEST[$arr]) )
|
elseif ( isset($_REQUEST[$arr]) )
|
||||||
$value = $_REQUEST[$arr];
|
$value = $_REQUEST[$arr];
|
||||||
if ( !preg_match_all( '/\[\s*[\'"]?(\w+)["\']?\s*\]/', $matches[2], $matches ) ) {
|
if ( !preg_match_all( '/\[\s*[\'"]?(\w+)["\']?\s*\]/', $matches[2], $matches ) ) {
|
||||||
Fatal( "Can't parse selector '$name'" );
|
ZM\Fatal( "Can't parse selector '$name'" );
|
||||||
}
|
}
|
||||||
for ( $i = 0; $i < count($matches[1]); $i++ ) {
|
for ( $i = 0; $i < count($matches[1]); $i++ ) {
|
||||||
$idx = $matches[1][$i];
|
$idx = $matches[1][$i];
|
||||||
|
@ -833,17 +833,17 @@ function daemonControl( $command, $daemon=false, $args=false ) {
|
||||||
}
|
}
|
||||||
$string = escapeshellcmd( $string );
|
$string = escapeshellcmd( $string );
|
||||||
#$string .= ' 2>/dev/null >&- <&- >/dev/null';
|
#$string .= ' 2>/dev/null >&- <&- >/dev/null';
|
||||||
Logger::Debug("daemonControl $string");
|
ZM\Logger::Debug("daemonControl $string");
|
||||||
exec( $string );
|
exec( $string );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmcControl($monitor, $mode=false) {
|
function zmcControl($monitor, $mode=false) {
|
||||||
$Monitor = new Monitor( $monitor );
|
$Monitor = new ZM\Monitor( $monitor );
|
||||||
return $Monitor->zmcControl($mode);
|
return $Monitor->zmcControl($mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmaControl($monitor, $mode=false) {
|
function zmaControl($monitor, $mode=false) {
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new ZM\Monitor($monitor);
|
||||||
return $Monitor->zmaControl($mode);
|
return $Monitor->zmaControl($mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ function zmaCheck( $monitor ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
||||||
$Event = new Event( $event );
|
$Event = new ZM\Event( $event );
|
||||||
return $Event->getImageSrc( $frame, $scale, $captureOnly, $overwrite );
|
return $Event->getImageSrc( $frame, $scale, $captureOnly, $overwrite );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,7 +940,7 @@ function createListThumbnail( $event, $overwrite=false ) {
|
||||||
$scale = (SCALE_BASE*ZM_WEB_LIST_THUMB_HEIGHT)/$event['Height'];
|
$scale = (SCALE_BASE*ZM_WEB_LIST_THUMB_HEIGHT)/$event['Height'];
|
||||||
$thumbWidth = reScale( $event['Width'], $scale );
|
$thumbWidth = reScale( $event['Width'], $scale );
|
||||||
} else {
|
} else {
|
||||||
Fatal( "No thumbnail width or height specified, please check in Options->Web" );
|
ZM\Fatal( "No thumbnail width or height specified, please check in Options->Web" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$imageData = getImageSrc( $event, $frame, $scale, false, $overwrite );
|
$imageData = getImageSrc( $event, $frame, $scale, false, $overwrite );
|
||||||
|
@ -1196,11 +1196,11 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
if ( ! $StorageArea ) {
|
if ( ! $StorageArea ) {
|
||||||
for ( $j = 0; $j < count($terms); $j++ ) {
|
for ( $j = 0; $j < count($terms); $j++ ) {
|
||||||
if ( isset($terms[$j]['attr']) and $terms[$j]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
|
if ( isset($terms[$j]['attr']) and $terms[$j]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
|
||||||
$StorageArea = Storage::find_one(array('Id'=>$terms[$j]['val']));
|
$StorageArea = ZM\Storage::find_one(array('Id'=>$terms[$j]['val']));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end foreach remaining term
|
} // end foreach remaining term
|
||||||
if ( ! $StorageArea ) $StorageArea = new Storage();
|
if ( ! $StorageArea ) $StorageArea = new ZM\Storage();
|
||||||
} // end no StorageArea found yet
|
} // end no StorageArea found yet
|
||||||
|
|
||||||
$filter['sql'] .= getDiskPercent( $StorageArea->Path() );
|
$filter['sql'] .= getDiskPercent( $StorageArea->Path() );
|
||||||
|
@ -1210,7 +1210,7 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
if ( ! $StorageArea ) {
|
if ( ! $StorageArea ) {
|
||||||
for ( $j = $i; $j < count($terms); $j++ ) {
|
for ( $j = $i; $j < count($terms); $j++ ) {
|
||||||
if ( isset($terms[$i]['attr']) and $terms[$i]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
|
if ( isset($terms[$i]['attr']) and $terms[$i]['attr'] == 'StorageId' and isset($terms[$j]['val']) ) {
|
||||||
$StorageArea = Storage::find_one(array('Id'=>$terms[$j]['val']));
|
$StorageArea = ZM\Storage::find_one(array('Id'=>$terms[$j]['val']));
|
||||||
}
|
}
|
||||||
} // end foreach remaining term
|
} // end foreach remaining term
|
||||||
} // end no StorageArea found yet
|
} // end no StorageArea found yet
|
||||||
|
@ -1242,7 +1242,7 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'StorageId':
|
case 'StorageId':
|
||||||
$StorageArea = Storage::find_one(array('Id'=>$value));
|
$StorageArea = ZM\Storage::find_one(array('Id'=>$value));
|
||||||
if ( $value != 'NULL' )
|
if ( $value != 'NULL' )
|
||||||
$value = dbEscape($value);
|
$value = dbEscape($value);
|
||||||
break;
|
break;
|
||||||
|
@ -1462,7 +1462,7 @@ function getDiskPercent($path = ZM_DIR_EVENTS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiskBlocks() {
|
function getDiskBlocks() {
|
||||||
if ( ! $StorageArea ) $StorageArea = new Storage();
|
if ( ! $StorageArea ) $StorageArea = new ZM\Storage();
|
||||||
$df = shell_exec( 'df '.escapeshellarg($StorageArea->Path() ));
|
$df = shell_exec( 'df '.escapeshellarg($StorageArea->Path() ));
|
||||||
$space = -1;
|
$space = -1;
|
||||||
if ( preg_match( '/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches ) )
|
if ( preg_match( '/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches ) )
|
||||||
|
@ -1847,17 +1847,17 @@ function coordsToPoints( $coords ) {
|
||||||
function limitPoints( &$points, $min_x, $min_y, $max_x, $max_y ) {
|
function limitPoints( &$points, $min_x, $min_y, $max_x, $max_y ) {
|
||||||
foreach ( $points as &$point ) {
|
foreach ( $points as &$point ) {
|
||||||
if ( $point['x'] < $min_x ) {
|
if ( $point['x'] < $min_x ) {
|
||||||
Logger::Debug('Limiting point x'.$point['x'].' to min_x ' . $min_x );
|
ZM\Logger::Debug('Limiting point x'.$point['x'].' to min_x ' . $min_x );
|
||||||
$point['x'] = $min_x;
|
$point['x'] = $min_x;
|
||||||
} else if ( $point['x'] > $max_x ) {
|
} else if ( $point['x'] > $max_x ) {
|
||||||
Logger::Debug('Limiting point x'.$point['x'].' to max_x ' . $max_x );
|
ZM\Logger::Debug('Limiting point x'.$point['x'].' to max_x ' . $max_x );
|
||||||
$point['x'] = $max_x;
|
$point['x'] = $max_x;
|
||||||
}
|
}
|
||||||
if ( $point['y'] < $min_y ) {
|
if ( $point['y'] < $min_y ) {
|
||||||
Logger::Debug('Limiting point y'.$point['y'].' to min_y ' . $min_y );
|
ZM\Logger::Debug('Limiting point y'.$point['y'].' to min_y ' . $min_y );
|
||||||
$point['y'] = $min_y;
|
$point['y'] = $min_y;
|
||||||
} else if ( $point['y'] > $max_y ) {
|
} else if ( $point['y'] > $max_y ) {
|
||||||
Logger::Debug('Limiting point y'.$point['y'].' to max_y ' . $max_y );
|
ZM\Logger::Debug('Limiting point y'.$point['y'].' to max_y ' . $max_y );
|
||||||
$point['y'] = $max_y;
|
$point['y'] = $max_y;
|
||||||
}
|
}
|
||||||
} // end foreach point
|
} // end foreach point
|
||||||
|
@ -1912,13 +1912,13 @@ function initX10Status() {
|
||||||
if ( !isset($x10_status) ) {
|
if ( !isset($x10_status) ) {
|
||||||
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
|
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
|
||||||
if ( $socket < 0 ) {
|
if ( $socket < 0 ) {
|
||||||
Fatal( 'socket_create() failed: '.socket_strerror($socket) );
|
ZM\Fatal( 'socket_create() failed: '.socket_strerror($socket) );
|
||||||
}
|
}
|
||||||
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
|
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
|
||||||
if ( @socket_connect( $socket, $sock_file ) ) {
|
if ( @socket_connect( $socket, $sock_file ) ) {
|
||||||
$command = 'status';
|
$command = 'status';
|
||||||
if ( !socket_write( $socket, $command ) ) {
|
if ( !socket_write( $socket, $command ) ) {
|
||||||
Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
|
ZM\Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
|
||||||
}
|
}
|
||||||
socket_shutdown( $socket, 1 );
|
socket_shutdown( $socket, 1 );
|
||||||
$x10Output = '';
|
$x10Output = '';
|
||||||
|
@ -1954,13 +1954,13 @@ function getDeviceStatusX10( $key ) {
|
||||||
function setDeviceStatusX10( $key, $status ) {
|
function setDeviceStatusX10( $key, $status ) {
|
||||||
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
|
$socket = socket_create( AF_UNIX, SOCK_STREAM, 0 );
|
||||||
if ( $socket < 0 ) {
|
if ( $socket < 0 ) {
|
||||||
Fatal( 'socket_create() failed: '.socket_strerror($socket) );
|
ZM\Fatal( 'socket_create() failed: '.socket_strerror($socket) );
|
||||||
}
|
}
|
||||||
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
|
$sock_file = ZM_PATH_SOCKS.'/zmx10.sock';
|
||||||
if ( @socket_connect( $socket, $sock_file ) ) {
|
if ( @socket_connect( $socket, $sock_file ) ) {
|
||||||
$command = "$status;$key";
|
$command = "$status;$key";
|
||||||
if ( !socket_write( $socket, $command ) ) {
|
if ( !socket_write( $socket, $command ) ) {
|
||||||
Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
|
ZM\Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socket)) );
|
||||||
}
|
}
|
||||||
socket_shutdown( $socket, 1 );
|
socket_shutdown( $socket, 1 );
|
||||||
$x10Response = socket_read( $socket, 256 );
|
$x10Response = socket_read( $socket, 256 );
|
||||||
|
@ -1983,18 +1983,18 @@ function logState() {
|
||||||
$state = 'ok';
|
$state = 'ok';
|
||||||
|
|
||||||
$levelCounts = array(
|
$levelCounts = array(
|
||||||
Logger::FATAL => array( ZM_LOG_ALERT_FAT_COUNT, ZM_LOG_ALARM_FAT_COUNT ),
|
ZM\Logger::FATAL => array( ZM_LOG_ALERT_FAT_COUNT, ZM_LOG_ALARM_FAT_COUNT ),
|
||||||
Logger::ERROR => array( ZM_LOG_ALERT_ERR_COUNT, ZM_LOG_ALARM_ERR_COUNT ),
|
ZM\Logger::ERROR => array( ZM_LOG_ALERT_ERR_COUNT, ZM_LOG_ALARM_ERR_COUNT ),
|
||||||
Logger::WARNING => array( ZM_LOG_ALERT_WAR_COUNT, ZM_LOG_ALARM_WAR_COUNT ),
|
ZM\Logger::WARNING => array( ZM_LOG_ALERT_WAR_COUNT, ZM_LOG_ALARM_WAR_COUNT ),
|
||||||
);
|
);
|
||||||
|
|
||||||
# This is an expensive request, as it has to hit every row of the Logs Table
|
# This is an expensive request, as it has to hit every row of the Logs Table
|
||||||
$sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
|
$sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.ZM\Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC';
|
||||||
$counts = dbFetchAll($sql);
|
$counts = dbFetchAll($sql);
|
||||||
if ( $counts ) {
|
if ( $counts ) {
|
||||||
foreach ( $counts as $count ) {
|
foreach ( $counts as $count ) {
|
||||||
if ( $count['Level'] <= Logger::PANIC )
|
if ( $count['Level'] <= ZM\Logger::PANIC )
|
||||||
$count['Level'] = Logger::FATAL;
|
$count['Level'] = ZM\Logger::FATAL;
|
||||||
if ( !($levelCount = $levelCounts[$count['Level']]) ) {
|
if ( !($levelCount = $levelCounts[$count['Level']]) ) {
|
||||||
Error('Unexpected Log level '.$count['Level']);
|
Error('Unexpected Log level '.$count['Level']);
|
||||||
next;
|
next;
|
||||||
|
@ -2026,15 +2026,15 @@ function checkJsonError($value) {
|
||||||
$value = var_export($value,true);
|
$value = var_export($value,true);
|
||||||
switch( json_last_error() ) {
|
switch( json_last_error() ) {
|
||||||
case JSON_ERROR_DEPTH :
|
case JSON_ERROR_DEPTH :
|
||||||
Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" );
|
ZM\Fatal( "Unable to decode JSON string '$value', maximum stack depth exceeded" );
|
||||||
case JSON_ERROR_CTRL_CHAR :
|
case JSON_ERROR_CTRL_CHAR :
|
||||||
Fatal( "Unable to decode JSON string '$value', unexpected control character found" );
|
ZM\Fatal( "Unable to decode JSON string '$value', unexpected control character found" );
|
||||||
case JSON_ERROR_STATE_MISMATCH :
|
case JSON_ERROR_STATE_MISMATCH :
|
||||||
Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" );
|
ZM\Fatal( "Unable to decode JSON string '$value', invalid or malformed JSON" );
|
||||||
case JSON_ERROR_SYNTAX :
|
case JSON_ERROR_SYNTAX :
|
||||||
Fatal( "Unable to decode JSON string '$value', syntax error" );
|
ZM\Fatal( "Unable to decode JSON string '$value', syntax error" );
|
||||||
default :
|
default :
|
||||||
Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() );
|
ZM\Fatal( "Unable to decode JSON string '$value', unexpected error ".json_last_error() );
|
||||||
case JSON_ERROR_NONE:
|
case JSON_ERROR_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2122,7 +2122,7 @@ define( 'HTTP_STATUS_BAD_REQUEST', 400 );
|
||||||
define( 'HTTP_STATUS_FORBIDDEN', 403 );
|
define( 'HTTP_STATUS_FORBIDDEN', 403 );
|
||||||
|
|
||||||
function ajaxError( $message, $code=HTTP_STATUS_OK ) {
|
function ajaxError( $message, $code=HTTP_STATUS_OK ) {
|
||||||
Error( $message );
|
ZM\Error( $message );
|
||||||
if ( function_exists( 'ajaxCleanup' ) )
|
if ( function_exists( 'ajaxCleanup' ) )
|
||||||
ajaxCleanup();
|
ajaxCleanup();
|
||||||
if ( $code == HTTP_STATUS_OK ) {
|
if ( $code == HTTP_STATUS_OK ) {
|
||||||
|
@ -2168,7 +2168,7 @@ function cache_bust( $file ) {
|
||||||
if ( file_exists(ZM_DIR_CACHE.'/'.$cacheFile) or symlink(ZM_PATH_WEB.'/'.$file, ZM_DIR_CACHE.'/'.$cacheFile) ) {
|
if ( file_exists(ZM_DIR_CACHE.'/'.$cacheFile) or symlink(ZM_PATH_WEB.'/'.$file, ZM_DIR_CACHE.'/'.$cacheFile) ) {
|
||||||
return 'cache/'.$cacheFile;
|
return 'cache/'.$cacheFile;
|
||||||
} else {
|
} else {
|
||||||
Warning("Failed linking $file to $cacheFile");
|
ZM\Warning("Failed linking $file to $cacheFile");
|
||||||
}
|
}
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -2292,7 +2292,7 @@ function getStreamHTML( $monitor, $options = array() ) {
|
||||||
$monitor->Name());
|
$monitor->Name());
|
||||||
} else {
|
} else {
|
||||||
if ( $options['mode'] == 'stream' ) {
|
if ( $options['mode'] == 'stream' ) {
|
||||||
Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
ZM\Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
||||||
}
|
}
|
||||||
$options['mode'] = 'single';
|
$options['mode'] = 'single';
|
||||||
$streamSrc = $monitor->getStreamSrc( $options );
|
$streamSrc = $monitor->getStreamSrc( $options );
|
||||||
|
@ -2308,7 +2308,7 @@ function getStreamMode( ) {
|
||||||
$streamMode = 'jpeg';
|
$streamMode = 'jpeg';
|
||||||
} else {
|
} else {
|
||||||
$streamMode = 'single';
|
$streamMode = 'single';
|
||||||
Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
ZM\Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
||||||
}
|
}
|
||||||
return $streamMode;
|
return $streamMode;
|
||||||
} // end function getStreamMode
|
} // end function getStreamMode
|
||||||
|
@ -2349,13 +2349,13 @@ function check_timezone() {
|
||||||
#");
|
#");
|
||||||
|
|
||||||
if ( $sys_tzoffset != $php_tzoffset )
|
if ( $sys_tzoffset != $php_tzoffset )
|
||||||
Fatal("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
|
ZM\Fatal("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
|
||||||
|
|
||||||
if ( $sys_tzoffset != $mysql_tzoffset )
|
if ( $sys_tzoffset != $mysql_tzoffset )
|
||||||
Error("ZoneMinder is not installed properly: mysql's timezone does not match the system timezone! Event lists will display incorrect times.");
|
ZM\Error("ZoneMinder is not installed properly: mysql's timezone does not match the system timezone! Event lists will display incorrect times.");
|
||||||
|
|
||||||
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone')))
|
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone')))
|
||||||
Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
|
ZM\Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ZM;
|
||||||
require_once( 'config.php' );
|
require_once( 'config.php' );
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
|
|
|
@ -8,7 +8,7 @@ function zm_session_start() {
|
||||||
$currentCookieParams = session_get_cookie_params();
|
$currentCookieParams = session_get_cookie_params();
|
||||||
$currentCookieParams['lifetime'] = ZM_COOKIE_LIFETIME;
|
$currentCookieParams['lifetime'] = ZM_COOKIE_LIFETIME;
|
||||||
|
|
||||||
Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
ZM\Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
||||||
session_set_cookie_params(
|
session_set_cookie_params(
|
||||||
$currentCookieParams['lifetime'],
|
$currentCookieParams['lifetime'],
|
||||||
$currentCookieParams['path'],
|
$currentCookieParams['path'],
|
||||||
|
@ -22,7 +22,7 @@ function zm_session_start() {
|
||||||
session_start();
|
session_start();
|
||||||
// Do not allow to use expired session ID
|
// Do not allow to use expired session ID
|
||||||
if ( !empty($_SESSION['last_time']) && ($_SESSION['last_time'] < (time() - 180)) ) {
|
if ( !empty($_SESSION['last_time']) && ($_SESSION['last_time'] < (time() - 180)) ) {
|
||||||
Info('Destroying session due to timeout. ');
|
ZM\Info('Destroying session due to timeout. ');
|
||||||
session_destroy();
|
session_destroy();
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
//
|
//
|
||||||
|
namespace ZM;
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
@ -219,7 +220,6 @@ if ( ZM_OPT_USE_AUTH and !isset($user) and ($view != 'login') ) {
|
||||||
$request = null;
|
$request = null;
|
||||||
} else if ( ZM_SHOW_PRIVACY && ($view != 'privacy') && ($view != 'options') && (!$request) && canEdit('System') ) {
|
} else if ( ZM_SHOW_PRIVACY && ($view != 'privacy') && ($view != 'options') && (!$request) && canEdit('System') ) {
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
Logger::Debug('Redirecting to privacy');
|
|
||||||
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=privacy';
|
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=privacy';
|
||||||
$request = null;
|
$request = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
.ptzControls input.ptzTextBtn {
|
.ptzControls input.ptzTextBtn {
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
|
.ptzControls button {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
.ptzControls .controlsPanel {
|
.ptzControls .controlsPanel {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
|
@ -21,104 +21,104 @@
|
||||||
function getControlCommands( $monitor ) {
|
function getControlCommands( $monitor ) {
|
||||||
$cmds = array();
|
$cmds = array();
|
||||||
|
|
||||||
$cmds['Wake'] = "wake";
|
$cmds['Wake'] = 'wake';
|
||||||
$cmds['Sleep'] = "sleep";
|
$cmds['Sleep'] = 'sleep';
|
||||||
$cmds['Reset'] = "reset";
|
$cmds['Reset'] = 'reset';
|
||||||
|
|
||||||
$cmds['PresetSet'] = "presetSet";
|
$cmds['PresetSet'] = 'presetSet';
|
||||||
$cmds['PresetGoto'] = "presetGoto";
|
$cmds['PresetGoto'] = 'presetGoto';
|
||||||
$cmds['PresetHome'] = "presetHome";
|
$cmds['PresetHome'] = 'presetHome';
|
||||||
|
|
||||||
if ( $monitor->CanZoom() ) {
|
if ( $monitor->CanZoom() ) {
|
||||||
if ( $monitor->CanZoomCon() )
|
if ( $monitor->CanZoomCon() )
|
||||||
$cmds['ZoomRoot'] = "zoomCon";
|
$cmds['ZoomRoot'] = 'zoomCon';
|
||||||
elseif ( $monitor->CanZoomRel() )
|
elseif ( $monitor->CanZoomRel() )
|
||||||
$cmds['ZoomRoot'] = "zoomRel";
|
$cmds['ZoomRoot'] = 'zoomRel';
|
||||||
elseif ( $monitor->CanZoomAbs() )
|
elseif ( $monitor->CanZoomAbs() )
|
||||||
$cmds['ZoomRoot'] = "zoomAbs";
|
$cmds['ZoomRoot'] = 'zoomAbs';
|
||||||
$cmds['ZoomTele'] = $cmds['ZoomRoot']."Tele";
|
$cmds['ZoomTele'] = $cmds['ZoomRoot'].'Tele';
|
||||||
$cmds['ZoomWide'] = $cmds['ZoomRoot']."Wide";
|
$cmds['ZoomWide'] = $cmds['ZoomRoot'].'Wide';
|
||||||
$cmds['ZoomStop'] = "zoomStop";
|
$cmds['ZoomStop'] = 'zoomStop';
|
||||||
$cmds['ZoomAuto'] = "zoomAuto";
|
$cmds['ZoomAuto'] = 'zoomAuto';
|
||||||
$cmds['ZoomMan'] = "zoomMan";
|
$cmds['ZoomMan'] = 'zoomMan';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $monitor->CanFocus() ) {
|
if ( $monitor->CanFocus() ) {
|
||||||
if ( $monitor->CanFocusCon() )
|
if ( $monitor->CanFocusCon() )
|
||||||
$cmds['FocusRoot'] = "focusCon";
|
$cmds['FocusRoot'] = 'focusCon';
|
||||||
elseif ( $monitor->CanFocusRel() )
|
elseif ( $monitor->CanFocusRel() )
|
||||||
$cmds['FocusRoot'] = "focusRel";
|
$cmds['FocusRoot'] = 'focusRel';
|
||||||
elseif ( $monitor->CanFocusAbs() )
|
elseif ( $monitor->CanFocusAbs() )
|
||||||
$cmds['FocusRoot'] = "focusAbs";
|
$cmds['FocusRoot'] = 'focusAbs';
|
||||||
$cmds['FocusFar'] = $cmds['FocusRoot']."Far";
|
$cmds['FocusFar'] = $cmds['FocusRoot'].'Far';
|
||||||
$cmds['FocusNear'] = $cmds['FocusRoot']."Near";
|
$cmds['FocusNear'] = $cmds['FocusRoot'].'Near';
|
||||||
$cmds['FocusStop'] = "focusStop";
|
$cmds['FocusStop'] = 'focusStop';
|
||||||
$cmds['FocusAuto'] = "focusAuto";
|
$cmds['FocusAuto'] = 'focusAuto';
|
||||||
$cmds['FocusMan'] = "focusMan";
|
$cmds['FocusMan'] = 'focusMan';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $monitor->CanIris() ) {
|
if ( $monitor->CanIris() ) {
|
||||||
if ( $monitor->CanIrisCon() )
|
if ( $monitor->CanIrisCon() )
|
||||||
$cmds['IrisRoot'] = "irisCon";
|
$cmds['IrisRoot'] = 'irisCon';
|
||||||
elseif ( $monitor->CanIrisRel() )
|
elseif ( $monitor->CanIrisRel() )
|
||||||
$cmds['IrisRoot'] = "irisRel";
|
$cmds['IrisRoot'] = 'irisRel';
|
||||||
elseif ( $monitor->CanIrisAbs() )
|
elseif ( $monitor->CanIrisAbs() )
|
||||||
$cmds['IrisRoot'] = "irisAbs";
|
$cmds['IrisRoot'] = 'irisAbs';
|
||||||
$cmds['IrisOpen'] = $cmds['IrisRoot']."Open";
|
$cmds['IrisOpen'] = $cmds['IrisRoot'].'Open';
|
||||||
$cmds['IrisClose'] = $cmds['IrisRoot']."Close";
|
$cmds['IrisClose'] = $cmds['IrisRoot'].'Close';
|
||||||
$cmds['IrisStop'] = "irisStop";
|
$cmds['IrisStop'] = 'irisStop';
|
||||||
$cmds['IrisAuto'] = "irisAuto";
|
$cmds['IrisAuto'] = 'irisAuto';
|
||||||
$cmds['IrisMan'] = "irisMan";
|
$cmds['IrisMan'] = 'irisMan';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $monitor->CanWhite() ) {
|
if ( $monitor->CanWhite() ) {
|
||||||
if ( $monitor->CanWhiteCon() )
|
if ( $monitor->CanWhiteCon() )
|
||||||
$cmds['WhiteRoot'] = "whiteCon";
|
$cmds['WhiteRoot'] = 'whiteCon';
|
||||||
elseif ( $monitor->CanWhiteRel() )
|
elseif ( $monitor->CanWhiteRel() )
|
||||||
$cmds['WhiteRoot'] = "whiteRel";
|
$cmds['WhiteRoot'] = 'whiteRel';
|
||||||
elseif ( $monitor->CanWhiteAbs() )
|
elseif ( $monitor->CanWhiteAbs() )
|
||||||
$cmds['WhiteRoot'] = "whiteAbs";
|
$cmds['WhiteRoot'] = 'whiteAbs';
|
||||||
$cmds['WhiteIn'] = $cmds['WhiteRoot']."In";
|
$cmds['WhiteIn'] = $cmds['WhiteRoot'].'In';
|
||||||
$cmds['WhiteOut'] = $cmds['WhiteRoot']."Out";
|
$cmds['WhiteOut'] = $cmds['WhiteRoot'].'Out';
|
||||||
$cmds['WhiteAuto'] = "whiteAuto";
|
$cmds['WhiteAuto'] = 'whiteAuto';
|
||||||
$cmds['WhiteMan'] = "whiteMan";
|
$cmds['WhiteMan'] = 'whiteMan';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $monitor->CanGain() ) {
|
if ( $monitor->CanGain() ) {
|
||||||
if ( $monitor->CanGainCon() )
|
if ( $monitor->CanGainCon() )
|
||||||
$cmds['GainRoot'] = "gainCon";
|
$cmds['GainRoot'] = 'gainCon';
|
||||||
elseif ( $monitor->CanGainRel() )
|
elseif ( $monitor->CanGainRel() )
|
||||||
$cmds['GainRoot'] = "gainRel";
|
$cmds['GainRoot'] = 'gainRel';
|
||||||
elseif ( $monitor->CanGainAbs() )
|
elseif ( $monitor->CanGainAbs() )
|
||||||
$cmds['GainRoot'] = "gainAbs";
|
$cmds['GainRoot'] = 'gainAbs';
|
||||||
$cmds['GainUp'] = $cmds['GainRoot']."Up";
|
$cmds['GainUp'] = $cmds['GainRoot'].'Up';
|
||||||
$cmds['GainDown'] = $cmds['GainRoot']."Down";
|
$cmds['GainDown'] = $cmds['GainRoot'].'Down';
|
||||||
$cmds['GainAuto'] = "gainAuto";
|
$cmds['GainAuto'] = 'gainAuto';
|
||||||
$cmds['GainMan'] = "gainMan";
|
$cmds['GainMan'] = 'gainMan';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $monitor->CanMove() ) {
|
if ( $monitor->CanMove() ) {
|
||||||
if ( $monitor->CanMoveCon() ) {
|
if ( $monitor->CanMoveCon() ) {
|
||||||
$cmds['MoveRoot'] = "moveCon";
|
$cmds['MoveRoot'] = 'moveCon';
|
||||||
$cmds['Center'] = "moveStop";
|
$cmds['Center'] = 'moveStop';
|
||||||
} elseif ( $monitor->CanMoveRel() ) {
|
} elseif ( $monitor->CanMoveRel() ) {
|
||||||
$cmds['MoveRoot'] = "moveRel";
|
$cmds['MoveRoot'] = 'moveRel';
|
||||||
$cmds['Center'] = $cmds['PresetHome'];
|
$cmds['Center'] = $cmds['PresetHome'];
|
||||||
} elseif ( $monitor->CanMoveAbs() ) {
|
} elseif ( $monitor->CanMoveAbs() ) {
|
||||||
$cmds['MoveRoot'] = "moveAbs";
|
$cmds['MoveRoot'] = 'moveAbs';
|
||||||
$cmds['Center'] = $cmds['PresetHome'];
|
$cmds['Center'] = $cmds['PresetHome'];
|
||||||
} else {
|
} else {
|
||||||
$cmds['MoveRoot'] = '';
|
$cmds['MoveRoot'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmds['MoveUp'] = $cmds['MoveRoot']."Up";
|
$cmds['MoveUp'] = $cmds['MoveRoot'].'Up';
|
||||||
$cmds['MoveDown'] = $cmds['MoveRoot']."Down";
|
$cmds['MoveDown'] = $cmds['MoveRoot'].'Down';
|
||||||
$cmds['MoveLeft'] = $cmds['MoveRoot']."Left";
|
$cmds['MoveLeft'] = $cmds['MoveRoot'].'Left';
|
||||||
$cmds['MoveRight'] = $cmds['MoveRoot']."Right";
|
$cmds['MoveRight'] = $cmds['MoveRoot'].'Right';
|
||||||
$cmds['MoveUpLeft'] = $cmds['MoveRoot']."UpLeft";
|
$cmds['MoveUpLeft'] = $cmds['MoveRoot'].'UpLeft';
|
||||||
$cmds['MoveUpRight'] = $cmds['MoveRoot']."UpRight";
|
$cmds['MoveUpRight'] = $cmds['MoveRoot'].'UpRight';
|
||||||
$cmds['MoveDownLeft'] = $cmds['MoveRoot']."DownLeft";
|
$cmds['MoveDownLeft'] = $cmds['MoveRoot'].'DownLeft';
|
||||||
$cmds['MoveDownRight'] = $cmds['MoveRoot']."DownRight";
|
$cmds['MoveDownRight'] = $cmds['MoveRoot'].'DownRight';
|
||||||
}
|
}
|
||||||
return( $cmds );
|
return( $cmds );
|
||||||
}
|
}
|
||||||
|
@ -128,15 +128,15 @@ function controlFocus( $monitor, $cmds ) {
|
||||||
?>
|
?>
|
||||||
<div class="arrowControl focusControls">
|
<div class="arrowControl focusControls">
|
||||||
<div class="arrowLabel"><?php echo translate('Near') ?></div>
|
<div class="arrowLabel"><?php echo translate('Near') ?></div>
|
||||||
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['FocusNear'] ?>',event,0,-1)"></div>
|
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['FocusNear'] ?>',event,0,-1)"></button>
|
||||||
<div class="arrowCenter"<?php if ( $monitor->CanFocusCon() ) { ?> onclick="controlCmd('<?php echo $cmds['FocusStop'] ?>')"<?php } ?>><?php echo translate('Focus') ?></div>
|
<button type="button" class="arrowCenter"<?php if ( $monitor->CanFocusCon() ) { ?> onclick="controlCmd('<?php echo $cmds['FocusStop'] ?>')"<?php } ?>><?php echo translate('Focus') ?></button>
|
||||||
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['FocusFar'] ?>',event,0,1)"></div>
|
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['FocusFar'] ?>',event,0,1)"></button>
|
||||||
<div class="arrowLabel"><?php echo translate('Far') ?></div>
|
<div class="arrowLabel"><?php echo translate('Far') ?></div>
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->CanAutoFocus() ) {
|
if ( $monitor->CanAutoFocus() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['FocusAuto'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusAuto'] ?>" onclick="controlCmd('<?php echo $cmds['FocusAuto'] ?>')"><?php echo translate('Auto') ?></button>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Man') ?>" onclick="controlCmd('<?php echo $cmds['FocusMan'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="<?php echo $cmds['FocusMan'] ?>" onclick="controlCmd('<?php echo $cmds['FocusMan'] ?>')"><?php echo translate('Man') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -152,15 +152,15 @@ function controlZoom( $monitor, $cmds ) {
|
||||||
?>
|
?>
|
||||||
<div class="arrowControl zoomControls">
|
<div class="arrowControl zoomControls">
|
||||||
<div class="arrowLabel"><?php echo translate('Tele') ?></div>
|
<div class="arrowLabel"><?php echo translate('Tele') ?></div>
|
||||||
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['ZoomTele'] ?>',event,0,-1)"></div>
|
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['ZoomTele'] ?>',event,0,-1)"></button>
|
||||||
<div class="arrowCenter"<?php if ( $monitor->CanZoomCon() ) { ?> onclick="controlCmd('<?php echo $cmds['ZoomStop'] ?>')"<?php } ?>><?php echo translate('Zoom') ?></div>
|
<button type="button" class="arrowCenter"<?php if ( $monitor->CanZoomCon() ) { ?> onclick="controlCmd('<?php echo $cmds['ZoomStop'] ?>')"<?php } ?>><?php echo translate('Zoom') ?></button>
|
||||||
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['ZoomWide'] ?>',event,0,1)"></div>
|
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['ZoomWide'] ?>',event,0,1)"></button>
|
||||||
<div class="arrowLabel"><?php echo translate('Wide') ?></div>
|
<div class="arrowLabel"><?php echo translate('Wide') ?></div>
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->CanAutoZoom() ) {
|
if ( $monitor->CanAutoZoom() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['ZoomAuto'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['ZoomAuto'] ?>')"><?php echo translate('Auto') ?></button>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Man') ?>" onclick="controlCmd('<?php echo $cmds['ZoomMan'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['ZoomMan'] ?>')"><?php echo translate('Man') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -175,15 +175,15 @@ function controlIris( $monitor, $cmds ) {
|
||||||
?>
|
?>
|
||||||
<div class="arrowControl irisControls">
|
<div class="arrowControl irisControls">
|
||||||
<div class="arrowLabel"><?php echo translate('Open') ?></div>
|
<div class="arrowLabel"><?php echo translate('Open') ?></div>
|
||||||
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['IrisOpen'] ?>',event,0,-1)"></div>
|
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['IrisOpen'] ?>',event,0,-1)"></button>
|
||||||
<div class="arrowCenter"<?php if ( $monitor->CanIrisCon() ) { ?> onclick="controlCmd('<?php echo $cmds['IrisStop'] ?>')"<?php } ?>><?php echo translate('Iris') ?></div>
|
<button type="button" class="arrowCenter"<?php if ( $monitor->CanIrisCon() ) { ?> onclick="controlCmd('<?php echo $cmds['IrisStop'] ?>')"<?php } ?>><?php echo translate('Iris') ?></button>
|
||||||
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['IrisClose'] ?>',event,0,1)"></div>
|
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['IrisClose'] ?>',event,0,1)"></button>
|
||||||
<div class="arrowLabel"><?php echo translate('Close') ?></div>
|
<div class="arrowLabel"><?php echo translate('Close') ?></div>
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->CanAutoIris() ) {
|
if ( $monitor->CanAutoIris() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['IrisAuto'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['IrisAuto'] ?>')"><?php echo translate('Auto') ?></button>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Man') ?>" onclick="controlCmd('<?php echo $cmds['IrisMan'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['IrisMan'] ?>')"><?php echo translate('Man') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -199,15 +199,15 @@ function controlWhite( $monitor, $cmds ) {
|
||||||
?>
|
?>
|
||||||
<div class="arrowControl whiteControls">
|
<div class="arrowControl whiteControls">
|
||||||
<div class="arrowLabel"><?php echo translate('In') ?></div>
|
<div class="arrowLabel"><?php echo translate('In') ?></div>
|
||||||
<div class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['WhiteIn'] ?>',event,0,-1)"></div>
|
<button type="button" class="longArrowBtn upBtn" onclick="controlCmd('<?php echo $cmds['WhiteIn'] ?>',event,0,-1)"></button>
|
||||||
<div class="arrowCenter"<?php if ( $monitor->CanWhiteCon() ) { ?> onclick="controlCmd('<?php echo $cmds['WhiteStop'] ?>')"<?php } ?>><?php echo translate('White') ?></div>
|
<button type="button" class="arrowCenter"<?php if ( $monitor->CanWhiteCon() ) { ?> onclick="controlCmd('<?php echo $cmds['WhiteStop'] ?>')"<?php } ?>><?php echo translate('White') ?></button>
|
||||||
<div class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['WhiteOut'] ?>',event,0,1)"></div>
|
<button type="button" class="longArrowBtn downBtn" onclick="controlCmd('<?php echo $cmds['WhiteOut'] ?>',event,0,1)"></button>
|
||||||
<div class="arrowLabel"><?php echo translate('Out') ?></div>
|
<div class="arrowLabel"><?php echo translate('Out') ?></div>
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->CanAutoWhite() ) {
|
if ( $monitor->CanAutoWhite() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Auto') ?>" onclick="controlCmd('<?php echo $cmds['WhiteAuto'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Auto" onclick="controlCmd('<?php echo $cmds['WhiteAuto'] ?>')"><?php echo translate('Auto') ?></button>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Man') ?>" onclick="controlCmd('<?php echo $cmds['WhiteMan'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Man" onclick="controlCmd('<?php echo $cmds['WhiteMan'] ?>')"><?php echo translate('Man') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -229,19 +229,19 @@ function controlPanTilt( $monitor, $cmds ) {
|
||||||
$hasTilt = $monitor->CanTilt();
|
$hasTilt = $monitor->CanTilt();
|
||||||
$hasDiag = $hasPan && $hasTilt && $monitor->CanMoveDiag();
|
$hasDiag = $hasPan && $hasTilt && $monitor->CanMoveDiag();
|
||||||
?>
|
?>
|
||||||
<div class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></div>
|
<button type="button" class="arrowBtn upLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpLeft'] ?>',event,-1,-1)"></button>
|
||||||
<div class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></div>
|
<button type="button" class="arrowBtn upBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUp'] ?>',event,0,-1)"></button>
|
||||||
<div class="arrowBtn upRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpRight'] ?>',event,1,-1)"></div>
|
<button type="button" class="arrowBtn upRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveUpRight'] ?>',event,1,-1)"></button>
|
||||||
<div class="arrowBtn leftBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveLeft'] ?>',event,1,0)"></div>
|
<button type="button" class="arrowBtn leftBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveLeft'] ?>',event,1,0)"></button>
|
||||||
<?php if ( isset($cmds['Center']) ) { ?>
|
<?php if ( isset($cmds['Center']) ) { ?>
|
||||||
<div class="arrowBtn centerBtn" onclick="controlCmd('<?php echo $cmds['Center'] ?>')"></div>
|
<button type="button" class="arrowBtn centerBtn" onclick="controlCmd('<?php echo $cmds['Center'] ?>')"></button>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<div class="arrowBtn NocenterBtn"></div>
|
<button type="button" class="arrowBtn NocenterBtn"></button>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="arrowBtn rightBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveRight'] ?>',event,1,0)"></div>
|
<button type="button" class="arrowBtn rightBtn<?php echo $hasPan?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveRight'] ?>',event,1,0)"></button>
|
||||||
<div class="arrowBtn downLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownLeft'] ?>',event,-1,1)"></div>
|
<button type="button" class="arrowBtn downLeftBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownLeft'] ?>',event,-1,1)"></button>
|
||||||
<div class="arrowBtn downBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDown'] ?>',event,0,1)"></div>
|
<button type="button" class="arrowBtn downBtn<?php echo $hasTilt?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDown'] ?>',event,0,1)"></button>
|
||||||
<div class="arrowBtn downRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownRight'] ?>',event,1,1)"></div>
|
<button type="button" class="arrowBtn downRightBtn<?php echo $hasDiag?'':' invisible' ?>" onclick="controlCmd('<?php echo $cmds['MoveDownRight'] ?>',event,1,1)"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
@ -270,7 +270,7 @@ function controlPresets( $monitor, $cmds ) {
|
||||||
<?php
|
<?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])?htmlentities($labels[$i]):'' ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/>
|
<button type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i])?htmlentities($labels[$i]):'' ?>" value="<?php echo $i ?>" onclick="controlCmd('<?php echo $cmds['PresetGoto'] ?><?php echo $i ?>');"/><?php echo $i ?></button>
|
||||||
<?php
|
<?php
|
||||||
if ( $i && (($i%$presetBreak) == 0) ) {
|
if ( $i && (($i%$presetBreak) == 0) ) {
|
||||||
?><br/><?php
|
?><br/><?php
|
||||||
|
@ -282,12 +282,12 @@ function controlPresets( $monitor, $cmds ) {
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->HasHomePreset() ) {
|
if ( $monitor->HasHomePreset() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/>
|
<button type="button" class="ptzTextBtn" value="<?php echo translate('Home') ?>" onclick="controlCmd('<?php echo $cmds['PresetHome'] ?>');"/>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ( canEdit('Monitors') && $monitor->CanSetPresets() ) {
|
if ( canEdit('Monitors') && $monitor->CanSetPresets() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn popup-link" value="<?php echo translate('Set') ?>" data-url="?view=controlpreset&mid=<?php echo $monitor->Id() ?>" data-window-name="zmPreset" data-window-tag="preset"/>
|
<button type="button" class="ptzTextBtn popup-link" value="<?php echo translate('Set') ?>" data-url="?view=controlpreset&mid=<?php echo $monitor->Id() ?>" data-window-name="zmPreset" data-window-tag="preset"/>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -308,17 +308,17 @@ function controlPower( $monitor, $cmds ) {
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->CanWake() ) {
|
if ( $monitor->CanWake() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Wake') ?>" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Wake" onclick="controlCmd('<?php echo $cmds['Wake'] ?>')"><?php echo translate('Wake') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ( $monitor->CanSleep() ) {
|
if ( $monitor->CanSleep() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Sleep') ?>" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Sleep" onclick="controlCmd('<?php echo $cmds['Sleep'] ?>')"><?php echo translate('Sleep') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ( $monitor->CanReset() ) {
|
if ( $monitor->CanReset() ) {
|
||||||
?>
|
?>
|
||||||
<input type="button" class="ptzTextBtn" value="<?php echo translate('Reset') ?>" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"/>
|
<button type="button" class="ptzTextBtn" value="Reset" onclick="controlCmd('<?php echo $cmds['Reset'] ?>')"><?php echo translate('Reset') ?></button>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -265,7 +265,7 @@ function getNavBarHTML($reload = null) {
|
||||||
<li><a href="?view=options"><?php echo translate('Options') ?></a></li>
|
<li><a href="?view=options"><?php echo translate('Options') ?></a></li>
|
||||||
<li>
|
<li>
|
||||||
<?php
|
<?php
|
||||||
if ( logToDatabase() > Logger::NOLOG ) {
|
if ( ZM\logToDatabase() > ZM\Logger::NOLOG ) {
|
||||||
if ( ! ZM_RUN_AUDIT ) {
|
if ( ! ZM_RUN_AUDIT ) {
|
||||||
# zmaudit can clean the logs, but if we aren't running it, then we should clecan them regularly
|
# zmaudit can clean the logs, but if we aren't running it, then we should clecan them regularly
|
||||||
dbQuery('DELETE FROM Logs WHERE TimeKey < unix_timestamp( NOW() - interval '.ZM_LOG_DATABASE_LIMIT.') LIMIT 100');
|
dbQuery('DELETE FROM Logs WHERE TimeKey < unix_timestamp( NOW() - interval '.ZM_LOG_DATABASE_LIMIT.') LIMIT 100');
|
||||||
|
@ -355,13 +355,13 @@ if ($reload == 'reload') ob_start();
|
||||||
?>
|
?>
|
||||||
<li><?php echo translate('Storage') ?>:
|
<li><?php echo translate('Storage') ?>:
|
||||||
<?php
|
<?php
|
||||||
$storage_areas = Storage::find();
|
$storage_areas = ZM\Storage::find();
|
||||||
$storage_paths = null;
|
$storage_paths = null;
|
||||||
foreach ( $storage_areas as $area ) {
|
foreach ( $storage_areas as $area ) {
|
||||||
$storage_paths[$area->Path()] = $area;
|
$storage_paths[$area->Path()] = $area;
|
||||||
}
|
}
|
||||||
if ( ! isset($storage_paths[ZM_DIR_EVENTS]) ) {
|
if ( ! isset($storage_paths[ZM_DIR_EVENTS]) ) {
|
||||||
array_push( $storage_areas, new Storage() );
|
array_push( $storage_areas, new ZM\Storage() );
|
||||||
}
|
}
|
||||||
$func = function($S){
|
$func = function($S){
|
||||||
$class = '';
|
$class = '';
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
var popupSizes = {
|
var popupSizes = {
|
||||||
'bandwidth': {'width': 300, 'height': 200},
|
'bandwidth': {'width': 300, 'height': 200},
|
||||||
'console': {'width': 750, 'height': 312},
|
'console': {'width': 750, 'height': 312},
|
||||||
'control': {'width': 380, 'height': 480},
|
'control': {'width': 480, 'height': 480},
|
||||||
'controlcaps': {'width': 780, 'height': 320},
|
'controlcaps': {'width': 780, 'height': 320},
|
||||||
'controlcap': {'width': 400, 'height': 400},
|
'controlcap': {'width': 400, 'height': 400},
|
||||||
'cycle': {'addWidth': 32, 'minWidth': 384, 'addHeight': 62},
|
'cycle': {'addWidth': 32, 'minWidth': 384, 'addHeight': 62},
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
$servers = Server::find(null, array('order'=>'lower(Name)'));
|
$servers = ZM\Server::find(null, array('order'=>'lower(Name)'));
|
||||||
$ServersById = array();
|
$ServersById = array();
|
||||||
foreach ( $servers as $S ) {
|
foreach ( $servers as $S ) {
|
||||||
$ServersById[$S->Id()] = $S;
|
$ServersById[$S->Id()] = $S;
|
||||||
|
@ -37,7 +37,7 @@ foreach ( array('Group','Function','ServerId','StorageId','Status','MonitorId','
|
||||||
}
|
}
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
$storage_areas = Storage::find();
|
$storage_areas = ZM\Storage::find();
|
||||||
$StorageById = array();
|
$StorageById = array();
|
||||||
foreach ( $storage_areas as $S ) {
|
foreach ( $storage_areas as $S ) {
|
||||||
$StorageById[$S->Id()] = $S;
|
$StorageById[$S->Id()] = $S;
|
||||||
|
@ -52,7 +52,7 @@ $html =
|
||||||
';
|
';
|
||||||
|
|
||||||
$GroupsById = array();
|
$GroupsById = array();
|
||||||
foreach ( Group::find() as $G ) {
|
foreach ( ZM\Group::find() as $G ) {
|
||||||
$GroupsById[$G->Id()] = $G;
|
$GroupsById[$G->Id()] = $G;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +61,13 @@ if ( count($GroupsById) ) {
|
||||||
$html .= '<span id="groupControl"><label>'. translate('Group') .'</label>';
|
$html .= '<span id="groupControl"><label>'. translate('Group') .'</label>';
|
||||||
# This will end up with the group_id of the deepest selection
|
# This will end up with the group_id of the deepest selection
|
||||||
$group_id = isset($_SESSION['Group']) ? $_SESSION['Group'] : null;
|
$group_id = isset($_SESSION['Group']) ? $_SESSION['Group'] : null;
|
||||||
$html .= Group::get_group_dropdown();
|
$html .= ZM\Group::get_group_dropdown();
|
||||||
$groupSql = Group::get_group_sql($group_id);
|
$groupSql = ZM\Group::get_group_sql($group_id);
|
||||||
$html .= '</span>';
|
$html .= '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$selected_monitor_ids = isset($_SESSION['MonitorId']) ? $_SESSION['MonitorId'] : array();
|
$selected_monitor_ids = isset($_SESSION['MonitorId']) ? $_SESSION['MonitorId'] : array();
|
||||||
if ( ! is_array( $selected_monitor_ids ) ) {
|
if ( ! is_array( $selected_monitor_ids ) ) {
|
||||||
Warning("Turning selected_monitor_ids into an array $selected_monitor_ids");
|
|
||||||
$selected_monitor_ids = array($selected_monitor_ids);
|
$selected_monitor_ids = array($selected_monitor_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,12 +188,12 @@ $html .= htmlSelect( 'Status[]', $status_options,
|
||||||
|
|
||||||
for ( $i = 0; $i < count($monitors); $i++ ) {
|
for ( $i = 0; $i < count($monitors); $i++ ) {
|
||||||
if ( !visibleMonitor($monitors[$i]['Id']) ) {
|
if ( !visibleMonitor($monitors[$i]['Id']) ) {
|
||||||
Warning('Monitor '.$monitors[$i]['Id'].' is not visible');
|
ZM\Logger::Warning('Monitor '.$monitors[$i]['Id'].' is not visible');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_SESSION['MonitorName']) ) {
|
if ( isset($_SESSION['MonitorName']) ) {
|
||||||
$Monitor = new Monitor($monitors[$i]);
|
$Monitor = new ZM\Monitor($monitors[$i]);
|
||||||
ini_set('track_errors', 'on');
|
ini_set('track_errors', 'on');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
$regexp = $_SESSION['MonitorName'];
|
$regexp = $_SESSION['MonitorName'];
|
||||||
|
@ -210,7 +209,7 @@ $html .= htmlSelect( 'Status[]', $status_options,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_SESSION['Source']) ) {
|
if ( isset($_SESSION['Source']) ) {
|
||||||
$Monitor = new Monitor($monitors[$i]);
|
$Monitor = new ZM\Monitor($monitors[$i]);
|
||||||
ini_set('track_errors', 'on');
|
ini_set('track_errors', 'on');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
$regexp = $_SESSION['Source'];
|
$regexp = $_SESSION['Source'];
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canEdit( 'Monitors' ) ) {
|
if ( !canEdit('Monitors') ) {
|
||||||
$view = 'error';
|
$view = 'error';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ xhtmlHeaders(__FILE__, translate('AddMonitors'));
|
||||||
<th>Group</th>
|
<th>Group</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr title="Example Data">
|
<tr title="Example Data">
|
||||||
<td>Example Name MN1-30 INQ37.01</td>
|
<td>Example Name Driveway</td>
|
||||||
<td>http://10.34.152.20:2001/?action=stream</td>
|
<td>http://192.168.1.0/?action=stream</td>
|
||||||
<td>MN1</td>
|
<td>MN1</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -80,7 +80,7 @@ xhtmlHeaders(__FILE__, translate('AddMonitors'));
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<?php
|
<?php
|
||||||
$servers = Server::find();
|
$servers = ZM\Server::find();
|
||||||
$ServersById = array();
|
$ServersById = array();
|
||||||
foreach ( $servers as $S ) {
|
foreach ( $servers as $S ) {
|
||||||
$ServersById[$S->Id()] = $S;
|
$ServersById[$S->Id()] = $S;
|
||||||
|
@ -92,7 +92,7 @@ xhtmlHeaders(__FILE__, translate('AddMonitors'));
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
$storage_areas = Storage::find();
|
$storage_areas = ZM\Storage::find();
|
||||||
$StorageById = array();
|
$StorageById = array();
|
||||||
foreach ( $storage_areas as $S ) {
|
foreach ( $storage_areas as $S ) {
|
||||||
$StorageById[$S->Id()] = $S;
|
$StorageById[$S->Id()] = $S;
|
||||||
|
|
|
@ -227,7 +227,7 @@ ob_end_clean();
|
||||||
echo $table_head;
|
echo $table_head;
|
||||||
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
$monitor = $displayMonitors[$monitor_i];
|
$monitor = $displayMonitors[$monitor_i];
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new ZM\Monitor($monitor);
|
||||||
|
|
||||||
if ( $monitor_i and ( $monitor_i % 100 == 0 ) ) {
|
if ( $monitor_i and ( $monitor_i % 100 == 0 ) ) {
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@ -272,7 +272,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
<span class="glyphicon glyphicon-dot <?php echo $dot_class ?>" aria-hidden="true"></span><a <?php echo ($stream_available ? 'href="?view=watch&mid='.$monitor['Id'].'">' : '>') . $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
<span class="glyphicon glyphicon-dot <?php echo $dot_class ?>" aria-hidden="true"></span><a <?php echo ($stream_available ? 'href="?view=watch&mid='.$monitor['Id'].'">' : '>') . $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
||||||
<?php echo implode('<br/>',
|
<?php echo implode('<br/>',
|
||||||
array_map(function($group_id){
|
array_map(function($group_id){
|
||||||
$Group = Group::find_one(array('Id'=>$group_id));
|
$Group = ZM\Group::find_one(array('Id'=>$group_id));
|
||||||
if ( $Group ) {
|
if ( $Group ) {
|
||||||
$Groups = $Group->Parents();
|
$Groups = $Group->Parents();
|
||||||
array_push( $Groups, $Group );
|
array_push( $Groups, $Group );
|
||||||
|
@ -302,7 +302,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
</div></td>
|
</div></td>
|
||||||
<?php
|
<?php
|
||||||
if ( count($servers) ) { ?>
|
if ( count($servers) ) { ?>
|
||||||
<td class="colServer"><?php $Server = isset($ServersById[$monitor['ServerId']]) ? $ServersById[$monitor['ServerId']] : new Server( $monitor['ServerId'] ); echo $Server->Name(); ?></td>
|
<td class="colServer"><?php $Server = isset($ServersById[$monitor['ServerId']]) ? $ServersById[$monitor['ServerId']] : new ZM\Server($monitor['ServerId']); echo $Server->Name(); ?></td>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
echo '<td class="colSource">'. makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$source_class.'">'.validHtmlStr($Monitor->Source()).'</span>', canEdit('Monitors') ).'</td>';
|
echo '<td class="colSource">'. makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$source_class.'">'.validHtmlStr($Monitor->Source()).'</span>', canEdit('Monitors') ).'</td>';
|
||||||
|
|
|
@ -46,7 +46,7 @@ foreach ( dbFetchAll($sql, false, $params) as $row ) {
|
||||||
foreach ( getSkinIncludes('includes/control_functions.php') as $includeFile )
|
foreach ( getSkinIncludes('includes/control_functions.php') as $includeFile )
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
|
|
||||||
$monitor = new Monitor($mid);
|
$monitor = new ZM\Monitor($mid);
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ foreach( $displayMonitors as &$row ) {
|
||||||
$row['PopupScale'] = reScale(SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
|
$row['PopupScale'] = reScale(SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
|
||||||
|
|
||||||
$row['connKey'] = generateConnKey();
|
$row['connKey'] = generateConnKey();
|
||||||
$monitors[] = new Monitor($row);
|
$monitors[] = new ZM\Monitor($row);
|
||||||
} # end foreach Monitor
|
} # end foreach Monitor
|
||||||
|
|
||||||
if ( $monitors ) {
|
if ( $monitors ) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ if ( !canView('Events') ) {
|
||||||
$eid = validInt( $_REQUEST['eid'] );
|
$eid = validInt( $_REQUEST['eid'] );
|
||||||
$fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1;
|
$fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1;
|
||||||
|
|
||||||
$Event = new Event( $eid );
|
$Event = new ZM\Event( $eid );
|
||||||
if ( $user['MonitorIds'] ) {
|
if ( $user['MonitorIds'] ) {
|
||||||
$monitor_ids = explode( ',', $user['MonitorIds'] );
|
$monitor_ids = explode( ',', $user['MonitorIds'] );
|
||||||
if ( count($monitor_ids) and ! in_array( $Event->MonitorId(), $monitor_ids ) ) {
|
if ( count($monitor_ids) and ! in_array( $Event->MonitorId(), $monitor_ids ) ) {
|
||||||
|
|
|
@ -80,12 +80,12 @@ $focusWindow = true;
|
||||||
|
|
||||||
if ( $_POST ) {
|
if ( $_POST ) {
|
||||||
// I think this is basically so that a refresh doesn't repost
|
// I think this is basically so that a refresh doesn't repost
|
||||||
Logger::Debug("Redirecting to " . $_SERVER['REQUEST_URI']);
|
ZM\Logger::Debug('Redirecting to ' . $_SERVER['REQUEST_URI']);
|
||||||
header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
|
header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage_areas = Storage::find();
|
$storage_areas = ZM\Storage::find();
|
||||||
$StorageById = array();
|
$StorageById = array();
|
||||||
foreach ( $storage_areas as $S ) {
|
foreach ( $storage_areas as $S ) {
|
||||||
$StorageById[$S->Id()] = $S;
|
$StorageById[$S->Id()] = $S;
|
||||||
|
@ -146,7 +146,7 @@ $disk_space_total = 0;
|
||||||
|
|
||||||
$results = dbQuery($eventsSql);
|
$results = dbQuery($eventsSql);
|
||||||
while ( $event_row = dbFetchNext($results) ) {
|
while ( $event_row = dbFetchNext($results) ) {
|
||||||
$event = new Event($event_row);
|
$event = new ZM\Event($event_row);
|
||||||
if ( $event_row['Archived'] )
|
if ( $event_row['Archived'] )
|
||||||
$archived = true;
|
$archived = true;
|
||||||
else
|
else
|
||||||
|
@ -248,7 +248,7 @@ while ( $event_row = dbFetchNext($results) ) {
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
} // end if ZM_WEB_LIST_THUMBS
|
} // end if ZM_WEB_LIST_THUMBS
|
||||||
?>
|
?>
|
||||||
<td class="colMark"><input type="checkbox" name="eids[]" value="<?php echo $event->Id() ?>" data-on-click-this="configureButton"/></td>
|
<td class="colMark"><input type="checkbox" name="eids[]" value="<?php echo $event->Id() ?>"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ if ( isset($_SESSION['export']) ) {
|
||||||
|
|
||||||
if (isset($_REQUEST['exportFormat'])) {
|
if (isset($_REQUEST['exportFormat'])) {
|
||||||
if (!in_array($_REQUEST['exportFormat'], array('zip', 'tar'))) {
|
if (!in_array($_REQUEST['exportFormat'], array('zip', 'tar'))) {
|
||||||
Error('Invalid exportFormat');
|
ZM\Error('Invalid exportFormat');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ foreach ( dbFetchAll('SELECT * FROM Filters ORDER BY Name') as $row ) {
|
||||||
$filterNames[$row['Id']] .= '&';
|
$filterNames[$row['Id']] .= '&';
|
||||||
|
|
||||||
if ( isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
if ( isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
||||||
$filter = new Filter($row);
|
$filter = new ZM\Filter($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $filter ) {
|
if ( ! $filter ) {
|
||||||
$filter = new Filter();
|
$filter = new ZM\Filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_REQUEST['sort_field']) && isset($_REQUEST['filter']) ) {
|
if ( isset($_REQUEST['sort_field']) && isset($_REQUEST['filter']) ) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ $eid = validInt($_REQUEST['eid']);
|
||||||
if ( !empty($_REQUEST['fid']) )
|
if ( !empty($_REQUEST['fid']) )
|
||||||
$fid = validInt($_REQUEST['fid']);
|
$fid = validInt($_REQUEST['fid']);
|
||||||
|
|
||||||
$Event = new Event($eid);
|
$Event = new ZM\Event($eid);
|
||||||
$Monitor = $Event->Monitor();
|
$Monitor = $Event->Monitor();
|
||||||
|
|
||||||
if ( !empty($fid) ) {
|
if ( !empty($fid) ) {
|
||||||
|
@ -39,7 +39,7 @@ if ( !empty($fid) ) {
|
||||||
} else {
|
} else {
|
||||||
$frame = dbFetchOne( 'SELECT * FROM Frames WHERE EventId = ? AND Score = ?', NULL, array( $eid, $Event->MaxScore() ) );
|
$frame = dbFetchOne( 'SELECT * FROM Frames WHERE EventId = ? AND Score = ?', NULL, array( $eid, $Event->MaxScore() ) );
|
||||||
}
|
}
|
||||||
$Frame = new Frame($frame);
|
$Frame = new ZM\Frame($frame);
|
||||||
|
|
||||||
$maxFid = $Event->Frames();
|
$maxFid = $Event->Frames();
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ $scale = $scale ?: "auto";
|
||||||
|
|
||||||
$imageData = $Event->getImageSrc( $frame, $scale, 0 );
|
$imageData = $Event->getImageSrc( $frame, $scale, 0 );
|
||||||
if ( ! $imageData ) {
|
if ( ! $imageData ) {
|
||||||
Error("No data found for Event $eid frame $fid");
|
ZM\Error("No data found for Event $eid frame $fid");
|
||||||
$imageData = array();
|
$imageData = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ if ( !canView('Events') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
require_once('includes/Frame.php');
|
require_once('includes/Frame.php');
|
||||||
$Event = new Event( $_REQUEST['eid'] );
|
$Event = new ZM\Event($_REQUEST['eid']);
|
||||||
|
|
||||||
$sql = 'SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId';
|
$sql = 'SELECT *, unix_timestamp( TimeStamp ) AS UnixTimeStamp FROM Frames WHERE EventID = ? ORDER BY FrameId';
|
||||||
$frames = dbFetchAll( $sql, NULL, array( $_REQUEST['eid'] ) );
|
$frames = dbFetchAll( $sql, NULL, array( $_REQUEST['eid'] ) );
|
||||||
|
@ -62,7 +62,7 @@ xhtmlHeaders(__FILE__, translate('Frames').' - '.$Event->Id() );
|
||||||
<?php
|
<?php
|
||||||
if ( count($frames) ) {
|
if ( count($frames) ) {
|
||||||
foreach ( $frames as $frame ) {
|
foreach ( $frames as $frame ) {
|
||||||
$Frame = new Frame( $frame );
|
$Frame = new ZM\Frame( $frame );
|
||||||
|
|
||||||
$class = strtolower($frame['Type']);
|
$class = strtolower($frame['Type']);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -24,9 +24,9 @@ if ( !canEdit('Groups') ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($_REQUEST['gid']) ) {
|
if ( !empty($_REQUEST['gid']) ) {
|
||||||
$newGroup = new Group($_REQUEST['gid']);
|
$newGroup = new ZM\Group($_REQUEST['gid']);
|
||||||
} else {
|
} else {
|
||||||
$newGroup = new Group();
|
$newGroup = new ZM\Group();
|
||||||
}
|
}
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Group').' - '.$newGroup->Name());
|
xhtmlHeaders(__FILE__, translate('Group').' - '.$newGroup->Name());
|
||||||
|
@ -51,7 +51,7 @@ xhtmlHeaders(__FILE__, translate('Group').' - '.$newGroup->Name());
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$Groups = array();
|
$Groups = array();
|
||||||
foreach ( Group::find() as $Group ) {
|
foreach ( ZM\Group::find() as $Group ) {
|
||||||
$Groups[$Group->Id()] = $Group;
|
$Groups[$Group->Id()] = $Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ $group_id = 0;
|
||||||
$max_depth = 0;
|
$max_depth = 0;
|
||||||
|
|
||||||
$Groups = array();
|
$Groups = array();
|
||||||
foreach ( Group::find() as $Group ) {
|
foreach ( ZM\Group::find() as $Group ) {
|
||||||
$Groups[$Group->Id()] = $Group;
|
$Groups[$Group->Id()] = $Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,21 +120,21 @@ echo " };\n";
|
||||||
|
|
||||||
echo "\nvar Storage = [];\n";
|
echo "\nvar Storage = [];\n";
|
||||||
$have_storage_zero = 0;
|
$have_storage_zero = 0;
|
||||||
foreach ( Storage::find() as $Storage ) {
|
foreach ( ZM\Storage::find() as $Storage ) {
|
||||||
echo 'Storage[' . $Storage->Id() . '] = ' . $Storage->to_json(). ";\n";
|
echo 'Storage[' . $Storage->Id() . '] = ' . $Storage->to_json(). ";\n";
|
||||||
if ( $Storage->Id() == 0 )
|
if ( $Storage->Id() == 0 )
|
||||||
$have_storage_zero = true;
|
$have_storage_zero = true;
|
||||||
}
|
}
|
||||||
if ( !$have_storage_zero ) {
|
if ( !$have_storage_zero ) {
|
||||||
$Storage = new Storage();
|
$Storage = new ZM\Storage();
|
||||||
echo 'Storage[0] = ' . $Storage->to_json(). ";\n";
|
echo 'Storage[0] = ' . $Storage->to_json(). ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\nvar Servers = [];\n";
|
echo "\nvar Servers = [];\n";
|
||||||
// Fall back to get Server paths, etc when no using multi-server mode
|
// Fall back to get Server paths, etc when no using multi-server mode
|
||||||
$Server = new Server();
|
$Server = new ZM\Server();
|
||||||
echo 'Servers[0] = new Server(' . $Server->to_json(). ");\n";
|
echo 'Servers[0] = new Server(' . $Server->to_json(). ");\n";
|
||||||
foreach ( Server::find() as $Server ) {
|
foreach ( ZM\Server::find() as $Server ) {
|
||||||
echo 'Servers[' . $Server->Id() . '] = new Server(' . $Server->to_json(). ");\n";
|
echo 'Servers[' . $Server->Id() . '] = new Server(' . $Server->to_json(). ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
function submitForm( element ) {
|
|
||||||
var form = element.form;
|
|
||||||
if ( form.option.selectedIndex == 0 ) {
|
|
||||||
form.view.value = currentView;
|
|
||||||
} else {
|
|
||||||
form.view.value = 'none';
|
|
||||||
}
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
function validateForm(form) {
|
function validateForm(form) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
if ( !form.elements['newServer[Name]'].value ) {
|
if ( !form.elements['newServer[Name]'].value ) {
|
||||||
errors[errors.length] = "You must supply a name";
|
errors[errors.length] = 'You must supply a name';
|
||||||
}
|
}
|
||||||
if ( errors.length ) {
|
if ( errors.length ) {
|
||||||
alert( errors.join( "\n" ) );
|
alert(errors.join("\n"));
|
||||||
return ( false );
|
return false;
|
||||||
}
|
}
|
||||||
return ( true );
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ if ( ! $Server ) {
|
||||||
|
|
||||||
$monitor = null;
|
$monitor = null;
|
||||||
if ( ! empty($_REQUEST['mid']) ) {
|
if ( ! empty($_REQUEST['mid']) ) {
|
||||||
$monitor = new Monitor( $_REQUEST['mid'] );
|
$monitor = new ZM\Monitor( $_REQUEST['mid'] );
|
||||||
if ( $monitor and ZM_OPT_X10 )
|
if ( $monitor and ZM_OPT_X10 )
|
||||||
$x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['mid']) );
|
$x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['mid']) );
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ if ( ! $monitor ) {
|
||||||
|
|
||||||
$nextId = getTableAutoInc( 'Monitors' );
|
$nextId = getTableAutoInc( 'Monitors' );
|
||||||
if ( isset( $_REQUEST['dupId'] ) ) {
|
if ( isset( $_REQUEST['dupId'] ) ) {
|
||||||
$monitor = new Monitor( $_REQUEST['dupId'] );
|
$monitor = new ZM\Monitor( $_REQUEST['dupId'] );
|
||||||
$monitor->GroupIds(); // have to load before we change the Id
|
$monitor->GroupIds(); // have to load before we change the Id
|
||||||
if ( ZM_OPT_X10 )
|
if ( ZM_OPT_X10 )
|
||||||
$x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['dupId']) );
|
$x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['dupId']) );
|
||||||
|
@ -52,7 +52,7 @@ if ( ! $monitor ) {
|
||||||
$monitor->Name( translate('Monitor').'-'.$nextId );
|
$monitor->Name( translate('Monitor').'-'.$nextId );
|
||||||
$monitor->Id( $nextId );
|
$monitor->Id( $nextId );
|
||||||
} else {
|
} else {
|
||||||
$monitor = new Monitor();
|
$monitor = new ZM\Monitor();
|
||||||
$monitor->set( array(
|
$monitor->set( array(
|
||||||
'Id' => 0,
|
'Id' => 0,
|
||||||
'Name' => translate('Monitor').'-'.$nextId,
|
'Name' => translate('Monitor').'-'.$nextId,
|
||||||
|
@ -689,10 +689,8 @@ switch ( $tab ) {
|
||||||
<tr><td><?php echo translate('Server') ?></td><td>
|
<tr><td><?php echo translate('Server') ?></td><td>
|
||||||
<?php
|
<?php
|
||||||
$servers = array(''=>'None','auto'=>'Auto');
|
$servers = array(''=>'None','auto'=>'Auto');
|
||||||
$result = dbQuery( 'SELECT * FROM Servers ORDER BY Name');
|
foreach ( ZM\Server::find(NULL, array('order'=>'lower(Name)')) as $Server ) {
|
||||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' );
|
$servers[$Server->Id()] = $Server->Name();
|
||||||
foreach ( $results as $row => $server_obj ) {
|
|
||||||
$servers[$server_obj->Id()] = $server_obj->Name();
|
|
||||||
}
|
}
|
||||||
echo htmlSelect( 'newMonitor[ServerId]', $servers, $monitor->ServerId() );
|
echo htmlSelect( 'newMonitor[ServerId]', $servers, $monitor->ServerId() );
|
||||||
?>
|
?>
|
||||||
|
@ -700,10 +698,8 @@ switch ( $tab ) {
|
||||||
<tr><td><?php echo translate('StorageArea') ?></td><td>
|
<tr><td><?php echo translate('StorageArea') ?></td><td>
|
||||||
<?php
|
<?php
|
||||||
$storage_areas = array(0=>'Default');
|
$storage_areas = array(0=>'Default');
|
||||||
$result = dbQuery( 'SELECT * FROM Storage ORDER BY Name');
|
foreach ( ZM\Storage::find( NULL, array('order'=>'lower(Name)') ) as $Storage ) {
|
||||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' );
|
$storage_areas[$Storage->Id()] = $Storage->Name();
|
||||||
foreach ( $results as $row => $storage_obj ) {
|
|
||||||
$storage_areas[$storage_obj->Id] = $storage_obj->Name();
|
|
||||||
}
|
}
|
||||||
echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() );
|
echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() );
|
||||||
?>
|
?>
|
||||||
|
@ -744,7 +740,7 @@ switch ( $tab ) {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td><?php echo translate('Groups'); ?></td><td><select name="newMonitor[GroupIds][]" multiple="multiple" class="chosen"><?php
|
<tr><td><?php echo translate('Groups'); ?></td><td><select name="newMonitor[GroupIds][]" multiple="multiple" class="chosen"><?php
|
||||||
echo htmlOptions(Group::get_dropdown_options( ), $monitor->GroupIds() );
|
echo htmlOptions(ZM\Group::get_dropdown_options( ), $monitor->GroupIds() );
|
||||||
?></td></tr>
|
?></td></tr>
|
||||||
<tr><td><?php echo translate('AnalysisFPS') ?></td><td><input type="text" name="newMonitor[AnalysisFPSLimit]" value="<?php echo validHtmlStr($monitor->AnalysisFPSLimit()) ?>" size="6"/></td></tr>
|
<tr><td><?php echo translate('AnalysisFPS') ?></td><td><input type="text" name="newMonitor[AnalysisFPSLimit]" value="<?php echo validHtmlStr($monitor->AnalysisFPSLimit()) ?>" size="6"/></td></tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -34,7 +34,7 @@ function probeV4L() {
|
||||||
|
|
||||||
$result = exec(escapeshellcmd($command), $output, $status);
|
$result = exec(escapeshellcmd($command), $output, $status);
|
||||||
if ( $status ) {
|
if ( $status ) {
|
||||||
Error("Unable to probe local cameras, status is '$status'");
|
ZM\Error("Unable to probe local cameras using $command, status is '$status' " . implode("\n",$output));
|
||||||
return $cameras;
|
return $cameras;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ function probeV4L() {
|
||||||
$preferredFormats = array('BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY');
|
$preferredFormats = array('BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY');
|
||||||
foreach ( $output as $line ) {
|
foreach ( $output as $line ) {
|
||||||
if ( !preg_match('/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches) )
|
if ( !preg_match('/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches) )
|
||||||
Fatal("Can't parse command output '$line'");
|
ZM\Fatal("Can't parse command output '$line'");
|
||||||
$standards = explode('/',$deviceMatches[2]);
|
$standards = explode('/',$deviceMatches[2]);
|
||||||
$preferredStandard = false;
|
$preferredStandard = false;
|
||||||
foreach ( $preferredStandards as $standard ) {
|
foreach ( $preferredStandards as $standard ) {
|
||||||
|
@ -74,7 +74,7 @@ function probeV4L() {
|
||||||
$inputs = array();
|
$inputs = array();
|
||||||
for ( $i = 0; $i < $deviceMatches[4]; $i++ ) {
|
for ( $i = 0; $i < $deviceMatches[4]; $i++ ) {
|
||||||
if ( !preg_match('/i'.$i.':([^|]+)\|i'.$i.'T:([^|]+)\|/', $deviceMatches[5], $inputMatches) )
|
if ( !preg_match('/i'.$i.':([^|]+)\|i'.$i.'T:([^|]+)\|/', $deviceMatches[5], $inputMatches) )
|
||||||
Fatal("Can't parse input '".$deviceMatches[5]."'");
|
ZM\Fatal("Can't parse input '".$deviceMatches[5]."'");
|
||||||
if ( $inputMatches[2] == 'Camera' ) {
|
if ( $inputMatches[2] == 'Camera' ) {
|
||||||
$input = array(
|
$input = array(
|
||||||
'index' => $i,
|
'index' => $i,
|
||||||
|
@ -247,13 +247,13 @@ function probeNetwork() {
|
||||||
$arp_command = ZM_PATH_ARP;
|
$arp_command = ZM_PATH_ARP;
|
||||||
$result = explode(' ', $arp_command);
|
$result = explode(' ', $arp_command);
|
||||||
if ( !is_executable($result[0]) ) {
|
if ( !is_executable($result[0]) ) {
|
||||||
Error("ARP compatible binary not found or not executable by the web user account. Verify ZM_PATH_ARP points to a valid arp tool.");
|
ZM\Error("ARP compatible binary not found or not executable by the web user account. Verify ZM_PATH_ARP points to a valid arp tool.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = exec(escapeshellcmd($arp_command), $output, $status);
|
$result = exec(escapeshellcmd($arp_command), $output, $status);
|
||||||
if ( $status ) {
|
if ( $status ) {
|
||||||
Error("Unable to probe network cameras, status is '$status'");
|
ZM\Error("Unable to probe network cameras, status is '$status'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,14 @@ if ( !canEdit('Monitors') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitors = Monitor::find(array('Id' => $_REQUEST['mids']));
|
$monitors = ZM\Monitor::find(array('Id' => $_REQUEST['mids']));
|
||||||
$monitor = $monitors[0];
|
$monitor = $monitors[0];
|
||||||
$servers = Server::find();
|
$servers = ZM\Server::find();
|
||||||
$ServersById = array();
|
$ServersById = array();
|
||||||
foreach ( $servers as $S ) {
|
foreach ( $servers as $S ) {
|
||||||
$ServersById[$S->Id()] = $S;
|
$ServersById[$S->Id()] = $S;
|
||||||
}
|
}
|
||||||
$storage_areas = Storage::find();
|
$storage_areas = ZM\Storage::find();
|
||||||
$StorageById = array();
|
$StorageById = array();
|
||||||
foreach ( $storage_areas as $S ) {
|
foreach ( $storage_areas as $S ) {
|
||||||
$StorageById[$S->Id()] = $S;
|
$StorageById[$S->Id()] = $S;
|
||||||
|
|
|
@ -50,16 +50,16 @@ $scale = '100'; # actual
|
||||||
|
|
||||||
if ( isset( $_REQUEST['scale'] ) ) {
|
if ( isset( $_REQUEST['scale'] ) ) {
|
||||||
$scale = validInt($_REQUEST['scale']);
|
$scale = validInt($_REQUEST['scale']);
|
||||||
Logger::Debug("Setting scale from request to $scale");
|
ZM\Logger::Debug("Setting scale from request to $scale");
|
||||||
} else if ( isset($_COOKIE['zmMontageScale']) ) {
|
} else if ( isset($_COOKIE['zmMontageScale']) ) {
|
||||||
$scale = $_COOKIE['zmMontageScale'];
|
$scale = $_COOKIE['zmMontageScale'];
|
||||||
Logger::Debug("Setting scale from cookie to $scale");
|
ZM\Logger::Debug("Setting scale from cookie to $scale");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $scale )
|
if ( ! $scale )
|
||||||
$scale = 100;
|
$scale = 100;
|
||||||
|
|
||||||
$layouts = MontageLayout::find(NULL, array('order'=>"lower('Name')"));
|
$layouts = ZM\MontageLayout::find(NULL, array('order'=>"lower('Name')"));
|
||||||
$layoutsById = array();
|
$layoutsById = array();
|
||||||
foreach ( $layouts as $l ) {
|
foreach ( $layouts as $l ) {
|
||||||
$layoutsById[$l->Id()] = $l;
|
$layoutsById[$l->Id()] = $l;
|
||||||
|
@ -126,7 +126,7 @@ foreach( $displayMonitors as &$row ) {
|
||||||
if ( ! isset($heights[$row['Height']]) ) {
|
if ( ! isset($heights[$row['Height']]) ) {
|
||||||
$heights[$row['Height']] = $row['Height'];
|
$heights[$row['Height']] = $row['Height'];
|
||||||
}
|
}
|
||||||
$monitors[] = new Monitor($row);
|
$monitors[] = new ZM\Monitor($row);
|
||||||
} # end foreach Monitor
|
} # end foreach Monitor
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Montage'));
|
xhtmlHeaders(__FILE__, translate('Montage'));
|
||||||
|
|
|
@ -223,7 +223,7 @@ $monitors = array();
|
||||||
foreach( $displayMonitors as $row ) {
|
foreach( $displayMonitors as $row ) {
|
||||||
if ( $row['Function'] == 'None' || $row['Type'] == 'WebSite' )
|
if ( $row['Function'] == 'None' || $row['Type'] == 'WebSite' )
|
||||||
continue;
|
continue;
|
||||||
$Monitor = new Monitor($row);
|
$Monitor = new ZM\Monitor($row);
|
||||||
$monitors[] = $Monitor;
|
$monitors[] = $Monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ function execONVIF( $cmd ) {
|
||||||
|
|
||||||
if ( $status ) {
|
if ( $status ) {
|
||||||
$html_output = implode( '<br/>', $output );
|
$html_output = implode( '<br/>', $output );
|
||||||
Fatal( "Unable to probe network cameras, status is '$status'. Output was:<br/><br/>
|
ZM\Fatal( "Unable to probe network cameras, status is '$status'. Output was:<br/><br/>
|
||||||
$html_output<br/><br/>
|
$html_output<br/><br/>
|
||||||
Please the following command from a command line for more information:<br/><br/>$shell_command"
|
Please the following command from a command line for more information:<br/><br/>$shell_command"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug( "Results from probe: " . implode( '<br/>', $output ) );
|
ZM\Logger::Debug( "Results from probe: " . implode( '<br/>', $output ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -73,7 +73,7 @@ function probeCameras( $localIp ) {
|
||||||
} elseif ( $tokens[1] == 'location' ) {
|
} elseif ( $tokens[1] == 'location' ) {
|
||||||
// $camera['location'] = $tokens[2];
|
// $camera['location'] = $tokens[2];
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug('Unknown token ' . $tokens[1]);
|
ZM\Logger::Debug('Unknown token ' . $tokens[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end foreach token
|
} // end foreach token
|
||||||
|
@ -109,7 +109,7 @@ function probeProfiles( $device_ep, $soapversion, $username, $password ) {
|
||||||
);
|
);
|
||||||
$profiles[] = $profile;
|
$profiles[] = $profile;
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("Line did not match preg: $line");
|
ZM\Logger::Debug("Line did not match preg: $line");
|
||||||
}
|
}
|
||||||
} // end foreach line
|
} // end foreach line
|
||||||
} // end if results from execONVIF
|
} // end if results from execONVIF
|
||||||
|
@ -190,7 +190,7 @@ if ( !isset($_REQUEST['step']) || ($_REQUEST['step'] == '1') ) {
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="password"><?php echo translate('Password') ?></label>
|
<label for="password"><?php echo translate('Password') ?></label>
|
||||||
<input type="password" name="password" value=""onChange="configureButtons(this)"/>
|
<input type="password" name="password" value="" onChange="configureButtons(this)"/>
|
||||||
</p>
|
</p>
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
|
<input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
|
||||||
|
@ -206,12 +206,12 @@ if ( !isset($_REQUEST['step']) || ($_REQUEST['step'] == '1') ) {
|
||||||
//==== STEP 2 ============================================================
|
//==== STEP 2 ============================================================
|
||||||
} else if($_REQUEST['step'] == '2') {
|
} else if($_REQUEST['step'] == '2') {
|
||||||
if ( empty($_REQUEST['probe']) )
|
if ( empty($_REQUEST['probe']) )
|
||||||
Fatal('No probe passed in request. Please go back and try again.');
|
ZM\Fatal('No probe passed in request. Please go back and try again.');
|
||||||
#|| empty($_REQUEST['username']) ||
|
#|| empty($_REQUEST['username']) ||
|
||||||
#empty($_REQUEST['password']) )
|
#empty($_REQUEST['password']) )
|
||||||
|
|
||||||
$probe = json_decode(base64_decode($_REQUEST['probe']));
|
$probe = json_decode(base64_decode($_REQUEST['probe']));
|
||||||
Logger::Debug(print_r($probe,true));
|
ZM\Logger::Debug(print_r($probe,true));
|
||||||
foreach ( $probe as $name=>$value ) {
|
foreach ( $probe as $name=>$value ) {
|
||||||
if ( isset($value) ) {
|
if ( isset($value) ) {
|
||||||
$monitor[$name] = $value;
|
$monitor[$name] = $value;
|
||||||
|
|
|
@ -230,7 +230,7 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$monitor_counts = dbFetchAssoc('SELECT Id,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers', 'Id', 'MonitorCount');
|
$monitor_counts = dbFetchAssoc('SELECT Id,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers', 'Id', 'MonitorCount');
|
||||||
foreach ( Server::find() as $Server ) {
|
foreach ( ZM\Server::find() as $Server ) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="colName"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?></td>
|
<td class="colName"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?></td>
|
||||||
|
@ -287,7 +287,7 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach( Storage::find( null, array('order'=>'lower(Name)') ) as $Storage ) { ?>
|
<?php foreach( ZM\Storage::find( null, array('order'=>'lower(Name)') ) as $Storage ) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="colId"><?php echo makePopupLink('?view=storage&id='.$Storage->Id(), 'zmStorage', 'storage', validHtmlStr($Storage->Id()), $canEdit ) ?></td>
|
<td class="colId"><?php echo makePopupLink('?view=storage&id='.$Storage->Id(), 'zmStorage', 'storage', validHtmlStr($Storage->Id()), $canEdit ) ?></td>
|
||||||
<td class="colName"><?php echo makePopupLink('?view=storage&id='.$Storage->Id(), 'zmStorage', 'storage', validHtmlStr($Storage->Name()), $canEdit ) ?></td>
|
<td class="colName"><?php echo makePopupLink('?view=storage&id='.$Storage->Id(), 'zmStorage', 'storage', validHtmlStr($Storage->Name()), $canEdit ) ?></td>
|
||||||
|
|
|
@ -18,20 +18,19 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canEdit( 'System' ) )
|
if ( !canEdit('System') ) {
|
||||||
{
|
$view = 'error';
|
||||||
$view = "error";
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
"accept" => translate('Accept'),
|
'1' => translate('Accept'),
|
||||||
"decline" => translate('Decline'),
|
'0' => translate('Decline'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Privacy') );
|
xhtmlHeaders(__FILE__, translate('Privacy'));
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
|
@ -41,31 +40,31 @@ xhtmlHeaders(__FILE__, translate('Privacy') );
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<form name="contentForm" id="contentForm" method="post" action="?">
|
<form name="contentForm" id="contentForm" method="post" action="?">
|
||||||
<input type="hidden" name="view" value="none"/>
|
<input type="hidden" name="view" value="privacy"/>
|
||||||
<input type="hidden" name="action" value="privacy"/>
|
<input type="hidden" name="action" value="privacy"/>
|
||||||
<h6><?php echo translate('PrivacyAbout') ?></h6>
|
<h6><?php echo translate('PrivacyAbout') ?></h6>
|
||||||
<p><?php echo translate('PrivacyAboutText') ?></p>
|
<p><?php echo translate('PrivacyAboutText') ?></p>
|
||||||
<br>
|
<br/>
|
||||||
|
|
||||||
<h6><?php echo translate('PrivacyContact') ?></h6>
|
<h6><?php echo translate('PrivacyContact') ?></h6>
|
||||||
<p><?php echo translate('PrivacyContactText') ?></p>
|
<p><?php echo translate('PrivacyContactText') ?></p>
|
||||||
<br>
|
<br/>
|
||||||
|
|
||||||
<h6><?php echo translate('PrivacyCookies') ?></h6>
|
<h6><?php echo translate('PrivacyCookies') ?></h6>
|
||||||
<p><?php echo translate('PrivacyCookiesText') ?></p>
|
<p><?php echo translate('PrivacyCookiesText') ?></p>
|
||||||
<br>
|
<br/>
|
||||||
|
|
||||||
<h6><?php echo translate('PrivacyTelemetry') ?></h6>
|
<h6><?php echo translate('PrivacyTelemetry') ?></h6>
|
||||||
<p><?php echo translate('PrivacyTelemetryText') ?></p>
|
<p><?php echo translate('PrivacyTelemetryText') ?></p>
|
||||||
<br>
|
<br/>
|
||||||
|
|
||||||
<p><?php echo translate('PrivacyTelemetryList') ?></p>
|
<p><?php echo translate('PrivacyTelemetryList') ?></p>
|
||||||
<p><?php echo translate('PrivacyMonitorList') ?></p>
|
<p><?php echo translate('PrivacyMonitorList') ?></p>
|
||||||
<p><?php echo translate('PrivacyConclusionText') ?></p>
|
<p><?php echo translate('PrivacyConclusionText') ?></p>
|
||||||
<p><?php echo buildSelect( "option", $options ); ?></p>
|
<p><?php echo htmlSelect('option', $options, ZM_TELEMETRY_DATA); ?></p>
|
||||||
|
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<input type="submit" value="<?php echo translate('Apply') ?>" data-on-click-this="submitForm">
|
<button type="submit" value="Apply"><?php echo translate('Apply') ?></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -62,7 +62,7 @@ if ( count($selected_monitor_ids) ) {
|
||||||
}
|
}
|
||||||
parseFilter($filter);
|
parseFilter($filter);
|
||||||
$filterQuery = $filter['query'];
|
$filterQuery = $filter['query'];
|
||||||
Logger::Debug($filterQuery);
|
ZM\Logger::Debug($filterQuery);
|
||||||
|
|
||||||
$eventsSql = 'SELECT *,
|
$eventsSql = 'SELECT *,
|
||||||
UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs,
|
UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs,
|
||||||
|
@ -83,12 +83,12 @@ $eventsSql .= ' ORDER BY Id ASC';
|
||||||
|
|
||||||
$result = dbQuery($eventsSql);
|
$result = dbQuery($eventsSql);
|
||||||
if ( !$result ) {
|
if ( !$result ) {
|
||||||
Fatal('SQL-ERR');
|
ZM\Fatal('SQL-ERR');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$EventsByMonitor = array();
|
$EventsByMonitor = array();
|
||||||
while( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
|
while( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
$Event = new Event($event);
|
$Event = new ZM\Event($event);
|
||||||
if ( ! isset($EventsByMonitor[$event['MonitorId']]) )
|
if ( ! isset($EventsByMonitor[$event['MonitorId']]) )
|
||||||
$EventsByMonitor[$event['MonitorId']] = array( 'Events'=>array(), 'MinGap'=>0, 'MaxGap'=>0, 'FileMissing'=>array(), 'ZeroSize'=>array() );
|
$EventsByMonitor[$event['MonitorId']] = array( 'Events'=>array(), 'MinGap'=>0, 'MaxGap'=>0, 'FileMissing'=>array(), 'ZeroSize'=>array() );
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ while( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
<?php
|
<?php
|
||||||
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
$monitor = $displayMonitors[$monitor_i];
|
$monitor = $displayMonitors[$monitor_i];
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new ZM\Monitor($monitor);
|
||||||
$montagereview_link = "?view=montagereview&live=0&MonitorId=". $monitor['Id'] . '&minTime='.$minTime.'&maxTime='.$maxTime;
|
$montagereview_link = "?view=montagereview&live=0&MonitorId=". $monitor['Id'] . '&minTime='.$minTime.'&maxTime='.$maxTime;
|
||||||
|
|
||||||
$monitor_filter = addFilterTerm(
|
$monitor_filter = addFilterTerm(
|
||||||
|
@ -202,7 +202,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
<a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
<a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
||||||
<?php echo implode('<br/>',
|
<?php echo implode('<br/>',
|
||||||
array_map(function($group_id){
|
array_map(function($group_id){
|
||||||
$Group = new Group($group_id);
|
$Group = new ZM\Group($group_id);
|
||||||
$Groups = $Group->Parents();
|
$Groups = $Group->Parents();
|
||||||
array_push($Groups, $Group);
|
array_push($Groups, $Group);
|
||||||
return implode(' > ', array_map(function($Group){ return '<a href="?view=montagereview&GroupId='.$Group->Id().'">'.$Group->Name().'</a>'; }, $Groups ));
|
return implode(' > ', array_map(function($Group){ return '<a href="?view=montagereview&GroupId='.$Group->Id().'">'.$Group->Name().'</a>'; }, $Groups ));
|
||||||
|
|
|
@ -23,7 +23,7 @@ if ( !canEdit('System') ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Server = new Server($_REQUEST['id']);
|
$Server = new ZM\Server($_REQUEST['id']);
|
||||||
if ( $_REQUEST['id'] and ! $Server->Id() ) {
|
if ( $_REQUEST['id'] and ! $Server->Id() ) {
|
||||||
$view = 'error';
|
$view = 'error';
|
||||||
return;
|
return;
|
||||||
|
@ -97,9 +97,8 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name());
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<input type="hidden" name="action" value="Save"/>
|
<button type="submit" name="action" value="Save" ><?php echo translate('Save') ?></button>
|
||||||
<input type="submit" value="<?php echo translate('Save') ?>"/>
|
<button type="button" data-on-click="closeWindow"><?php echo translate('Cancel') ?></button>
|
||||||
<input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -48,7 +48,7 @@ $scheme_options = array(
|
||||||
'Shallow' => translate('Shallow'),
|
'Shallow' => translate('Shallow'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$servers = Server::find( null, array('order'=>'lower(Name)') );
|
$servers = ZM\Server::find( null, array('order'=>'lower(Name)') );
|
||||||
$ServersById = array();
|
$ServersById = array();
|
||||||
foreach ( $servers as $S ) {
|
foreach ( $servers as $S ) {
|
||||||
$ServersById[$S->Id()] = $S;
|
$ServersById[$S->Id()] = $S;
|
||||||
|
|
|
@ -757,7 +757,6 @@ if ( $mode == 'overlay' ) {
|
||||||
echo drawYGrid( $chart, $majYScale, 'majLabelY', 'majTickY', 'majGridY graphWidth' );
|
echo drawYGrid( $chart, $majYScale, 'majLabelY', 'majTickY', 'majGridY graphWidth' );
|
||||||
}
|
}
|
||||||
echo drawXGrid( $chart, $majXScale, 'majLabelX', 'majTickX', 'majGridX graphHeight', 'zoom graphHeight' );
|
echo drawXGrid( $chart, $majXScale, 'majLabelX', 'majTickX', 'majGridX graphHeight', 'zoom graphHeight' );
|
||||||
Warning("Mode: $mode");
|
|
||||||
if ( $mode == 'overlay' ) {
|
if ( $mode == 'overlay' ) {
|
||||||
?>
|
?>
|
||||||
<div id='activity' class='activitySize'>
|
<div id='activity' class='activitySize'>
|
||||||
|
|
|
@ -37,7 +37,7 @@ if ( ! visibleMonitor($mid) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitor = new Monitor($mid);
|
$monitor = new ZM\Monitor($mid);
|
||||||
|
|
||||||
#Whether to show the controls button
|
#Whether to show the controls button
|
||||||
$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView('Control') && $monitor->Type() != 'WebSite' );
|
$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView('Control') && $monitor->Type() != 'WebSite' );
|
||||||
|
|
|
@ -54,7 +54,7 @@ foreach ( getEnumValues( 'Zones', 'CheckMethod' ) as $optCheckMethod ) {
|
||||||
$optCheckMethods[$optCheckMethod] = $optCheckMethod;
|
$optCheckMethods[$optCheckMethod] = $optCheckMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitor = new Monitor( $mid );
|
$monitor = new ZM\Monitor( $mid );
|
||||||
|
|
||||||
$minX = 0;
|
$minX = 0;
|
||||||
$maxX = $monitor->Width()-1;
|
$maxX = $monitor->Width()-1;
|
||||||
|
|
|
@ -48,24 +48,23 @@ if ( $archivetype ) {
|
||||||
if ( $mimetype ) {
|
if ( $mimetype ) {
|
||||||
$filename = "zmExport_$connkey.$file_ext";
|
$filename = "zmExport_$connkey.$file_ext";
|
||||||
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
$filename_path = ZM_DIR_EXPORTS.'/'.$filename;
|
||||||
Logger::Debug("downloading archive from $filename_path");
|
ZM\Logger::Debug("downloading archive from $filename_path");
|
||||||
if ( is_readable($filename_path) ) {
|
if ( is_readable($filename_path) ) {
|
||||||
ob_clean();
|
|
||||||
header("Content-type: application/$mimetype" );
|
header("Content-type: application/$mimetype" );
|
||||||
header("Content-Disposition: inline; filename=$filename");
|
header("Content-Disposition: inline; filename=$filename");
|
||||||
header('Content-Length: ' . filesize($filename_path) );
|
header('Content-Length: ' . filesize($filename_path) );
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
if ( ! @readfile($filename_path) ) {
|
if ( ! @readfile($filename_path) ) {
|
||||||
Error("Error sending $filename_path");
|
ZM\Error("Error sending $filename_path");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("$filename_path does not exist or is not readable.");
|
ZM\Error("$filename_path does not exist or is not readable.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("Unsupported archive type specified. Supported archives are tar and zip");
|
ZM\Error("Unsupported archive type specified. Supported archives are tar and zip");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("No archive type given to archive.php. Please specify a tar or zip archive.");
|
ZM\Error("No archive type given to archive.php. Please specify a tar or zip archive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -64,16 +64,16 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
|
|
||||||
if ( empty($_REQUEST['fid']) ) {
|
if ( empty($_REQUEST['fid']) ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal('No Frame ID specified');
|
ZM\Fatal('No Frame ID specified');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($_REQUEST['eid']) ) {
|
if ( !empty($_REQUEST['eid']) ) {
|
||||||
Logger::Debug("Loading by eid");
|
ZM\Logger::Debug("Loading by eid");
|
||||||
$Event = Event::find_one(array('Id'=>$_REQUEST['eid']));
|
$Event = ZM\Event::find_one(array('Id'=>$_REQUEST['eid']));
|
||||||
if ( !$Event ) {
|
if ( !$Event ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal('Event '.$_REQUEST['eid'].' Not found');
|
ZM\Fatal('Event '.$_REQUEST['eid'].' Not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,19 +81,19 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
$path = $Event->Path().'/objdetect.jpg';
|
$path = $Event->Path().'/objdetect.jpg';
|
||||||
if ( !file_exists($path) ) {
|
if ( !file_exists($path) ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal("File $path does not exist. Please make sure store_frame_in_zm is enabled in the object detection config");
|
ZM\Fatal("File $path does not exist. Please make sure store_frame_in_zm is enabled in the object detection config");
|
||||||
}
|
}
|
||||||
$Frame = new Frame();
|
$Frame = new ZM\Frame();
|
||||||
$Frame->Id('objdetect');
|
$Frame->Id('objdetect');
|
||||||
} else if ( $_REQUEST['fid'] == 'alarm' ) {
|
} else if ( $_REQUEST['fid'] == 'alarm' ) {
|
||||||
# look for first alarmed frame
|
# look for first alarmed frame
|
||||||
$Frame = Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'Type'=>'Alarm'),
|
$Frame = ZM\Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'Type'=>'Alarm'),
|
||||||
array('order'=>'FrameId ASC'));
|
array('order'=>'FrameId ASC'));
|
||||||
if ( !$Frame ) { # no alarms, get first one I find
|
if ( !$Frame ) { # no alarms, get first one I find
|
||||||
$Frame = Frame::find_one(array('EventId'=>$_REQUEST['eid']));
|
$Frame = ZM\Frame::find_one(array('EventId'=>$_REQUEST['eid']));
|
||||||
if ( !$Frame ) {
|
if ( !$Frame ) {
|
||||||
Warning('No frame found for event '.$_REQUEST['eid']);
|
ZM\Warning('No frame found for event '.$_REQUEST['eid']);
|
||||||
$Frame = new Frame();
|
$Frame = new ZM\Frame();
|
||||||
$Frame->Delta(1);
|
$Frame->Delta(1);
|
||||||
$Frame->FrameId(1);
|
$Frame->FrameId(1);
|
||||||
}
|
}
|
||||||
|
@ -106,12 +106,12 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
$path = $Event->Path().'/alarm.jpg';
|
$path = $Event->Path().'/alarm.jpg';
|
||||||
}
|
}
|
||||||
} else if ( $_REQUEST['fid'] == 'snapshot' ) {
|
} else if ( $_REQUEST['fid'] == 'snapshot' ) {
|
||||||
$Frame = Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'Score'=>$Event->MaxScore()));
|
$Frame = ZM\Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'Score'=>$Event->MaxScore()));
|
||||||
if ( !$Frame )
|
if ( !$Frame )
|
||||||
$Frame = Frame::find_one(array('EventId'=>$_REQUEST['eid']));
|
$Frame = ZM\Frame::find_one(array('EventId'=>$_REQUEST['eid']));
|
||||||
if ( !$Frame ) {
|
if ( !$Frame ) {
|
||||||
Warning('No frame found for event ' . $_REQUEST['eid']);
|
ZM\Warning('No frame found for event ' . $_REQUEST['eid']);
|
||||||
$Frame = new Frame();
|
$Frame = new ZM\Frame();
|
||||||
$Frame->Delta(1);
|
$Frame->Delta(1);
|
||||||
$Frame->FrameId('snapshot');
|
$Frame->FrameId('snapshot');
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$Frame = Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'FrameId'=>$_REQUEST['fid']));
|
$Frame = ZM\Frame::find_one(array('EventId'=>$_REQUEST['eid'], 'FrameId'=>$_REQUEST['fid']));
|
||||||
if ( ! $Frame ) {
|
if ( ! $Frame ) {
|
||||||
$previousBulkFrame = dbFetchOne(
|
$previousBulkFrame = dbFetchOne(
|
||||||
'SELECT * FROM Frames WHERE EventId=? AND FrameId < ? ORDER BY FrameID DESC LIMIT 1',
|
'SELECT * FROM Frames WHERE EventId=? AND FrameId < ? ORDER BY FrameID DESC LIMIT 1',
|
||||||
|
@ -135,72 +135,72 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
NULL, array($_REQUEST['eid'], $_REQUEST['fid'])
|
NULL, array($_REQUEST['eid'], $_REQUEST['fid'])
|
||||||
);
|
);
|
||||||
if ( $previousBulkFrame and $nextBulkFrame ) {
|
if ( $previousBulkFrame and $nextBulkFrame ) {
|
||||||
$Frame = new Frame($previousBulkFrame);
|
$Frame = new ZM\Frame($previousBulkFrame);
|
||||||
$Frame->FrameId($_REQUEST['fid']);
|
$Frame->FrameId($_REQUEST['fid']);
|
||||||
|
|
||||||
$percentage = ($Frame->FrameId() - $previousBulkFrame['FrameId']) / ($nextBulkFrame['FrameId'] - $previousBulkFrame['FrameId']);
|
$percentage = ($Frame->FrameId() - $previousBulkFrame['FrameId']) / ($nextBulkFrame['FrameId'] - $previousBulkFrame['FrameId']);
|
||||||
|
|
||||||
$Frame->Delta($previousBulkFrame['Delta'] + floor( 100* ( $nextBulkFrame['Delta'] - $previousBulkFrame['Delta'] ) * $percentage )/100);
|
$Frame->Delta($previousBulkFrame['Delta'] + floor( 100* ( $nextBulkFrame['Delta'] - $previousBulkFrame['Delta'] ) * $percentage )/100);
|
||||||
Logger::Debug("Got virtual frame from Bulk Frames previous delta: " . $previousBulkFrame['Delta'] . " + nextdelta:" . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage );
|
ZM\Logger::Debug("Got virtual frame from Bulk Frames previous delta: " . $previousBulkFrame['Delta'] . " + nextdelta:" . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage );
|
||||||
} else {
|
} else {
|
||||||
Fatal('No Frame found for event('.$_REQUEST['eid'].') and frame id('.$_REQUEST['fid'].')');
|
ZM\Fatal('No Frame found for event('.$_REQUEST['eid'].') and frame id('.$_REQUEST['fid'].')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame
|
// Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame
|
||||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||||
Logger::Debug("Path: $path");
|
ZM\Logger::Debug("Path: $path");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
# If we are only specifying fid, then the fid must be the primary key into the frames table. But when the event is specified, then it is the frame #
|
# If we are only specifying fid, then the fid must be the primary key into the frames table. But when the event is specified, then it is the frame #
|
||||||
$Frame = Frame::find_one(array('Id'=>$_REQUEST['fid']));
|
$Frame = ZM\Frame::find_one(array('Id'=>$_REQUEST['fid']));
|
||||||
if ( !$Frame ) {
|
if ( !$Frame ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal('Frame ' . $_REQUEST['fid'] . ' Not Found');
|
ZM\Fatal('Frame ' . $_REQUEST['fid'] . ' Not Found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Event = Event::find_one(array('Id'=>$Frame->EventId()));
|
$Event = ZM\Event::find_one(array('Id'=>$Frame->EventId()));
|
||||||
if ( !$Event ) {
|
if ( !$Event ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal('Event ' . $Frame->EventId() . ' Not Found');
|
ZM\Fatal('Event ' . $Frame->EventId() . ' Not Found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||||
} # end if have eid
|
} # end if have eid
|
||||||
|
|
||||||
if ( !file_exists($path) ) {
|
if ( !file_exists($path) ) {
|
||||||
Logger::Debug("$path does not exist");
|
ZM\Logger::Debug("$path does not exist");
|
||||||
# Generate the frame JPG
|
# Generate the frame JPG
|
||||||
if ( ($show == 'capture') and $Event->DefaultVideo() ) {
|
if ( ($show == 'capture') and $Event->DefaultVideo() ) {
|
||||||
if ( !file_exists($Event->Path().'/'.$Event->DefaultVideo()) ) {
|
if ( !file_exists($Event->Path().'/'.$Event->DefaultVideo()) ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal("Can't create frame images from video because there is no video file for this event at (".$Event->Path().'/'.$Event->DefaultVideo() );
|
ZM\Fatal("Can't create frame images from video because there is no video file for this event at (".$Event->Path().'/'.$Event->DefaultVideo() );
|
||||||
}
|
}
|
||||||
$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -frames:v 1 '.$path;
|
$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -frames:v 1 '.$path;
|
||||||
#$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
|
#$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
|
||||||
#$command ='ffmpeg -v 0 -i '.$Storage->Path().'/'.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
|
#$command ='ffmpeg -v 0 -i '.$Storage->Path().'/'.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
|
||||||
Logger::Debug("Running $command");
|
ZM\Logger::Debug("Running $command");
|
||||||
$output = array();
|
$output = array();
|
||||||
$retval = 0;
|
$retval = 0;
|
||||||
exec( $command, $output, $retval );
|
exec( $command, $output, $retval );
|
||||||
Logger::Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
|
ZM\Logger::Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
|
||||||
if ( ! file_exists( $path ) ) {
|
if ( ! file_exists( $path ) ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal("Can't create frame images from video for this event (".$Event->DefaultVideo() );
|
ZM\Fatal("Can't create frame images from video for this event (".$Event->DefaultVideo() );
|
||||||
}
|
}
|
||||||
# Generating an image file will use up more disk space, so update the Event record.
|
# Generating an image file will use up more disk space, so update the Event record.
|
||||||
$Event->DiskSpace(null);
|
$Event->DiskSpace(null);
|
||||||
$Event->save();
|
$Event->save();
|
||||||
} else {
|
} else {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal("Can't create frame $show images from video because there is no video file for this event at ".
|
ZM\Fatal("Can't create frame $show images from video because there is no video file for this event at ".
|
||||||
$Event->Path().'/'.$Event->DefaultVideo() );
|
$Event->Path().'/'.$Event->DefaultVideo() );
|
||||||
}
|
}
|
||||||
} # end if ! file_exists($path)
|
} # end if ! file_exists($path)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Warning('Loading images by path is deprecated');
|
ZM\Warning('Loading images by path is deprecated');
|
||||||
$dir_events = realpath(ZM_DIR_EVENTS);
|
$dir_events = realpath(ZM_DIR_EVENTS);
|
||||||
$path = realpath($dir_events . '/' . $_REQUEST['path']);
|
$path = realpath($dir_events . '/' . $_REQUEST['path']);
|
||||||
$pos = strpos($path, $dir_events);
|
$pos = strpos($path, $dir_events);
|
||||||
|
@ -223,7 +223,7 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
}
|
}
|
||||||
if ( !file_exists($path) ) {
|
if ( !file_exists($path) ) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
Fatal("Image not found at $path");
|
ZM\Fatal("Image not found at $path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ if ( !empty($_REQUEST['scale']) ) {
|
||||||
|
|
||||||
$width = 0;
|
$width = 0;
|
||||||
if ( !empty($_REQUEST['width']) ) {
|
if ( !empty($_REQUEST['width']) ) {
|
||||||
Logger::Debug("Setting width: " . $_REQUEST['width']);
|
ZM\Logger::Debug("Setting width: " . $_REQUEST['width']);
|
||||||
if ( is_numeric($_REQUEST['width']) ) {
|
if ( is_numeric($_REQUEST['width']) ) {
|
||||||
$x = $_REQUEST['width'];
|
$x = $_REQUEST['width'];
|
||||||
if ( $x >= 10 and $x <= 8000 )
|
if ( $x >= 10 and $x <= 8000 )
|
||||||
|
@ -257,10 +257,8 @@ if ( !empty($_REQUEST['height']) ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $errorText ) {
|
if ( $errorText ) {
|
||||||
Error($errorText);
|
ZM\Error($errorText);
|
||||||
} else {
|
} else {
|
||||||
# Clears the output buffer. Not sure what is there, but have had troubles.
|
|
||||||
ob_end_clean();
|
|
||||||
header('Content-type: image/jpeg');
|
header('Content-type: image/jpeg');
|
||||||
if ( ( $scale==0 || $scale==100 ) && ($width==0) && ($height==0) ) {
|
if ( ( $scale==0 || $scale==100 ) && ($width==0) && ($height==0) ) {
|
||||||
# This is so that Save Image As give a useful filename
|
# This is so that Save Image As give a useful filename
|
||||||
|
@ -269,10 +267,10 @@ if ( $errorText ) {
|
||||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||||
}
|
}
|
||||||
if ( !readfile($path) ) {
|
if ( !readfile($path) ) {
|
||||||
Error('No bytes read from '. $path);
|
ZM\Error('No bytes read from '. $path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("Doing a scaled image: scale($scale) width($width) height($height)");
|
ZM\Logger::Debug("Doing a scaled image: scale($scale) width($width) height($height)");
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ( ! ( $width && $height ) ) {
|
if ( ! ( $width && $height ) ) {
|
||||||
$i = imagecreatefromjpeg($path);
|
$i = imagecreatefromjpeg($path);
|
||||||
|
@ -285,10 +283,10 @@ if ( $errorText ) {
|
||||||
$width = ($height * $oldWidth) / $oldHeight;
|
$width = ($height * $oldWidth) / $oldHeight;
|
||||||
} elseif ( $width != 0 && $height == 0 ) {
|
} elseif ( $width != 0 && $height == 0 ) {
|
||||||
$height = ($width * $oldHeight) / $oldWidth;
|
$height = ($width * $oldHeight) / $oldWidth;
|
||||||
Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight) / $oldWidth");
|
ZM\Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight) / $oldWidth");
|
||||||
}
|
}
|
||||||
if ( $width == $oldWidth && $height == $oldHeight ) {
|
if ( $width == $oldWidth && $height == $oldHeight ) {
|
||||||
Warning('No change to width despite scaling.');
|
ZM\Warning('No change to width despite scaling.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +297,7 @@ Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight)
|
||||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||||
}
|
}
|
||||||
if ( !( file_exists($scaled_path) and readfile($scaled_path) ) ) {
|
if ( !( file_exists($scaled_path) and readfile($scaled_path) ) ) {
|
||||||
Logger::Debug("Cached scaled image does not exist at $scaled_path or is no good.. Creating it");
|
ZM\Logger::Debug("Cached scaled image does not exist at $scaled_path or is no good.. Creating it");
|
||||||
ob_start();
|
ob_start();
|
||||||
if ( !$i )
|
if ( !$i )
|
||||||
$i = imagecreatefromjpeg($path);
|
$i = imagecreatefromjpeg($path);
|
||||||
|
@ -309,15 +307,14 @@ Logger::Debug("Figuring out height using width: $height = ($width * $oldHeight)
|
||||||
imagedestroy($iScale);
|
imagedestroy($iScale);
|
||||||
$scaled_jpeg_data = ob_get_contents();
|
$scaled_jpeg_data = ob_get_contents();
|
||||||
file_put_contents($scaled_path, $scaled_jpeg_data);
|
file_put_contents($scaled_path, $scaled_jpeg_data);
|
||||||
ob_end_clean();
|
|
||||||
echo $scaled_jpeg_data;
|
echo $scaled_jpeg_data;
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("Sending $scaled_path");
|
ZM\Logger::Debug("Sending $scaled_path");
|
||||||
$bytes = readfile($scaled_path);
|
$bytes = readfile($scaled_path);
|
||||||
if ( !$bytes ) {
|
if ( !$bytes ) {
|
||||||
Error('No bytes read from '. $scaled_path);
|
ZM\Error('No bytes read from '. $scaled_path);
|
||||||
} else {
|
} else {
|
||||||
Logger::Debug("$bytes sent");
|
ZM\Logger::Debug("$bytes sent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,19 +38,19 @@ $path = '';
|
||||||
$Event = null;
|
$Event = null;
|
||||||
|
|
||||||
if ( ! empty($_REQUEST['eid']) ) {
|
if ( ! empty($_REQUEST['eid']) ) {
|
||||||
$Event = new Event($_REQUEST['eid']);
|
$Event = new ZM\Event($_REQUEST['eid']);
|
||||||
$path = $Event->Path().'/'.$Event->DefaultVideo();
|
$path = $Event->Path().'/'.$Event->DefaultVideo();
|
||||||
Logger::Debug("Path: $path");
|
ZM\Logger::Debug("Path: $path");
|
||||||
} else if ( ! empty($_REQUEST['event_id']) ) {
|
} else if ( ! empty($_REQUEST['event_id']) ) {
|
||||||
$Event = new Event($_REQUEST['event_id']);
|
$Event = new ZM\Event($_REQUEST['event_id']);
|
||||||
$path = $Event->Path().'/'.$Event->DefaultVideo();
|
$path = $Event->Path().'/'.$Event->DefaultVideo();
|
||||||
Logger::Debug("Path: $path");
|
ZM\Logger::Debug("Path: $path");
|
||||||
} else {
|
} else {
|
||||||
$errorText = 'No video path';
|
$errorText = 'No video path';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $errorText ) {
|
if ( $errorText ) {
|
||||||
Error($errorText);
|
ZM\Error($errorText);
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -68,14 +68,14 @@ $end = $size-1;
|
||||||
$length = $size;
|
$length = $size;
|
||||||
|
|
||||||
if ( isset($_SERVER['HTTP_RANGE']) ) {
|
if ( isset($_SERVER['HTTP_RANGE']) ) {
|
||||||
Logger::Debug('Using Range ' . $_SERVER['HTTP_RANGE']);
|
ZM\Logger::Debug('Using Range ' . $_SERVER['HTTP_RANGE']);
|
||||||
if ( preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) {
|
if ( preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) {
|
||||||
$begin = intval($matches[1]);
|
$begin = intval($matches[1]);
|
||||||
if ( ! empty($matches[2]) ) {
|
if ( ! empty($matches[2]) ) {
|
||||||
$end = intval($matches[2]);
|
$end = intval($matches[2]);
|
||||||
}
|
}
|
||||||
$length = $end - $begin + 1;
|
$length = $end - $begin + 1;
|
||||||
Logger::Debug("Using Range $begin $end size: $size, length: $length");
|
ZM\Logger::Debug("Using Range $begin $end size: $size, length: $length");
|
||||||
}
|
}
|
||||||
} # end if HTTP_RANGE
|
} # end if HTTP_RANGE
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ if ( $begin > 0 || $end < $size-1 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apparently without these we get a few extra bytes of output at the end...
|
// Apparently without these we get a few extra bytes of output at the end...
|
||||||
ob_clean();
|
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
$cur = $begin;
|
$cur = $begin;
|
||||||
|
|
Loading…
Reference in New Issue