Merge branch 'master' into storageareas
This commit is contained in:
commit
588ca2cf62
|
@ -517,6 +517,7 @@ CREATE TABLE `Monitors` (
|
||||||
`ArchivedEvents` int(10) default NULL,
|
`ArchivedEvents` int(10) default NULL,
|
||||||
`ArchivedEventDiskSpace` bigint default NULL,
|
`ArchivedEventDiskSpace` bigint default NULL,
|
||||||
`ZoneCount` TINYINT NOT NULL DEFAULT 0,
|
`ZoneCount` TINYINT NOT NULL DEFAULT 0,
|
||||||
|
`Refresh` int(10) unsigned default NULL,
|
||||||
PRIMARY KEY (`Id`)
|
PRIMARY KEY (`Id`)
|
||||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||||
|
|
||||||
|
@ -777,7 +778,8 @@ INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-423','Ffmpeg','Reolink',0,0,1,1
|
||||||
INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-411','Ffmpeg','Reolink',0,0,1,1,0,0,0,1,0,0,1,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,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);
|
INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-411','Ffmpeg','Reolink',0,0,1,1,0,0,0,1,0,0,1,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,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);
|
||||||
INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-420','Ffmpeg','Reolink',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,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);
|
INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-420','Ffmpeg','Reolink',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,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);
|
||||||
INSERT INTO `Controls` VALUES (NULL,'D-LINK DCS-3415','Remote','DCS3415',0,0,0,1,0,0,0,0,0,0,0,0,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,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0);
|
INSERT INTO `Controls` VALUES (NULL,'D-LINK DCS-3415','Remote','DCS3415',0,0,0,1,0,0,0,0,0,0,0,0,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,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
INSERT INTO `Controls` VALUES (NULL,'IOS Camera','Ffmpeg','IPCAMIOS',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,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,0);
|
||||||
|
INSERT INTO `Controls` VALUES (NULL,'Dericam P2','Ffmpeg','DericamP2',0,1,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,0,0,0,0,0,1,10,0,1,1,1,0,0,0,1,1,0,0,0,0,1,1,45,0,0,1,0,0,0,0,1,1,45,0,0,0,0);
|
||||||
--
|
--
|
||||||
-- Add some monitor preset values
|
-- Add some monitor preset values
|
||||||
--
|
--
|
||||||
|
|
|
@ -16,7 +16,7 @@ SET @s = (SELECT IF(
|
||||||
AND column_name = 'Refresh'
|
AND column_name = 'Refresh'
|
||||||
) > 0,
|
) > 0,
|
||||||
"SELECT 'Column Refresh exists in Monitors'",
|
"SELECT 'Column Refresh exists in Monitors'",
|
||||||
"ALTER TABLE Monitors ADD `Refresh` int(10) unsigned default NULL"
|
"ALTER TABLE Monitors ADD `Refresh` int(10) unsigned default NULL AFTER `ZoneCount`"
|
||||||
));
|
));
|
||||||
|
|
||||||
PREPARE stmt FROM @s;
|
PREPARE stmt FROM @s;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
--
|
||||||
|
-- This updates a 1.31.44 database to 1.31.45
|
||||||
|
--
|
||||||
|
-- Add WebSite enum to Monitor.Type
|
||||||
|
-- Add Refresh column to Monitors table
|
||||||
|
|
||||||
|
-- This is the same as the update to 1.31.43, but due to Refresh not being added to zm_create.sql.in we need to have it
|
||||||
|
-- again in order to fix people who did a fresh install from 1.31.43 or 1.31.44.
|
||||||
|
--
|
||||||
|
|
||||||
|
SET @s = (SELECT IF(
|
||||||
|
(SELECT COUNT(*)
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE table_name = 'Monitors'
|
||||||
|
AND table_schema = DATABASE()
|
||||||
|
AND column_name = 'Refresh'
|
||||||
|
) > 0,
|
||||||
|
"SELECT 'Column Refresh exists in Monitors'",
|
||||||
|
"ALTER TABLE Monitors ADD `Refresh` int(10) unsigned default NULL AFTER `ZoneCount`"
|
||||||
|
));
|
||||||
|
|
||||||
|
PREPARE stmt FROM @s;
|
||||||
|
EXECUTE stmt;
|
69
docs/api.rst
69
docs/api.rst
|
@ -13,8 +13,8 @@ The API is built in CakePHP and lives under the ``/api`` directory. It
|
||||||
provides a RESTful service and supports CRUD (create, retrieve, update, delete)
|
provides a RESTful service and supports CRUD (create, retrieve, update, delete)
|
||||||
functions for Monitors, Events, Frames, Zones and Config.
|
functions for Monitors, Events, Frames, Zones and Config.
|
||||||
|
|
||||||
Security
|
Login, Logout & API Security
|
||||||
^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
The APIs tie into ZoneMinder's existing security model. This means if you have
|
The APIs tie into ZoneMinder's existing security model. This means if you have
|
||||||
OPT_AUTH enabled, you need to log into ZoneMinder using the same browser you plan to
|
OPT_AUTH enabled, you need to log into ZoneMinder using the same browser you plan to
|
||||||
use the APIs from. If you are developing an app that relies on the API, you need
|
use the APIs from. If you are developing an app that relies on the API, you need
|
||||||
|
@ -23,12 +23,33 @@ to do a POST login from the app into ZoneMinder before you can access the API.
|
||||||
Then, you need to re-use the authentication information of the login (returned as cookie states)
|
Then, you need to re-use the authentication information of the login (returned as cookie states)
|
||||||
with subsequent APIs for the authentication information to flow through to the APIs.
|
with subsequent APIs for the authentication information to flow through to the APIs.
|
||||||
|
|
||||||
This means if you plan to use cuRL to experiment with these APIs, you first need to do
|
This means if you plan to use cuRL to experiment with these APIs, you first need to login:
|
||||||
|
|
||||||
|
**Login process for ZoneMinder v1.32.0 and above**
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
curl -XPOST -d "user=XXXX&pass=YYYY" -c cookies.txt http://yourzmip/zm/api/login.json
|
||||||
|
|
||||||
|
Staring ZM 1.32.0, you also have a `logout` API that basically clears your session. It looks like this:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
curl -b cookies.txt http://yourzmip/zm/api/logout.json
|
||||||
|
|
||||||
|
|
||||||
|
**Login process for older versions of ZoneMinder**
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
curl -d "username=XXXX&password=YYYY&action=login&view=console" -c cookies.txt http://yourzmip/zm/index.php
|
curl -d "username=XXXX&password=YYYY&action=login&view=console" -c cookies.txt http://yourzmip/zm/index.php
|
||||||
|
|
||||||
|
The equivalent logout process for older versions of ZoneMinder is:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
curl -XPOST -d "username=XXXX&password=YYYY&action=logout&view=console" -b cookies.txt http://yourzmip/zm/index.php
|
||||||
|
|
||||||
replacing *XXXX* and *YYYY* with your username and password, respectively.
|
replacing *XXXX* and *YYYY* with your username and password, respectively.
|
||||||
|
|
||||||
Please make sure you do this in a directory where you have write permissions, otherwise cookies.txt will not be created
|
Please make sure you do this in a directory where you have write permissions, otherwise cookies.txt will not be created
|
||||||
|
@ -45,16 +66,46 @@ using CuRL like so:
|
||||||
|
|
||||||
This would return a list of monitors and pass on the authentication information to the ZM API layer.
|
This would return a list of monitors and pass on the authentication information to the ZM API layer.
|
||||||
|
|
||||||
So remember, if you are using authentication, please add a ``-b cookies.txt`` to each of the commands below if you are using
|
A deeper dive into the login process
|
||||||
CuRL. If you are not using CuRL and writing your own app, you need to make sure you pass on cookies to subsequent requests
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
in your app.
|
|
||||||
|
As you might have seen above, there are two ways to login, one that uses the `login.json` API and the other that logs in using the ZM portal. If you are running ZoneMinder 1.32.0 and above, it is *strongly* recommended you use the `login.json` approach. The "old" approach will still work but is not as powerful as the API based login. Here are the reasons why:
|
||||||
|
|
||||||
|
* The "old" approach basically uses the same login webpage (`index.php`) that a user would log into when viewing the ZM console. This is not really using an API and more importantly, if you have additional components like reCAPTCHA enabled, this will not work. Using the API approach is much cleaner and will work irrespective of reCAPTCHA
|
||||||
|
|
||||||
|
* The new login API returns important information that you can use to stream videos as well, right after login. Consider for example, a typical response to the login API (`/login.json`):
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
{
|
||||||
|
"credentials": "auth=f5b9cf48693fe8552503c8ABCD5",
|
||||||
|
"append_password": 0,
|
||||||
|
"version": "1.31.44",
|
||||||
|
"apiversion": "1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
In this example I have `OPT_AUTH` enabled in ZoneMinder and it returns my credential key. You can then use this key to stream images like so:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
<img src="https://server/zm/cgi-bin/nph-zms?monitor=1&auth=<authval>" />
|
||||||
|
|
||||||
|
Where `authval` is the credentials returned to start streaming videos.
|
||||||
|
|
||||||
|
The `append_password` field will contain 1 when it is necessary for you to append your ZM password. This is the case when you set `AUTH_RELAY` in ZM options to "plain", for example. In that case, the `credentials` field may contain something like `&user=admin&pass=` and you have to add your password to that string.
|
||||||
|
|
||||||
|
|
||||||
|
.. NOTE:: It is recommended you invoke the `login` API once every 60 minutes to make sure the session stays alive. The same is true if you use the old login method too.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples (please read security notice above)
|
Examples (please read security notice above)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
You will see each URL ending in either ``.xml`` or ``.json``. This is the
|
Please remember, if you are using authentication, please add a ``-b cookies.txt`` to each of the commands below if you are using
|
||||||
format of the request, and it determines the format that any data returned to
|
CuRL. If you are not using CuRL and writing your own app, you need to make sure you pass on cookies to subsequent requests
|
||||||
you will be in. I like json, however you can use xml if you'd like.
|
in your app.
|
||||||
|
|
||||||
|
|
||||||
(In all examples, replace 'server' with IP or hostname & port where ZoneMinder is running)
|
(In all examples, replace 'server' with IP or hostname & port where ZoneMinder is running)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,475 @@
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# ZoneMinder Dericam P2 Control Protocol Module
|
||||||
|
# Copyright (C) Roman Dissertori
|
||||||
|
#
|
||||||
|
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# This module contains the implementation of the Dericam P2 device control protocol
|
||||||
|
#
|
||||||
|
package ZoneMinder::Control::DericamP2;
|
||||||
|
|
||||||
|
use 5.006;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
require ZoneMinder::Control;
|
||||||
|
|
||||||
|
our @ISA = qw(ZoneMinder::Control);
|
||||||
|
|
||||||
|
our %CamParams = ();
|
||||||
|
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# Dericam P2 Control Protocol
|
||||||
|
#
|
||||||
|
# On ControlAddress use the format :
|
||||||
|
# USERNAME:PASSWORD@ADDRESS:PORT
|
||||||
|
# eg : admin:@10.1.2.1:80
|
||||||
|
# zoneminder:zonepass@10.0.100.1:40000
|
||||||
|
#
|
||||||
|
# ==========================================================================
|
||||||
|
|
||||||
|
use ZoneMinder::Logger qw(:all);
|
||||||
|
use ZoneMinder::Config qw(:all);
|
||||||
|
|
||||||
|
use Time::HiRes qw( usleep );
|
||||||
|
|
||||||
|
sub open
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->loadMonitor();
|
||||||
|
|
||||||
|
use LWP::UserAgent;
|
||||||
|
$self->{ua} = LWP::UserAgent->new;
|
||||||
|
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );
|
||||||
|
|
||||||
|
$self->{state} = 'open';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
printMsg( $cmd, "Tx" );
|
||||||
|
|
||||||
|
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
||||||
|
Info( "http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
|
||||||
|
my $res = $self->{ua}->request($req);
|
||||||
|
|
||||||
|
if ( $res->is_success )
|
||||||
|
{
|
||||||
|
$result = !undef;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Error( "Error check failed:'".$res->status_line()."'" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( $result );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getCamParams
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=getimageattr";
|
||||||
|
|
||||||
|
my $req = $self->sendCmd( $cmd );
|
||||||
|
my $res = $self->{ua}->request($req);
|
||||||
|
|
||||||
|
if ( $res->is_success )
|
||||||
|
{
|
||||||
|
# Parse results setting values in %FCParams
|
||||||
|
my $content = $res->decoded_content;
|
||||||
|
|
||||||
|
while ($content =~ s/var\s+([^=]+)=([^;]+);//ms) {
|
||||||
|
$CamParams{$1} = $2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Error( "Error check failed:'".$res->status_line()."'" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#autoStop
|
||||||
|
#This makes use of the ZoneMinder Auto Stop Timeout on the Control Tab
|
||||||
|
sub autoStop
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $stop_command = shift;
|
||||||
|
my $autostop = shift;
|
||||||
|
if( $stop_command && $autostop)
|
||||||
|
{
|
||||||
|
Debug( "Auto Stop" );
|
||||||
|
usleep( $autostop );
|
||||||
|
my $cmd = "decoder_control.cgi?command=".$stop_command;
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reset the Camera
|
||||||
|
sub reset
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Camera Reset" );
|
||||||
|
# Move to default position
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-act=home";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
|
||||||
|
# Reset all other values to default
|
||||||
|
$cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-image_type=1&-default=on";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reboot Camera (on Sleep button)
|
||||||
|
sub sleep
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Camera Reboot" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-act=sysreboot";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop the Camera
|
||||||
|
sub moveStop
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Camera Stop" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-act=stop";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Up Arrow
|
||||||
|
sub moveConUp
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $stop_command = "1";
|
||||||
|
Debug( "Move Up" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=up&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
#$self->autoStop( $stop_command, $self->{Monitor}->{AutoStopTimeout} );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Down Arrow
|
||||||
|
sub moveConDown
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $stop_command = "3";
|
||||||
|
Debug( "Move Down" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=down&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
#$self->autoStop( $stop_command, $self->{Monitor}->{AutoStopTimeout} );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Left Arrow
|
||||||
|
sub moveConLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $stop_command = "5";
|
||||||
|
Debug( "Move Left" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=left&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
#$self->autoStop( $stop_command, $self->{Monitor}->{AutoStopTimeout} );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Right Arrow
|
||||||
|
sub moveConRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $stop_command = "7";
|
||||||
|
Debug( "Move Right" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=right&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
#$self->autoStop( $stop_command, $self->{Monitor}->{AutoStopTimeout} );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Zoom In
|
||||||
|
sub zoomConTele
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Zoom Tele" );
|
||||||
|
my $cmd = "decoder_control.cgi?command=18";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Zoom Out
|
||||||
|
sub zoomConWide
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Zoom Wide" );
|
||||||
|
my $cmd = "decoder_control.cgi?command=16";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Diagonally Up Right Arrow
|
||||||
|
#This camera does not have builtin diagonal commands so we emulate them
|
||||||
|
sub moveConUpRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Up Right" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=upright&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Diagonally Down Right Arrow
|
||||||
|
#This camera does not have builtin diagonal commands so we emulate them
|
||||||
|
sub moveConDownRight
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Down Right" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=downright&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Diagonally Up Left Arrow
|
||||||
|
#This camera does not have builtin diagonal commands so we emulate them
|
||||||
|
sub moveConUpLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Up Left" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=upleft&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Diagonally Down Left Arrow
|
||||||
|
#This camera does not have builtin diagonal commands so we emulate them
|
||||||
|
sub moveConDownLeft
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Move Diagonally Down Left" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=downnleft&-speed=45";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Set Camera Preset
|
||||||
|
#Presets must be translated into values internal to the camera
|
||||||
|
#Those values are: 30,32,34,36,38,40,42,44 for presets 1-8 respectively
|
||||||
|
sub presetSet
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
my $preset = $self->getParam( $params, 'preset' );
|
||||||
|
Debug( "Set Preset $preset" );
|
||||||
|
|
||||||
|
if (( $preset >= 1 ) && ( $preset <= 8 )) {
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=preset&-act=set&-number=".(($preset*2) + 28);
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Recall Camera Preset
|
||||||
|
#Presets must be translated into values internal to the camera
|
||||||
|
#Those values are: 31,33,35,37,39,41,43,45 for presets 1-8 respectively
|
||||||
|
sub presetGoto
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
my $preset = $self->getParam( $params, 'preset' );
|
||||||
|
Debug( "Goto Preset $preset" );
|
||||||
|
|
||||||
|
if (( $preset >= 1 ) && ( $preset <= 8 )) {
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-number=".(($preset*2) + 29);
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $preset == 9 ) {
|
||||||
|
$self->horizontalPatrol();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $preset == 10 ) {
|
||||||
|
$self->verticalPatrol();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Horizontal Patrol
|
||||||
|
sub horizontalPatrol
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Horizontal Patrol" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=hscan";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#Vertical Patrol
|
||||||
|
sub verticalPatrol
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
Debug( "Vertical Patrol" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-act=vscan";
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Increase Brightness
|
||||||
|
sub irisAbsOpen
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'brightness'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'brightness'} += $step;
|
||||||
|
$CamParams{'brightness'} = 100 if ($CamParams{'brightness'} > 100);
|
||||||
|
Debug( "Increase Brightness" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-brightness=".$CamParams{'brightness'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Decrease Brightness
|
||||||
|
sub irisAbsClose
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'brightness'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'brightness'} -= $step;
|
||||||
|
$CamParams{'brightness'} = 0 if ($CamParams{'brightness'} < 0);
|
||||||
|
Debug( "Decrease Brightness" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-brightness=".$CamParams{'brightness'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Increase Contrast
|
||||||
|
sub whiteAbsIn
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'contrast'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'contrast'} += $step;
|
||||||
|
$CamParams{'contrast'} = 100 if ($CamParams{'contrast'} > 100);
|
||||||
|
Debug( "Increase Contrast" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-contrast=".$CamParams{'contrast'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Decrease Contrast
|
||||||
|
sub whiteAbsOut
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'contrast'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'contrast'} -= $step;
|
||||||
|
$CamParams{'contrast'} = 0 if ($CamParams{'contrast'} < 0);
|
||||||
|
Debug( "Decrease Contrast" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-contrast=".$CamParams{'contrast'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#TODO Saturation cgi-bin/hi3510/param.cgi?cmd=setimageattr&-saturation=44 [0-255]
|
||||||
|
sub satIncrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'saturation'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'saturation'} += $step;
|
||||||
|
$CamParams{'saturation'} = 255 if ($CamParams{'saturation'} > 255);
|
||||||
|
Debug( "Increase Saturation" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-saturation=".$CamParams{'saturation'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub satDecrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'saturation'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'saturation'} -= $step;
|
||||||
|
$CamParams{'saturation'} = 0 if ($CamParams{'saturation'} < 0);
|
||||||
|
Debug( "Decrease Saturation" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-saturation=".$CamParams{'saturation'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
#TODO Sharpness cgi-bin/hi3510/param.cgi?cmd=setimageattr&-sharpness=37 [0-100]
|
||||||
|
sub sharpIncrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'sharpness'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'sharpness'} += $step;
|
||||||
|
$CamParams{'sharpness'} = 100 if ($CamParams{'sharpness'} > 100);
|
||||||
|
Debug( "Increase Sharpness" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-sharpness=".$CamParams{'sharpness'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub sharpDecrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'sharpness'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'sharpness'} -= $step;
|
||||||
|
$CamParams{'sharpness'} = 0 if ($CamParams{'sharpness'} < 0);
|
||||||
|
Debug( "Decrease Sharpness" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-sharpness=".$CamParams{'sharpness'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
#TODO Hue cgi-bin/hi3510/param.cgi?cmd=setimageattr&-hue=37 [0-100]
|
||||||
|
sub hueIncrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'hue'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'hue'} += $step;
|
||||||
|
$CamParams{'hue'} = 100 if ($CamParams{'hue'} > 100);
|
||||||
|
Debug( "Increase Hue" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-hue=".$CamParams{'hue'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
sub hueDecrease
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$self->getCamParams() unless($CamParams{'hue'});
|
||||||
|
my $step = $self->getParam( $params, 'step' );
|
||||||
|
|
||||||
|
$CamParams{'hue'} -= $step;
|
||||||
|
$CamParams{'hue'} = 0 if ($CamParams{'hue'} < 0);
|
||||||
|
Debug( "Decrease Hue" );
|
||||||
|
my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setimageattr&-hue=".$CamParams{'hue'};
|
||||||
|
$self->sendCmd( $cmd );
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -66,25 +66,24 @@ class AppController extends Controller {
|
||||||
$config = $this->Config->find('first', $options);
|
$config = $this->Config->find('first', $options);
|
||||||
$zmOptApi = $config['Config']['Value'];
|
$zmOptApi = $config['Config']['Value'];
|
||||||
|
|
||||||
if ($zmOptApi !='1') {
|
if ( $zmOptApi != '1' ) {
|
||||||
throw new UnauthorizedException(__('API Disabled'));
|
throw new UnauthorizedException(__('API Disabled'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// We need to reject methods that are not authenticated
|
// We need to reject methods that are not authenticated
|
||||||
// besides login and logout
|
// besides login and logout
|
||||||
if (strcasecmp($this->params->controller, "host") &&
|
if (
|
||||||
strcasecmp($this->params->action, "login") &&
|
strcasecmp($this->params->action, 'login')
|
||||||
strcasecmp($this->params->action,"logout")) {
|
&&
|
||||||
|
strcasecmp($this->params->action,"logout")
|
||||||
if (!$this->Session->read('user.Username')) {
|
) {
|
||||||
|
if ( !$this->Session->read('user.Username') ) {
|
||||||
throw new UnauthorizedException(__('Not Authenticated'));
|
throw new UnauthorizedException(__('Not Authenticated'));
|
||||||
return;
|
return;
|
||||||
} else if (!$this->Session->read('user.Enabled')) {
|
} else if ( !$this->Session->read('user.Enabled') ) {
|
||||||
throw new UnauthorizedException(__('User is not enabled'));
|
throw new UnauthorizedException(__('User is not enabled'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} # end function beforeFilter()
|
} # end function beforeFilter()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ App::uses('AppController', 'Controller');
|
||||||
*/
|
*/
|
||||||
class EventsController extends AppController {
|
class EventsController extends AppController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Components
|
* Components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
@ -17,13 +17,13 @@ class EventsController extends AppController {
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
parent::beforeFilter();
|
parent::beforeFilter();
|
||||||
$canView = $this->Session->Read('eventPermission');
|
$canView = $this->Session->Read('eventPermission');
|
||||||
if ($canView =='None') {
|
if ( $canView == 'None' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index method
|
* index method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -32,15 +32,15 @@ class EventsController extends AppController {
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
|
|
||||||
$allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY);
|
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
if (!empty($allowedMonitors)) {
|
if ( !empty($allowedMonitors) ) {
|
||||||
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
||||||
} else {
|
} else {
|
||||||
$mon_options='';
|
$mon_options = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->request->params['named']) {
|
if ( $this->request->params['named'] ) {
|
||||||
//$this->FilterComponent = $this->Components->load('Filter');
|
//$this->FilterComponent = $this->Components->load('Filter');
|
||||||
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
||||||
$conditions = $this->request->params['named'];
|
$conditions = $this->request->params['named'];
|
||||||
|
@ -61,7 +61,7 @@ class EventsController extends AppController {
|
||||||
'order' => array('StartTime'),
|
'order' => array('StartTime'),
|
||||||
'paramType' => 'querystring',
|
'paramType' => 'querystring',
|
||||||
);
|
);
|
||||||
if ( isset( $conditions['GroupId'] ) ) {
|
if ( isset($conditions['GroupId']) ) {
|
||||||
$settings['joins'] = array(
|
$settings['joins'] = array(
|
||||||
array(
|
array(
|
||||||
'table' => 'Groups_Monitors',
|
'table' => 'Groups_Monitors',
|
||||||
|
@ -93,7 +93,7 @@ class EventsController extends AppController {
|
||||||
$this->set(compact('events'));
|
$this->set(compact('events'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* view method
|
* view method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -104,16 +104,16 @@ class EventsController extends AppController {
|
||||||
$this->loadModel('Config');
|
$this->loadModel('Config');
|
||||||
|
|
||||||
$this->Event->recursive = 1;
|
$this->Event->recursive = 1;
|
||||||
if (!$this->Event->exists($id)) {
|
if ( !$this->Event->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY);
|
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
if (!empty($allowedMonitors)) {
|
if ( !empty($allowedMonitors) ) {
|
||||||
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
||||||
} else {
|
} else {
|
||||||
$mon_options='';
|
$mon_options = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array('conditions' => array(array('Event.' . $this->Event->primaryKey => $id), $mon_options));
|
$options = array('conditions' => array(array('Event.' . $this->Event->primaryKey => $id), $mon_options));
|
||||||
|
@ -149,14 +149,14 @@ class EventsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
|
|
||||||
if ($this->Session->Read('eventPermission') != 'Edit') {
|
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->request->is('post')) {
|
if ( $this->request->is('post') ) {
|
||||||
$this->Event->create();
|
$this->Event->create();
|
||||||
if ($this->Event->save($this->request->data)) {
|
if ( $this->Event->save($this->request->data) ) {
|
||||||
return $this->flash(__('The event has been saved.'), array('action' => 'index'));
|
return $this->flash(__('The event has been saved.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,18 +173,18 @@ class EventsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
|
|
||||||
if ($this->Session->Read('eventPermission') != 'Edit') {
|
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Event->id = $id;
|
$this->Event->id = $id;
|
||||||
|
|
||||||
if (!$this->Event->exists($id)) {
|
if ( !$this->Event->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->Event->save($this->request->data)) {
|
if ( $this->Event->save($this->request->data) ) {
|
||||||
$message = 'Saved';
|
$message = 'Saved';
|
||||||
} else {
|
} else {
|
||||||
$message = 'Error';
|
$message = 'Error';
|
||||||
|
@ -204,16 +204,16 @@ class EventsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete($id = null) {
|
public function delete($id = null) {
|
||||||
if ($this->Session->Read('eventPermission') != 'Edit') {
|
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->Event->id = $id;
|
$this->Event->id = $id;
|
||||||
if (!$this->Event->exists()) {
|
if ( !$this->Event->exists() ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
$this->request->allowMethod('post', 'delete');
|
$this->request->allowMethod('post', 'delete');
|
||||||
if ($this->Event->delete()) {
|
if ( $this->Event->delete() ) {
|
||||||
//$this->loadModel('Frame');
|
//$this->loadModel('Frame');
|
||||||
//$this->Event->Frame->delete();
|
//$this->Event->Frame->delete();
|
||||||
return $this->flash(__('The event has been deleted.'), array('action' => 'index'));
|
return $this->flash(__('The event has been deleted.'), array('action' => 'index'));
|
||||||
|
@ -228,7 +228,7 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
foreach ($this->params['named'] as $param_name => $value) {
|
foreach ($this->params['named'] as $param_name => $value) {
|
||||||
// Transform params into mysql
|
// Transform params into mysql
|
||||||
if (preg_match("/interval/i", $value, $matches)) {
|
if ( preg_match('/interval/i', $value, $matches) ) {
|
||||||
$condition = array("$param_name >= (date_sub(now(), $value))");
|
$condition = array("$param_name >= (date_sub(now(), $value))");
|
||||||
} else {
|
} else {
|
||||||
$condition = array($param_name => $value);
|
$condition = array($param_name => $value);
|
||||||
|
@ -254,9 +254,9 @@ class EventsController extends AppController {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$moreconditions ="";
|
$moreconditions = '';
|
||||||
foreach ($this->request->params['named'] as $name => $param) {
|
foreach ($this->request->params['named'] as $name => $param) {
|
||||||
$moreconditions = $moreconditions . " AND ".$name.$param;
|
$moreconditions = $moreconditions . ' AND '.$name.$param;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->Event->query("select MonitorId, COUNT(*) AS Count from Events WHERE (StartTime >= (DATE_SUB(NOW(), interval $interval)) $moreconditions) GROUP BY MonitorId;");
|
$query = $this->Event->query("select MonitorId, COUNT(*) AS Count from Events WHERE (StartTime >= (DATE_SUB(NOW(), interval $interval)) $moreconditions) GROUP BY MonitorId;");
|
||||||
|
@ -275,7 +275,7 @@ class EventsController extends AppController {
|
||||||
public function createThumbnail($id = null) {
|
public function createThumbnail($id = null) {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
|
|
||||||
if (!$this->Event->exists($id)) {
|
if ( !$this->Event->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,13 +285,13 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
// Find the max Frame for this Event. Error out otherwise.
|
// Find the max Frame for this Event. Error out otherwise.
|
||||||
$this->loadModel('Frame');
|
$this->loadModel('Frame');
|
||||||
if (! $frame = $this->Frame->find('first', array(
|
if ( !( $frame = $this->Frame->find('first', array(
|
||||||
'conditions' => array(
|
'conditions' => array(
|
||||||
'EventId' => $event['Event']['Id'],
|
'EventId' => $event['Event']['Id'],
|
||||||
'Score' => $event['Event']['MaxScore']
|
'Score' => $event['Event']['MaxScore']
|
||||||
)
|
)
|
||||||
))) {
|
))) ) {
|
||||||
throw new NotFoundException(__("Can not find Frame for Event " . $event['Event']['Id']));
|
throw new NotFoundException(__('Can not find Frame for Event ' . $event['Event']['Id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadModel('Config');
|
$this->loadModel('Config');
|
||||||
|
@ -304,7 +304,8 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
$config = $this->Config->find('list', array(
|
$config = $this->Config->find('list', array(
|
||||||
'conditions' => array('OR' => array(
|
'conditions' => array('OR' => array(
|
||||||
'Name' => array('ZM_WEB_LIST_THUMB_WIDTH',
|
'Name' => array(
|
||||||
|
'ZM_WEB_LIST_THUMB_WIDTH',
|
||||||
'ZM_WEB_LIST_THUMB_HEIGHT',
|
'ZM_WEB_LIST_THUMB_HEIGHT',
|
||||||
'ZM_EVENT_IMAGE_DIGITS',
|
'ZM_EVENT_IMAGE_DIGITS',
|
||||||
'ZM_DIR_IMAGES',
|
'ZM_DIR_IMAGES',
|
||||||
|
@ -340,7 +341,7 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
public function archive($id = null) {
|
public function archive($id = null) {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
if (!$this->Event->exists($id)) {
|
if ( !$this->Event->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +366,7 @@ class EventsController extends AppController {
|
||||||
public function getMaxScoreAlarmFrameId($id = null) {
|
public function getMaxScoreAlarmFrameId($id = null) {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
|
|
||||||
if (!$this->Event->exists($id)) {
|
if ( !$this->Event->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +383,7 @@ class EventsController extends AppController {
|
||||||
'Score' => $event['Event']['MaxScore']
|
'Score' => $event['Event']['MaxScore']
|
||||||
)
|
)
|
||||||
))) {
|
))) {
|
||||||
throw new NotFoundException(__("Can not find Frame for Event " . $event['Event']['Id']));
|
throw new NotFoundException(__('Can not find Frame for Event ' . $event['Event']['Id']));
|
||||||
}
|
}
|
||||||
return $frame['Frame']['Id'];
|
return $frame['Frame']['Id'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ class HostController extends AppController {
|
||||||
$zmOptAuth = $config['Config']['Value'];
|
$zmOptAuth = $config['Config']['Value'];
|
||||||
|
|
||||||
if ( $zmOptAuth == '1' ) {
|
if ( $zmOptAuth == '1' ) {
|
||||||
require_once "../../../includes/auth.php";
|
|
||||||
|
|
||||||
|
require_once "../../../includes/auth.php";
|
||||||
global $user;
|
global $user;
|
||||||
$user = $this->Session->read('user');
|
$user = $this->Session->read('user');
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ class HostController extends AppController {
|
||||||
$isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value'];
|
$isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value'];
|
||||||
|
|
||||||
if ( $isZmAuth ) {
|
if ( $isZmAuth ) {
|
||||||
|
require_once "../../../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
|
||||||
$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' ) {
|
||||||
$zmAuthHashIps= $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value'];
|
$zmAuthHashIps= $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value'];
|
||||||
|
|
|
@ -18,6 +18,7 @@ class MonitorsController extends AppController {
|
||||||
public function beforeRender() {
|
public function beforeRender() {
|
||||||
$this->set($this->Monitor->enumValues());
|
$this->set($this->Monitor->enumValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
parent::beforeFilter();
|
parent::beforeFilter();
|
||||||
$canView = $this->Session->Read('monitorPermission');
|
$canView = $this->Session->Read('monitorPermission');
|
||||||
|
@ -35,7 +36,7 @@ class MonitorsController extends AppController {
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->Monitor->recursive = 0;
|
$this->Monitor->recursive = 0;
|
||||||
|
|
||||||
if ($this->request->params['named']) {
|
if ( $this->request->params['named'] ) {
|
||||||
$this->FilterComponent = $this->Components->load('Filter');
|
$this->FilterComponent = $this->Components->load('Filter');
|
||||||
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
||||||
$conditions = $this->request->params['named'];
|
$conditions = $this->request->params['named'];
|
||||||
|
@ -49,7 +50,7 @@ class MonitorsController extends AppController {
|
||||||
}
|
}
|
||||||
$find_array = array('conditions'=>$conditions,'contain'=>array('Group'));
|
$find_array = array('conditions'=>$conditions,'contain'=>array('Group'));
|
||||||
|
|
||||||
if ( isset( $conditions['GroupId'] ) ) {
|
if ( isset($conditions['GroupId']) ) {
|
||||||
$find_array['joins'] = array(
|
$find_array['joins'] = array(
|
||||||
array(
|
array(
|
||||||
'table' => 'Groups_Monitors',
|
'table' => 'Groups_Monitors',
|
||||||
|
@ -84,11 +85,11 @@ class MonitorsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public function view($id = null) {
|
public function view($id = null) {
|
||||||
$this->Monitor->recursive = 0;
|
$this->Monitor->recursive = 0;
|
||||||
if (!$this->Monitor->exists($id)) {
|
if ( !$this->Monitor->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
$allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY);
|
$allowedMonitors=preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||||
if (!empty($allowedMonitors)) {
|
if ( !empty($allowedMonitors) ) {
|
||||||
$restricted = array('Monitor.' . $this->Monitor->primaryKey => $allowedMonitors);
|
$restricted = array('Monitor.' . $this->Monitor->primaryKey => $allowedMonitors);
|
||||||
} else {
|
} else {
|
||||||
$restricted = '';
|
$restricted = '';
|
||||||
|
@ -120,7 +121,7 @@ class MonitorsController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Monitor->create();
|
$this->Monitor->create();
|
||||||
if ($this->Monitor->save($this->request->data)) {
|
if ( $this->Monitor->save($this->request->data) ) {
|
||||||
$this->daemonControl($this->Monitor->id, 'start');
|
$this->daemonControl($this->Monitor->id, 'start');
|
||||||
//return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
|
//return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
|
||||||
$message = 'Saved';
|
$message = 'Saved';
|
||||||
|
@ -144,10 +145,10 @@ class MonitorsController extends AppController {
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
$this->Monitor->id = $id;
|
$this->Monitor->id = $id;
|
||||||
|
|
||||||
if (!$this->Monitor->exists($id)) {
|
if ( !$this->Monitor->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
if ($this->Session->Read('monitorPermission') != 'Edit') {
|
if ( $this->Session->Read('monitorPermission') != 'Edit' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -163,9 +164,17 @@ class MonitorsController extends AppController {
|
||||||
// - restart or stop this monitor after change
|
// - restart or stop this monitor after change
|
||||||
$func = $Monitor['Function'];
|
$func = $Monitor['Function'];
|
||||||
// We don't pass the request data as the monitor object because it may be a subset of the full monitor array
|
// We don't pass the request data as the monitor object because it may be a subset of the full monitor array
|
||||||
$this->daemonControl( $this->Monitor->id, 'stop' );
|
$this->daemonControl($this->Monitor->id, 'stop');
|
||||||
if ( ( $func != 'None' ) and ( (!defined('ZM_SERVER_ID')) or ($Monitor['ServerId']==ZM_SERVER_ID) ) ) {
|
if (
|
||||||
$this->daemonControl( $this->Monitor->id, 'start' );
|
( $func != 'None' )
|
||||||
|
and
|
||||||
|
(
|
||||||
|
(!defined('ZM_SERVER_ID'))
|
||||||
|
or
|
||||||
|
($Monitor['ServerId']==ZM_SERVER_ID)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$this->daemonControl($this->Monitor->id, 'start');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = 'Error ' . print_r($this->Monitor->invalidFields(), true);
|
$message = 'Error ' . print_r($this->Monitor->invalidFields(), true);
|
||||||
|
@ -187,10 +196,10 @@ class MonitorsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public function delete($id = null) {
|
public function delete($id = null) {
|
||||||
$this->Monitor->id = $id;
|
$this->Monitor->id = $id;
|
||||||
if (!$this->Monitor->exists()) {
|
if ( !$this->Monitor->exists() ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
if ($this->Session->Read('systemPermission') != 'Edit') {
|
if ( $this->Session->Read('systemPermission') != 'Edit' ) {
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +207,7 @@ class MonitorsController extends AppController {
|
||||||
|
|
||||||
$this->daemonControl($this->Monitor->id, 'stop');
|
$this->daemonControl($this->Monitor->id, 'stop');
|
||||||
|
|
||||||
if ($this->Monitor->delete()) {
|
if ( $this->Monitor->delete() ) {
|
||||||
return $this->flash(__('The monitor has been deleted.'), array('action' => 'index'));
|
return $this->flash(__('The monitor has been deleted.'), array('action' => 'index'));
|
||||||
} else {
|
} else {
|
||||||
return $this->flash(__('The monitor could not be deleted. Please, try again.'), array('action' => 'index'));
|
return $this->flash(__('The monitor could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||||
|
@ -226,7 +235,7 @@ class MonitorsController extends AppController {
|
||||||
public function alarm() {
|
public function alarm() {
|
||||||
$id = $this->request->params['named']['id'];
|
$id = $this->request->params['named']['id'];
|
||||||
$cmd = strtolower($this->request->params['named']['command']);
|
$cmd = strtolower($this->request->params['named']['command']);
|
||||||
if (!$this->Monitor->exists($id)) {
|
if ( !$this->Monitor->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
if ( $cmd != 'on' && $cmd != 'off' && $cmd != 'status' ) {
|
if ( $cmd != 'on' && $cmd != 'off' && $cmd != 'status' ) {
|
||||||
|
@ -260,7 +269,7 @@ class MonitorsController extends AppController {
|
||||||
$config = $this->Config->find('first', $options);
|
$config = $this->Config->find('first', $options);
|
||||||
$zmAuthRelay = $config['Config']['Value'];
|
$zmAuthRelay = $config['Config']['Value'];
|
||||||
|
|
||||||
$auth='';
|
$auth = '';
|
||||||
if ( $zmOptAuth ) {
|
if ( $zmOptAuth ) {
|
||||||
if ( $zmAuthRelay == 'hashed' ) {
|
if ( $zmAuthRelay == 'hashed' ) {
|
||||||
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_SECRET'));
|
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_SECRET'));
|
||||||
|
@ -293,7 +302,7 @@ class MonitorsController extends AppController {
|
||||||
$id = $this->request->params['named']['id'];
|
$id = $this->request->params['named']['id'];
|
||||||
$daemon = $this->request->params['named']['daemon'];
|
$daemon = $this->request->params['named']['daemon'];
|
||||||
|
|
||||||
if (!$this->Monitor->exists($id)) {
|
if ( !$this->Monitor->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,14 @@ App::uses('AppController', 'Controller');
|
||||||
*/
|
*/
|
||||||
class ZonePresetsController extends AppController {
|
class ZonePresetsController extends AppController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Components
|
* Components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('RequestHandler');
|
public $components = array('RequestHandler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index method
|
* index method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -28,7 +28,7 @@ class ZonePresetsController extends AppController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* view method
|
* view method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -36,28 +36,28 @@ class ZonePresetsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function view($id = null) {
|
public function view($id = null) {
|
||||||
if (!$this->ZonePreset->exists($id)) {
|
if ( !$this->ZonePreset->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid zone preset'));
|
throw new NotFoundException(__('Invalid zone preset'));
|
||||||
}
|
}
|
||||||
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
||||||
$this->set('zonePreset', $this->ZonePreset->find('first', $options));
|
$this->set('zonePreset', $this->ZonePreset->find('first', $options));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add method
|
* add method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
if ($this->request->is('post')) {
|
if ( $this->request->is('post') ) {
|
||||||
$this->ZonePreset->create();
|
$this->ZonePreset->create();
|
||||||
if ($this->ZonePreset->save($this->request->data)) {
|
if ( $this->ZonePreset->save($this->request->data) ) {
|
||||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit method
|
* edit method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -65,11 +65,11 @@ class ZonePresetsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
if (!$this->ZonePreset->exists($id)) {
|
if ( !$this->ZonePreset->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid zone preset'));
|
throw new NotFoundException(__('Invalid zone preset'));
|
||||||
}
|
}
|
||||||
if ($this->request->is(array('post', 'put'))) {
|
if ( $this->request->is(array('post', 'put')) ) {
|
||||||
if ($this->ZonePreset->save($this->request->data)) {
|
if ( $this->ZonePreset->save($this->request->data) ) {
|
||||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,7 +78,7 @@ class ZonePresetsController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete method
|
* delete method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -87,13 +87,14 @@ class ZonePresetsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public function delete($id = null) {
|
public function delete($id = null) {
|
||||||
$this->ZonePreset->id = $id;
|
$this->ZonePreset->id = $id;
|
||||||
if (!$this->ZonePreset->exists()) {
|
if ( !$this->ZonePreset->exists() ) {
|
||||||
throw new NotFoundException(__('Invalid zone preset'));
|
throw new NotFoundException(__('Invalid zone preset'));
|
||||||
}
|
}
|
||||||
$this->request->allowMethod('post', 'delete');
|
$this->request->allowMethod('post', 'delete');
|
||||||
if ($this->ZonePreset->delete()) {
|
if ( $this->ZonePreset->delete() ) {
|
||||||
return $this->flash(__('The zone preset has been deleted.'), array('action' => 'index'));
|
return $this->flash(__('The zone preset has been deleted.'), array('action' => 'index'));
|
||||||
} else {
|
} else {
|
||||||
return $this->flash(__('The zone preset could not be deleted. Please, try again.'), array('action' => 'index'));
|
return $this->flash(__('The zone preset could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
} // end class ZonePresetsController
|
||||||
|
|
|
@ -7,28 +7,26 @@ App::uses('AppController', 'Controller');
|
||||||
*/
|
*/
|
||||||
class ZonesController extends AppController {
|
class ZonesController extends AppController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Components
|
* Components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('RequestHandler');
|
public $components = array('RequestHandler');
|
||||||
|
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
parent::beforeFilter();
|
parent::beforeFilter();
|
||||||
$canView = $this->Session->Read('monitorPermission');
|
$canView = $this->Session->Read('monitorPermission');
|
||||||
if ($canView =='None')
|
if ( $canView =='None' ) {
|
||||||
{
|
|
||||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// Find all zones which belong to a MonitorId
|
||||||
|
public function forMonitor($id = null) {
|
||||||
// Find all zones which belong to a MonitorId
|
|
||||||
public function forMonitor($id = null) {
|
|
||||||
$this->loadModel('Monitor');
|
$this->loadModel('Monitor');
|
||||||
if (!$this->Monitor->exists($id)) {
|
if ( !$this->Monitor->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
$this->Zone->recursive = -1;
|
$this->Zone->recursive = -1;
|
||||||
|
@ -39,34 +37,33 @@ public function forMonitor($id = null) {
|
||||||
'zones' => $zones,
|
'zones' => $zones,
|
||||||
'_serialize' => array('zones')
|
'_serialize' => array('zones')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
public function index() {
|
|
||||||
|
public function index() {
|
||||||
$this->Zone->recursive = -1;
|
$this->Zone->recursive = -1;
|
||||||
|
|
||||||
$allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY);
|
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||||
if (!empty($allowedMonitors))
|
if ( !empty($allowedMonitors) ) {
|
||||||
{
|
|
||||||
$mon_options = array('Zones.MonitorId' => $allowedMonitors);
|
$mon_options = array('Zones.MonitorId' => $allowedMonitors);
|
||||||
}
|
} else {
|
||||||
else
|
$mon_options = '';
|
||||||
{
|
|
||||||
$mon_options='';
|
|
||||||
}
|
}
|
||||||
$zones = $this->Zone->find('all',$mon_options);
|
$zones = $this->Zone->find('all',$mon_options);
|
||||||
$this->set(array(
|
$this->set(array(
|
||||||
'zones' => $zones,
|
'zones' => $zones,
|
||||||
'_serialize' => array('zones')
|
'_serialize' => array('zones')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* add method
|
* add method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
if ($this->request->is('post')) {
|
if ( $this->request->is('post') ) {
|
||||||
$this->Zone->create();
|
$this->Zone->create();
|
||||||
if ($this->Zone->save($this->request->data)) {
|
if ( $this->Zone->save($this->request->data) ) {
|
||||||
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +71,7 @@ public function index() {
|
||||||
$this->set(compact('monitors'));
|
$this->set(compact('monitors'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit method
|
* edit method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -84,11 +81,11 @@ public function index() {
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
$this->Zone->id = $id;
|
$this->Zone->id = $id;
|
||||||
|
|
||||||
if (!$this->Zone->exists($id)) {
|
if ( !$this->Zone->exists($id) ) {
|
||||||
throw new NotFoundException(__('Invalid zone'));
|
throw new NotFoundException(__('Invalid zone'));
|
||||||
}
|
}
|
||||||
if ($this->request->is(array('post', 'put'))) {
|
if ( $this->request->is(array('post', 'put')) ) {
|
||||||
if ($this->Zone->save($this->request->data)) {
|
if ( $this->Zone->save($this->request->data) ) {
|
||||||
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,7 +96,7 @@ public function index() {
|
||||||
$this->set(compact('monitors'));
|
$this->set(compact('monitors'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete method
|
* delete method
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -108,27 +105,24 @@ public function index() {
|
||||||
*/
|
*/
|
||||||
public function delete($id = null) {
|
public function delete($id = null) {
|
||||||
$this->Zone->id = $id;
|
$this->Zone->id = $id;
|
||||||
if (!$this->Zone->exists()) {
|
if ( !$this->Zone->exists() ) {
|
||||||
throw new NotFoundException(__('Invalid zone'));
|
throw new NotFoundException(__('Invalid zone'));
|
||||||
}
|
}
|
||||||
$this->request->allowMethod('post', 'delete');
|
$this->request->allowMethod('post', 'delete');
|
||||||
if ($this->Zone->delete()) {
|
if ( $this->Zone->delete() ) {
|
||||||
return $this->flash(__('The zone has been deleted.'), array('action' => 'index'));
|
return $this->flash(__('The zone has been deleted.'), array('action' => 'index'));
|
||||||
} else {
|
} else {
|
||||||
return $this->flash(__('The zone could not be deleted. Please, try again.'), array('action' => 'index'));
|
return $this->flash(__('The zone could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createZoneImage($id = null) {
|
||||||
|
|
||||||
public function createZoneImage( $id = null ) {
|
|
||||||
$this->loadModel('Monitor');
|
$this->loadModel('Monitor');
|
||||||
$this->Monitor->id = $id;
|
$this->Monitor->id = $id;
|
||||||
if (!$this->Monitor->exists()) {
|
if ( !$this->Monitor->exists() ) {
|
||||||
throw new NotFoundException(__('Invalid zone'));
|
throw new NotFoundException(__('Invalid zone'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->loadModel('Config');
|
$this->loadModel('Config');
|
||||||
$zm_dir_images = $this->Config->find('list', array(
|
$zm_dir_images = $this->Config->find('list', array(
|
||||||
'conditions' => array('Name' => 'ZM_DIR_IMAGES'),
|
'conditions' => array('Name' => 'ZM_DIR_IMAGES'),
|
||||||
|
@ -143,12 +137,11 @@ public function index() {
|
||||||
chdir($images_path);
|
chdir($images_path);
|
||||||
|
|
||||||
$command = escapeshellcmd("$zm_path_bin/zmu -z -m $id");
|
$command = escapeshellcmd("$zm_path_bin/zmu -z -m $id");
|
||||||
system( $command, $status );
|
system($command, $status);
|
||||||
|
|
||||||
$this->set(array(
|
$this->set(array(
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'_serialize' => array('status')
|
'_serialize' => array('status')
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ private $defaults = array(
|
||||||
'CanMoveRel' => 0,
|
'CanMoveRel' => 0,
|
||||||
'CanMoveCon' => 0,
|
'CanMoveCon' => 0,
|
||||||
'CanPan' => 0,
|
'CanPan' => 0,
|
||||||
|
'CanReset' => 0,
|
||||||
|
'CanSleep' => 0,
|
||||||
|
'CanWake' => 0,
|
||||||
'MinPanRange' => NULL,
|
'MinPanRange' => NULL,
|
||||||
'MaxPanRange' => NULL,
|
'MaxPanRange' => NULL,
|
||||||
'MinPanStep' => NULL,
|
'MinPanStep' => NULL,
|
||||||
|
@ -103,7 +106,7 @@ private $defaults = array(
|
||||||
if ( $IdOrRow ) {
|
if ( $IdOrRow ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||||
$row = dbFetchOne( 'SELECT * FROM Control WHERE Id=?', NULL, array( $IdOrRow ) );
|
$row = dbFetchOne( 'SELECT * FROM Controls WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||||
if ( ! $row ) {
|
if ( ! $row ) {
|
||||||
Error("Unable to load Control record for Id=" . $IdOrRow );
|
Error("Unable to load Control record for Id=" . $IdOrRow );
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,19 @@ private $defaults = array(
|
||||||
'Name' => '',
|
'Name' => '',
|
||||||
'StorageId' => 0,
|
'StorageId' => 0,
|
||||||
'ServerId' => 0,
|
'ServerId' => 0,
|
||||||
|
'Type' => 'Ffmpeg',
|
||||||
'Function' => 'None',
|
'Function' => 'None',
|
||||||
'Enabled' => 1,
|
'Enabled' => 1,
|
||||||
|
'LinkedMonitors' => null,
|
||||||
'Width' => null,
|
'Width' => null,
|
||||||
'Height' => null,
|
'Height' => null,
|
||||||
'Orientation' => null,
|
'Orientation' => null,
|
||||||
'AnalysisFPSLimit' => null,
|
'AnalysisFPSLimit' => null,
|
||||||
'ZoneCount' => 0,
|
'ZoneCount' => 0,
|
||||||
'Triggers' => null,
|
'Triggers' => null,
|
||||||
'Type' => 'Ffmpeg',
|
|
||||||
'MaxFPS' => null,
|
'MaxFPS' => null,
|
||||||
'AlarmMaxFPS' => null,
|
'AlarmMaxFPS' => null,
|
||||||
|
'Refresh' => null,
|
||||||
);
|
);
|
||||||
private $status_fields = array(
|
private $status_fields = array(
|
||||||
'AnalysisFPS' => null,
|
'AnalysisFPS' => null,
|
||||||
|
|
|
@ -41,7 +41,7 @@ var popupSizes = {
|
||||||
'filter': { 'width': 900, 'height': 700 },
|
'filter': { 'width': 900, 'height': 700 },
|
||||||
'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 200 },
|
'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 200 },
|
||||||
'frames': { 'width': 600, 'height': 600 },
|
'frames': { 'width': 600, 'height': 600 },
|
||||||
'function': { 'width': 350, 'height': 160 },
|
'function': { 'width': 350, 'height': 260 },
|
||||||
'group': { 'width': 760, 'height': 600 },
|
'group': { 'width': 760, 'height': 600 },
|
||||||
'groups': { 'width': 540, 'height': 420 },
|
'groups': { 'width': 540, 'height': 420 },
|
||||||
'image': { 'addWidth': 48, 'addHeight': 80 },
|
'image': { 'addWidth': 48, 'addHeight': 80 },
|
||||||
|
@ -54,7 +54,7 @@ var popupSizes = {
|
||||||
'monitorselect':{ 'width': 160, 'height': 200 },
|
'monitorselect':{ 'width': 160, 'height': 200 },
|
||||||
'montage': { 'width': -1, 'height': -1 },
|
'montage': { 'width': -1, 'height': -1 },
|
||||||
'onvifprobe': { 'width': 700, 'height': 550 },
|
'onvifprobe': { 'width': 700, 'height': 550 },
|
||||||
'optionhelp': { 'width': 400, 'height': 320 },
|
'optionhelp': { 'width': 400, 'height': 400 },
|
||||||
'options': { 'width': 1000, 'height': 660 },
|
'options': { 'width': 1000, 'height': 660 },
|
||||||
'preset': { 'width': 300, 'height': 220 },
|
'preset': { 'width': 300, 'height': 220 },
|
||||||
'server': { 'width': 600, 'height': 405 },
|
'server': { 'width': 600, 'height': 405 },
|
||||||
|
|
|
@ -260,8 +260,8 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
||||||
<thead class="thead-highlight">
|
<thead class="thead-highlight">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="colId"><?php echo translate('Id') ?></th>
|
<th class="colId"><?php echo translate('Id') ?></th>
|
||||||
<th class="colName"><?php echo translate('name') ?></th>
|
<th class="colName"><?php echo translate('Name') ?></th>
|
||||||
<th class="colPath"><?php echo translate('path') ?></th>
|
<th class="colPath"><?php echo translate('Path') ?></th>
|
||||||
<th class="colType"><?php echo translate('Type') ?></th>
|
<th class="colType"><?php echo translate('Type') ?></th>
|
||||||
<th class="colScheme"><?php echo translate('StorageScheme') ?></th>
|
<th class="colScheme"><?php echo translate('StorageScheme') ?></th>
|
||||||
<th class="colServer"><?php echo translate('Server') ?></th>
|
<th class="colServer"><?php echo translate('Server') ?></th>
|
||||||
|
|
Loading…
Reference in New Issue