Merge branch 'add_export_to_filter' of github.com:connortechnology/ZoneMinder into add_export_to_filter
This commit is contained in:
commit
8a43f4400e
|
@ -0,0 +1,326 @@
|
|||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder iPhone Control Protocol Module, $Date: 2018-07-15 00:20:00 +0000 $, $Revision: 0003 $
|
||||
# Copyright (C) 2001-2008 Philip Coombes
|
||||
#
|
||||
# Modified for iPhone ipcamera for IOS BY PETER ZARGLIS n 2018-06-09 13:45:00
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# This module contains the implementation of the iPhone ipcamera for IOS
|
||||
# control protocol.
|
||||
#
|
||||
# ==========================================================================
|
||||
package ZoneMinder::Control::IPCAMIOS;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
require ZoneMinder::Base;
|
||||
require ZoneMinder::Control;
|
||||
|
||||
our @ISA = qw(ZoneMinder::Control);
|
||||
|
||||
our $VERSION = $ZoneMinder::Base::VERSION;
|
||||
|
||||
# ==========================================================================
|
||||
#
|
||||
# iPhone ipcamera for IOS Protocol
|
||||
#
|
||||
# ==========================================================================
|
||||
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
use ZoneMinder::Config qw(:all);
|
||||
use Time::HiRes qw( usleep );
|
||||
|
||||
my $loopfactor=100000;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
my $id = shift;
|
||||
my $self = ZoneMinder::Control->new( $id );
|
||||
my $logindetails = "";
|
||||
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/.*://;
|
||||
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();
|
||||
|
||||
use LWP::UserAgent;
|
||||
$self->{ua} = LWP::UserAgent->new;
|
||||
$self->{ua}->agent( "ZoneMinder Control Agent" );
|
||||
|
||||
|
||||
$self->{state} = 'open';
|
||||
}
|
||||
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{state} = 'closed';
|
||||
}
|
||||
|
||||
sub sendCmd
|
||||
{
|
||||
my $self = shift;
|
||||
my $cmd = shift;
|
||||
my $result = undef;
|
||||
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
||||
my $res = $self->{ua}->request($req);
|
||||
if ( $res->is_success )
|
||||
{
|
||||
$result = $res->decoded_content;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error( "Error check failed: '".$res->status_line()."'" );
|
||||
}
|
||||
return( $result );
|
||||
}
|
||||
sub getDisplayAttr
|
||||
{
|
||||
my $self = shift;
|
||||
my $param = shift;
|
||||
my $cmdget = "parameters?";
|
||||
my $resp = $self->sendCmd( $cmdget );
|
||||
my @fields = split(',',$resp);
|
||||
my $response=$fields[$param];
|
||||
my @buffer=split(':',$response);
|
||||
my $response2=$buffer[1];
|
||||
return ($response2);
|
||||
}
|
||||
|
||||
sub sleep
|
||||
{
|
||||
|
||||
}
|
||||
# Flip image vertically -> Horz -> off
|
||||
sub moveConUp
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Flip Image" );
|
||||
my $dvalue=$self->getDisplayAttr(3);
|
||||
if ( $dvalue == 2 )
|
||||
{
|
||||
$dvalue=0;
|
||||
my $cmd = "parameters?flip=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
$dvalue=$dvalue+1;
|
||||
my $cmd = "parameters?flip=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
# Change camera (front facing or back)
|
||||
sub moveConDown
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Change Camera" );
|
||||
my $dvalue=$self->getDisplayAttr(7);
|
||||
if ( $dvalue == 0 )
|
||||
{
|
||||
my $cmd = "parameters?camera=1";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
my $cmd = "parameters?camera=0";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
# Picture Orientation Clockwise
|
||||
sub moveConRight
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Orientation" );
|
||||
my $dvalue=$self->getDisplayAttr(10);
|
||||
if ( $dvalue == 1 )
|
||||
{
|
||||
$dvalue=4;
|
||||
my $cmd = "parameters?rotation=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
$dvalue=$dvalue-1;
|
||||
my $cmd = "parameters?rotation=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
# Picture Orientation Anti-Clockwise
|
||||
sub moveConLeft
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Orientation" );
|
||||
my $dvalue=$self->getDisplayAttr(10);
|
||||
if ( $dvalue == 4 )
|
||||
{
|
||||
$dvalue=1;
|
||||
my $cmd = "parameters?rotation=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
$dvalue=$dvalue+1;
|
||||
my $cmd = "parameters?rotation=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
|
||||
# presetHome is used to turn off Torch, unlock Focus, unlock Exposure, unlock white-balance, rotation, image flipping
|
||||
# Just basically reset all the little variables and set it to medium quality
|
||||
# Rotation = 0 means it will autoselect using built in detection
|
||||
sub presetHome
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Home Preset" );
|
||||
my $cmd = "parameters?torch=0&focus=0&wb=0&exposure=0&rotation=0&flip=0&quality=0.5";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
|
||||
sub focusAbsNear
|
||||
# Focus Un/Lock
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Focus Un/Lock" );
|
||||
my $dvalue=$self->getDisplayAttr(2);
|
||||
if ( $dvalue == 0 )
|
||||
{
|
||||
my $cmd = "parameters?focus=1";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
my $cmd = "parameters?focus=0";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
|
||||
sub focusAbsFar
|
||||
# Exposure Un/Lock
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Exposure Un/Lock" );
|
||||
my $dvalue=$self->getDisplayAttr(11);
|
||||
if ( $dvalue == 0 )
|
||||
{
|
||||
my $cmd = "parameters?exposure=1";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
my $cmd = "parameters?exposure=0";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
# Increase stream Quality (from 0 to 10)
|
||||
sub irisAbsOpen
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Quality" );
|
||||
my $dvalue=$self->getDisplayAttr(8);
|
||||
if ( $dvalue < 1 )
|
||||
{
|
||||
$dvalue=$dvalue+0.1;
|
||||
my $cmd = "parameters?quality=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
|
||||
# Decrease stream Quality (from 10 to 0)
|
||||
sub irisAbsClose
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Quality" );
|
||||
my $dvalue=$self->getDisplayAttr(8);
|
||||
if ( $dvalue > 0 )
|
||||
{
|
||||
$dvalue=$dvalue-0.1;
|
||||
my $cmd = "parameters?quality=$dvalue";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
# White Balance Un/Lock
|
||||
sub whiteAbsIn
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "White Balance" );
|
||||
my $dvalue=$self->getDisplayAttr(9);
|
||||
if ( $dvalue == 0 )
|
||||
{
|
||||
my $cmd = "parameters?wb=1";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
my $cmd = "parameters?wb=0";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
|
||||
# Torch control on/off
|
||||
sub whiteAbsOut
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
Debug( "Torch" );
|
||||
my $dvalue=$self->getDisplayAttr(5);
|
||||
if ( $dvalue == 0 )
|
||||
{
|
||||
my $cmd = "parameters?torch=1";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
my $cmd = "parameters?torch=0";
|
||||
$self->sendCmd( $cmd );
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -173,6 +173,12 @@ my $cwd = getcwd;
|
|||
|
||||
my $video_name;
|
||||
my @event_ids;
|
||||
|
||||
# Fail if the path to a valid ffmpeg binary is not set
|
||||
if ( ! -x $Config{ZM_PATH_FFMPEG} ) {
|
||||
Fatal("Ffmpeg binary not found or not executable. Verify ZM_PATH_FFMPEG points to ffmpeg, avconv, or a compatible binary.");
|
||||
}
|
||||
|
||||
if ( $event_id ) {
|
||||
@event_ids = ( $event_id );
|
||||
|
||||
|
|
|
@ -27,116 +27,64 @@ App::uses('CrudControllerTrait', 'Crud.Lib');
|
|||
* Add your application-wide methods in the class below, your controllers
|
||||
* will inherit them.
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
use CrudControllerTrait;
|
||||
use CrudControllerTrait;
|
||||
|
||||
public $components = [
|
||||
'Session', // We are going to use SessionHelper to check PHP session vars
|
||||
'RequestHandler',
|
||||
'Crud.Crud' => [
|
||||
'actions' => [
|
||||
'index' => 'Crud.Index',
|
||||
'add' => 'Crud.Add',
|
||||
'edit' => 'Crud.Edit',
|
||||
'view' => 'Crud.View',
|
||||
'keyvalue' => 'Crud.List',
|
||||
'category' => 'Crud.Category'
|
||||
],
|
||||
'listeners' => ['Api', 'ApiTransformation']
|
||||
#],
|
||||
public $components = [
|
||||
'Session', // We are going to use SessionHelper to check PHP session vars
|
||||
'RequestHandler',
|
||||
'Crud.Crud' => [
|
||||
'actions' => [
|
||||
'index' => 'Crud.Index',
|
||||
'add' => 'Crud.Add',
|
||||
'edit' => 'Crud.Edit',
|
||||
'view' => 'Crud.View',
|
||||
'keyvalue' => 'Crud.List',
|
||||
'category' => 'Crud.Category'
|
||||
],
|
||||
'listeners' => ['Api', 'ApiTransformation']
|
||||
#],
|
||||
#'DebugKit.Toolbar' => [
|
||||
# 'bootstrap' => true, 'routes' => true
|
||||
]
|
||||
];
|
||||
];
|
||||
|
||||
// Global beforeFilter function
|
||||
//Zoneminder sets the username session variable
|
||||
// to the logged in user. If this variable is set
|
||||
// then you are logged in
|
||||
// its pretty simple to extend this to also check
|
||||
// for role and deny API access in future
|
||||
// Also checking to do this only if ZM_OPT_USE_AUTH is on
|
||||
public function beforeFilter() {
|
||||
$this->loadModel('Config');
|
||||
|
||||
// Global beforeFilter function
|
||||
//Zoneminder sets the username session variable
|
||||
// to the logged in user. If this variable is set
|
||||
// then you are logged in
|
||||
// its pretty simple to extend this to also check
|
||||
// for role and deny API access in future
|
||||
// Also checking to do this only if ZM_OPT_USE_AUTH is on
|
||||
public function beforeFilter() {
|
||||
$this->loadModel('Config');
|
||||
|
||||
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_API'));
|
||||
$config = $this->Config->find('first', $options);
|
||||
$zmOptApi = $config['Config']['Value'];
|
||||
|
||||
if ($zmOptApi !='1') {
|
||||
if ($zmOptApi !='1') {
|
||||
throw new UnauthorizedException(__('API Disabled'));
|
||||
return;
|
||||
}
|
||||
|
||||
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH'));
|
||||
$config = $this->Config->find('first', $options);
|
||||
$zmOptAuth = $config['Config']['Value'];
|
||||
|
||||
if ( $zmOptAuth == '1' ) {
|
||||
require_once "../../../includes/auth.php";
|
||||
|
||||
global $user;
|
||||
$user = $this->Session->read('user');
|
||||
|
||||
if ( isset($_REQUEST['user']) and isset($_REQUEST['pass']) ) {
|
||||
$user = userLogin($_REQUEST['user'],$_REQUEST['pass']);
|
||||
if ( !$user ) {
|
||||
throw new UnauthorizedException(__('User not found'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['auth']) ) {
|
||||
$user = getAuthUser($_REQUEST['auth']);
|
||||
if ( ! $user ) {
|
||||
throw new UnauthorizedException(__('User not found'));
|
||||
return;
|
||||
}
|
||||
} # end if REQUEST['auth']
|
||||
|
||||
if ( 0 and $user ) {
|
||||
# We have to redo the session variables because cakephp's Session code will overwrite the normal php session
|
||||
# Actually I'm not sure that is true. Getting indeterminate behaviour
|
||||
Logger::Debug("user.Username: " . $this->Session->read('user.Username'));
|
||||
if ( ! $this->Session->Write('user', $user) )
|
||||
$this->log("Error writing session var user");
|
||||
Logger::Debug("user.Username: " . $this->Session->read('user.Username'));
|
||||
if ( ! $this->Session->Write('user.Username', $user['Username']) )
|
||||
$this->log("Error writing session var user.Username");
|
||||
if ( ! $this->Session->Write('password', $user['Password']) )
|
||||
$this->log("Error writing session var user.Username");
|
||||
if ( ! $this->Session->Write('user.Enabled', $user['Enabled']) )
|
||||
$this->log("Error writing session var user.Enabled");
|
||||
if ( ! $this->Session->Write('remoteAddr', $_SERVER['REMOTE_ADDR']) )
|
||||
$this->log("Error writing session var remoteAddr");
|
||||
}
|
||||
|
||||
if ( ! $this->Session->read('user.Username') ) {
|
||||
throw new UnauthorizedException(__('Not Authenticated'));
|
||||
return;
|
||||
} else if ( ! $this->Session->read('user.Enabled') ) {
|
||||
throw new UnauthorizedException(__('User is not enabled'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->Session->Write('allowedMonitors',$user['MonitorIds']);
|
||||
$this->Session->Write('streamPermission',$user['Stream']);
|
||||
$this->Session->Write('eventPermission',$user['Events']);
|
||||
$this->Session->Write('controlPermission',$user['Control']);
|
||||
$this->Session->Write('systemPermission',$user['System']);
|
||||
$this->Session->Write('monitorPermission',$user['Monitors']);
|
||||
} else {
|
||||
// if auth is not on, you can do everything
|
||||
//$userMonitors = $this->User->find('first', $options);
|
||||
$this->Session->Write('allowedMonitors','');
|
||||
$this->Session->Write('streamPermission','View');
|
||||
$this->Session->Write('eventPermission','Edit');
|
||||
$this->Session->Write('controlPermission','Edit');
|
||||
$this->Session->Write('systemPermission','Edit');
|
||||
$this->Session->Write('monitorPermission','Edit');
|
||||
}
|
||||
// We need to reject methods that are not authenticated
|
||||
// besides login and logout
|
||||
if (strcasecmp($this->params->controller, "host") &&
|
||||
strcasecmp($this->params->action, "login") &&
|
||||
strcasecmp($this->params->action,"logout")) {
|
||||
|
||||
if (!$this->Session->read('user.Username')) {
|
||||
throw new UnauthorizedException(__('Not Authenticated'));
|
||||
return;
|
||||
} else if (!$this->Session->read('user.Enabled')) {
|
||||
throw new UnauthorizedException(__('User is not enabled'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} # end function beforeFilter()
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ App::uses('AppController', 'Controller');
|
|||
|
||||
class HostController extends AppController {
|
||||
|
||||
public $components = array('RequestHandler');
|
||||
public $components = array('RequestHandler', 'Session');
|
||||
|
||||
public function daemonCheck($daemon=false, $args=false) {
|
||||
public function daemonCheck($daemon=false, $args=false) {
|
||||
$string = Configure::read('ZM_PATH_BIN').'/zmdc.pl check';
|
||||
if ( $daemon ) {
|
||||
$string .= " $daemon";
|
||||
|
@ -15,27 +15,139 @@ class HostController extends AppController {
|
|||
$result = exec($string);
|
||||
$result = preg_match('/running/', $result);
|
||||
|
||||
$this->set(array(
|
||||
'result' => $result,
|
||||
'_serialize' => array('result')
|
||||
));
|
||||
}
|
||||
$this->set(array(
|
||||
'result' => $result,
|
||||
'_serialize' => array('result')
|
||||
));
|
||||
}
|
||||
|
||||
function getLoad() {
|
||||
$load = sys_getloadavg();
|
||||
function getLoad() {
|
||||
$load = sys_getloadavg();
|
||||
|
||||
$this->set(array(
|
||||
'load' => $load,
|
||||
'_serialize' => array('load')
|
||||
));
|
||||
}
|
||||
$this->set(array(
|
||||
'load' => $load,
|
||||
'_serialize' => array('load')
|
||||
));
|
||||
}
|
||||
|
||||
function getCredentials() {
|
||||
// ignore debug warnings from other functions
|
||||
$this->view='Json';
|
||||
|
||||
|
||||
function login() {
|
||||
|
||||
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH'));
|
||||
$config = $this->Config->find('first', $options);
|
||||
$zmOptAuth = $config['Config']['Value'];
|
||||
|
||||
if ( $zmOptAuth == '1' ) {
|
||||
require_once "../../../includes/auth.php";
|
||||
|
||||
global $user;
|
||||
$user = $this->Session->read('user');
|
||||
|
||||
|
||||
|
||||
$mUser = $this->request->data('user');
|
||||
$mPassword = $this->request->data('pass');
|
||||
$mAuth = $this->request->data('auth');
|
||||
|
||||
|
||||
if ( $mUser and $mPassword) {
|
||||
$user = userLogin($mUser, $mPassword);
|
||||
if ( !$user ) {
|
||||
throw new UnauthorizedException(__('User not found or incorrect password'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
elseif ( $mAuth ) {
|
||||
$user = getAuthUser($mAuth);
|
||||
if ( ! $user ) {
|
||||
throw new UnauthorizedException(__('User not found or incorrect password'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new UnauthorizedException(__('missing credentials'));
|
||||
}
|
||||
|
||||
if ( 0 and $user ) {
|
||||
# We have to redo the session variables because cakephp's Session code will overwrite the normal php session
|
||||
# Actually I'm not sure that is true. Getting indeterminate behaviour
|
||||
Logger::Debug("user.Username: " . $this->Session->read('user.Username'));
|
||||
if ( ! $this->Session->Write('user', $user) )
|
||||
$this->log("Error writing session var user");
|
||||
Logger::Debug("user.Username: " . $this->Session->read('user.Username'));
|
||||
if ( ! $this->Session->Write('user.Username', $user['Username']) )
|
||||
$this->log("Error writing session var user.Username");
|
||||
if ( ! $this->Session->Write('password', $user['Password']) )
|
||||
$this->log("Error writing session var user.Username");
|
||||
if ( ! $this->Session->Write('user.Enabled', $user['Enabled']) )
|
||||
$this->log("Error writing session var user.Enabled");
|
||||
if ( ! $this->Session->Write('remoteAddr', $_SERVER['REMOTE_ADDR']) )
|
||||
$this->log("Error writing session var remoteAddr");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// I don't think this is really needed - the Username part
|
||||
// Enabled check is ok
|
||||
if ( !$user['Username'] ) {
|
||||
throw new UnauthorizedException(__('Not Authenticated'));
|
||||
return;
|
||||
} else if ( !$user['Enabled'] ) {
|
||||
throw new UnauthorizedException(__('User is not enabled'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->Session->Write('allowedMonitors',$user['MonitorIds']);
|
||||
$this->Session->Write('streamPermission',$user['Stream']);
|
||||
$this->Session->Write('eventPermission',$user['Events']);
|
||||
$this->Session->Write('controlPermission',$user['Control']);
|
||||
$this->Session->Write('systemPermission',$user['System']);
|
||||
$this->Session->Write('monitorPermission',$user['Monitors']);
|
||||
} else {
|
||||
// if auth is not on, you can do everything
|
||||
//$userMonitors = $this->User->find('first', $options);
|
||||
$this->Session->Write('allowedMonitors','');
|
||||
$this->Session->Write('streamPermission','View');
|
||||
$this->Session->Write('eventPermission','Edit');
|
||||
$this->Session->Write('controlPermission','Edit');
|
||||
$this->Session->Write('systemPermission','Edit');
|
||||
$this->Session->Write('monitorPermission','Edit');
|
||||
}
|
||||
|
||||
|
||||
$cred = $this->_getCredentials();
|
||||
$ver = $this->_getVersion();
|
||||
$this->set(array(
|
||||
'credentials' => $cred[0],
|
||||
'append_password'=>$cred[1],
|
||||
'version' => $ver[0],
|
||||
'apiversion' => $ver[1],
|
||||
'_serialize' => array('credentials',
|
||||
'append_password',
|
||||
'version',
|
||||
'apiversion'
|
||||
)));
|
||||
|
||||
}
|
||||
|
||||
// clears out session
|
||||
function logout() {
|
||||
global $user;
|
||||
$this->Session->Write('user', null);
|
||||
|
||||
$this->set(array(
|
||||
'result' => 'ok',
|
||||
'_serialize' => array('result')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
private function _getCredentials() {
|
||||
$credentials = '';
|
||||
$appendPassword = 0;
|
||||
|
||||
$this->loadModel('Config');
|
||||
$isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value'];
|
||||
|
||||
|
@ -52,80 +164,90 @@ class HostController extends AppController {
|
|||
$credentials = 'user='.$this->Session->read('user.Username');
|
||||
}
|
||||
}
|
||||
return array($credentials, $appendPassword);
|
||||
|
||||
}
|
||||
|
||||
function getCredentials() {
|
||||
// ignore debug warnings from other functions
|
||||
$this->view='Json';
|
||||
$val = $this->_getCredentials();
|
||||
$this->set(array(
|
||||
'credentials'=> $credentials,
|
||||
'append_password'=>$appendPassword,
|
||||
'credentials'=> $val[0],
|
||||
'append_password'=>$val[1],
|
||||
'_serialize' => array('credentials', 'append_password')
|
||||
) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If $mid is set, only return disk usage for that monitor
|
||||
// If $mid is set, only return disk usage for that monitor
|
||||
// Else, return an array of total disk usage, and per-monitor
|
||||
// usage.
|
||||
function getDiskPercent($mid = null) {
|
||||
$this->loadModel('Config');
|
||||
$this->loadModel('Monitor');
|
||||
function getDiskPercent($mid = null) {
|
||||
$this->loadModel('Config');
|
||||
$this->loadModel('Monitor');
|
||||
|
||||
// If $mid is passed, see if it is valid
|
||||
if ($mid) {
|
||||
if (!$this->Monitor->exists($mid)) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
}
|
||||
// If $mid is passed, see if it is valid
|
||||
if ($mid) {
|
||||
if (!$this->Monitor->exists($mid)) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
}
|
||||
|
||||
$zm_dir_events = $this->Config->find('list', array(
|
||||
'conditions' => array('Name' => 'ZM_DIR_EVENTS'),
|
||||
'fields' => array('Name', 'Value')
|
||||
));
|
||||
$zm_dir_events = $zm_dir_events['ZM_DIR_EVENTS' ];
|
||||
$zm_dir_events = $this->Config->find('list', array(
|
||||
'conditions' => array('Name' => 'ZM_DIR_EVENTS'),
|
||||
'fields' => array('Name', 'Value')
|
||||
));
|
||||
$zm_dir_events = $zm_dir_events['ZM_DIR_EVENTS' ];
|
||||
|
||||
// Test to see if $zm_dir_events is relative or absolute
|
||||
if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) {
|
||||
// relative - so add the full path
|
||||
$zm_dir_events = Configure::read('ZM_PATH_WEB') . '/' . $zm_dir_events;
|
||||
}
|
||||
// Test to see if $zm_dir_events is relative or absolute
|
||||
if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) {
|
||||
// relative - so add the full path
|
||||
$zm_dir_events = Configure::read('ZM_PATH_WEB') . '/' . $zm_dir_events;
|
||||
}
|
||||
|
||||
if ($mid) {
|
||||
// Get disk usage for $mid
|
||||
$usage = shell_exec ("du -sh0 $zm_dir_events/$mid | awk '{print $1}'");
|
||||
} else {
|
||||
$monitors = $this->Monitor->find('all', array(
|
||||
'fields' => array('Id', 'Name', 'WebColour')
|
||||
));
|
||||
$usage = array();
|
||||
if ($mid) {
|
||||
// Get disk usage for $mid
|
||||
$usage = shell_exec ("du -sh0 $zm_dir_events/$mid | awk '{print $1}'");
|
||||
} else {
|
||||
$monitors = $this->Monitor->find('all', array(
|
||||
'fields' => array('Id', 'Name', 'WebColour')
|
||||
));
|
||||
$usage = array();
|
||||
|
||||
// Add each monitor's usage to array
|
||||
foreach ($monitors as $key => $value) {
|
||||
$id = $value['Monitor']['Id'];
|
||||
$name = $value['Monitor']['Name'];
|
||||
$color = $value['Monitor']['WebColour'];
|
||||
// Add each monitor's usage to array
|
||||
foreach ($monitors as $key => $value) {
|
||||
$id = $value['Monitor']['Id'];
|
||||
$name = $value['Monitor']['Name'];
|
||||
$color = $value['Monitor']['WebColour'];
|
||||
|
||||
$space = shell_exec ("du -s0 $zm_dir_events/$id | awk '{print $1}'");
|
||||
if ($space == null) {
|
||||
$space = 0;
|
||||
}
|
||||
$space = $space/1024/1024;
|
||||
$space = shell_exec ("du -s0 $zm_dir_events/$id | awk '{print $1}'");
|
||||
if ($space == null) {
|
||||
$space = 0;
|
||||
}
|
||||
$space = $space/1024/1024;
|
||||
|
||||
$usage[$name] = array(
|
||||
'space' => rtrim($space),
|
||||
'color' => $color
|
||||
);
|
||||
}
|
||||
$usage[$name] = array(
|
||||
'space' => rtrim($space),
|
||||
'color' => $color
|
||||
);
|
||||
}
|
||||
|
||||
// Add total usage to array
|
||||
$space = shell_exec( "df $zm_dir_events |tail -n1 | awk '{print $3 }'");
|
||||
$space = $space/1024/1024;
|
||||
$usage['Total'] = array(
|
||||
'space' => rtrim($space),
|
||||
'color' => '#F7464A'
|
||||
);
|
||||
}
|
||||
// Add total usage to array
|
||||
$space = shell_exec( "df $zm_dir_events |tail -n1 | awk '{print $3 }'");
|
||||
$space = $space/1024/1024;
|
||||
$usage['Total'] = array(
|
||||
'space' => rtrim($space),
|
||||
'color' => '#F7464A'
|
||||
);
|
||||
}
|
||||
|
||||
$this->set(array(
|
||||
'usage' => $usage,
|
||||
'_serialize' => array('usage')
|
||||
));
|
||||
}
|
||||
$this->set(array(
|
||||
'usage' => $usage,
|
||||
'_serialize' => array('usage')
|
||||
));
|
||||
}
|
||||
|
||||
function getTimeZone() {
|
||||
//http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
|
@ -136,18 +258,18 @@ class HostController extends AppController {
|
|||
));
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
//throw new UnauthorizedException(__('API Disabled'));
|
||||
$version = Configure::read('ZM_VERSION');
|
||||
// not going to use the ZM_API_VERSION
|
||||
// requires recompilation and dependency on ZM upgrade
|
||||
//$apiversion = Configure::read('ZM_API_VERSION');
|
||||
$apiversion = '1.0';
|
||||
private function _getVersion() {
|
||||
$version = Configure::read('ZM_VERSION');
|
||||
$apiversion = '1.0';
|
||||
return array($version, $apiversion);
|
||||
}
|
||||
|
||||
$this->set(array(
|
||||
'version' => $version,
|
||||
'apiversion' => $apiversion,
|
||||
'_serialize' => array('version', 'apiversion')
|
||||
));
|
||||
}
|
||||
function getVersion() {
|
||||
$val = $this->_getVersion();
|
||||
$this->set(array(
|
||||
'version' => $val[0],
|
||||
'apiversion' => $val[1],
|
||||
'_serialize' => array('version', 'apiversion')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,23 +114,23 @@ if ( $action == 'login' && isset($_REQUEST['username']) && ( ZM_AUTH_TYPE == 're
|
|||
// as it produces the same error as when you don't answer a recaptcha
|
||||
if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
|
||||
if (!in_array('invalid-input-secret',$responseData['error-codes'])) {
|
||||
Error ('reCaptcha authentication failed');
|
||||
Error('reCaptcha authentication failed');
|
||||
userLogout();
|
||||
$view='login';
|
||||
$refreshParent = true;
|
||||
return;
|
||||
} else {
|
||||
//Let them login but show an error
|
||||
echo '<script type="text/javascript">alert("'.translate('RecaptchaWarning').'"); </script>';
|
||||
Error ('Invalid recaptcha secret detected');
|
||||
Error('Invalid recaptcha secret detected');
|
||||
}
|
||||
}
|
||||
} // end if success==false
|
||||
|
||||
} // end if using reCaptcha
|
||||
|
||||
$username = validStr( $_REQUEST['username'] );
|
||||
$username = validStr($_REQUEST['username']);
|
||||
$password = isset($_REQUEST['password'])?validStr($_REQUEST['password']):'';
|
||||
userLogin( $username, $password );
|
||||
userLogin($username, $password);
|
||||
$refreshParent = true;
|
||||
$view = 'console';
|
||||
$redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console';
|
||||
|
|
|
@ -61,7 +61,7 @@ function userLogin($username, $password='', $passwordHashed=false) {
|
|||
}
|
||||
if ( $close_session )
|
||||
session_write_close();
|
||||
return $user;
|
||||
return isset($user) ? $user: null;
|
||||
} # end function userLogin
|
||||
|
||||
function userLogout() {
|
||||
|
|
|
@ -55,7 +55,7 @@ require_once( 'includes/Monitor.php' );
|
|||
if (
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
|
||||
or
|
||||
($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
|
||||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
|
||||
) {
|
||||
$protocol = 'https';
|
||||
} else {
|
||||
|
|
|
@ -410,18 +410,20 @@ if ( ZM_OPT_MESSAGE ) {
|
|||
</div>
|
||||
<hr/>
|
||||
<div id="contentButtons">
|
||||
<button onclick="submitToEvents(this);"> <?php echo translate('ListMatches') ?></button>
|
||||
<button onclick="submitToExport(this);"> <?php echo translate('ExportMatches') ?></button>
|
||||
<button name="executeButton" id="executeButton" onclick="executeFilter( this );"><?php echo translate('Execute') ?></button>
|
||||
<button type="button" onclick="submitToEvents(this);"> <?php echo translate('ListMatches') ?></button>
|
||||
<button type="button" onclick="submitToExport(this);"> <?php echo translate('ExportMatches') ?></button>
|
||||
<button type="button" name="executeButton" id="executeButton" onclick="executeFilter( this );"><?php echo translate('Execute') ?></button>
|
||||
<?php
|
||||
if ( canEdit( 'Events' ) ) {
|
||||
?>
|
||||
<button name="Save" value="Save" onclick="saveFilter(this);"><?php echo translate('Save') ?></button>
|
||||
<button name="SaveAs" value="SaveAs" onclick="saveFilter(this);"><?php echo translate('SaveAs') ?></button>
|
||||
<button type="button" name="Save" value="Save" onclick="saveFilter(this);"><?php echo translate('Save') ?></button>
|
||||
<button type="button" name="SaveAs" value="SaveAs" onclick="saveFilter(this);"><?php echo translate('SaveAs') ?></button>
|
||||
<?php
|
||||
if ( $filter->Id() ) {
|
||||
?>
|
||||
<input type="button" value="<?php echo translate('Delete') ?>" onclick="deleteFilter( this, '<?php echo $filter->Name() ?>' );"/>
|
||||
<button type="button" value="Delete " onclick="deleteFilter( this, '<?php echo $filter->Name() ?>' );">
|
||||
<?php echo translate('Delete') ?>
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ function submitToEvents( element ) {
|
|||
|
||||
function submitToExport(element) {
|
||||
var form = element.form;
|
||||
createPopup('?view=export&filter='+$j(form).serialize(), 'zmExport', 'export' );
|
||||
window.location.assign('?view=export&filter='+$j(form).serialize());
|
||||
//createPopup('?view=export&filter_id='+form.elements['Id'].value, 'zmExport', 'export' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue