Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas
This commit is contained in:
commit
3962c52288
|
@ -1,6 +1,6 @@
|
|||
You should only file an issue if you found a bug. Feature and enhancement requests, general discussions and support questions should occur in one of the following areas:
|
||||
|
||||
- The ZoneMinder IRC channel - irc.freenode.net #zoneminder
|
||||
- The [ZoneMinder-Chat Slack channel](https://zoneminder-chat.herokuapp.com/)
|
||||
- The [ZoneMinder Forum](https://forums.zoneminder.com/)
|
||||
|
||||
**Do not post feature or enhancement requests, general discussions or support questions here.**
|
||||
|
|
|
@ -3,6 +3,8 @@ ZoneMinder
|
|||
|
||||
[![Build Status](https://travis-ci.org/ZoneMinder/zoneminder.png)](https://travis-ci.org/ZoneMinder/zoneminder) [![Bountysource](https://api.bountysource.com/badge/team?team_id=204&style=bounties_received)](https://www.bountysource.com/teams/zoneminder/issues?utm_source=ZoneMinder&utm_medium=shield&utm_campaign=bounties_received)
|
||||
|
||||
[![Join Slack](https://github.com/ozonesecurity/ozonebase/blob/master/img/slacksm.png?raw=true)](https://zoneminder-chat.herokuapp.com)
|
||||
|
||||
All documentation for ZoneMinder is now online at https://zoneminder.readthedocs.org
|
||||
|
||||
## Overview
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%global _hardened_build 1
|
||||
|
||||
Name: zoneminder
|
||||
Version: 1.31.44
|
||||
Version: 1.31.45
|
||||
Release: 1%{?dist}
|
||||
Summary: A camera monitoring and analysis tool
|
||||
Group: System Environment/Daemons
|
||||
|
|
|
@ -98,6 +98,11 @@ use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)
|
|||
|
||||
logInit($filter_id?(id=>'zmfilter_'.$filter_id):());
|
||||
sub HupHandler {
|
||||
# This idea at this time is to just exit, freeing up the memory.
|
||||
# zmfilter.pl will be respawned by zmdc.
|
||||
TermHandler();
|
||||
return;
|
||||
|
||||
Info('Received HUP, reloading');
|
||||
ZoneMinder::Object::init_cache();
|
||||
&ZoneMinder::Logger::logHupHandler();
|
||||
|
|
|
@ -33,6 +33,7 @@ use LWP::UserAgent;
|
|||
use Sys::MemInfo qw(totalmem);
|
||||
use Sys::CPU qw(cpu_count);
|
||||
use POSIX qw(strftime uname);
|
||||
use JSON::MaybeXS;
|
||||
|
||||
$ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
|
||||
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
|
||||
|
@ -87,7 +88,7 @@ while( 1 ) {
|
|||
# We should keep *BSD systems in mind when calling system commands
|
||||
my %telemetry;
|
||||
$telemetry{uuid} = getUUID($dbh);
|
||||
$telemetry{ip} = getIP();
|
||||
($telemetry{city}, $telemetry{region}, $telemetry{country}, $telemetry{latitude}, $telemetry{longitude}) = getGeo();
|
||||
$telemetry{timestamp} = strftime( '%Y-%m-%dT%H:%M:%S%z', localtime() );
|
||||
$telemetry{monitor_count} = countQuery($dbh,'Monitors');
|
||||
$telemetry{event_count} = countQuery($dbh,'Events');
|
||||
|
@ -203,22 +204,25 @@ sub getUUID {
|
|||
return $uuid;
|
||||
}
|
||||
|
||||
# Retrieves the local server's external IP address
|
||||
sub getIP {
|
||||
my $ipaddr = '0.0.0.0';
|
||||
# Retrieve this server's general location information from a GeoIP database
|
||||
sub getGeo {
|
||||
my $unknown = 'Unknown';
|
||||
my $endpoint = 'https://ipinfo.io/geo';
|
||||
my $ua = LWP::UserAgent->new;
|
||||
my $server_endpoint = 'https://wiki.zoneminder.com/ip.php';
|
||||
|
||||
my $req = HTTP::Request->new(GET => $server_endpoint);
|
||||
my $req = HTTP::Request->new(GET => $endpoint);
|
||||
my $resp = $ua->request($req);
|
||||
my $resp_msg = $resp->decoded_content;
|
||||
my $resp_code = $resp->code;
|
||||
|
||||
if ($resp->is_success) {
|
||||
$ipaddr = $resp->decoded_content;
|
||||
my $content = decode_json( $resp_msg );
|
||||
(my $latitude, my $longitude) = split /,/, $content->{loc};
|
||||
return ($content->{city}, $content->{region}, $content->{country}, $latitude, $longitude);
|
||||
} else {
|
||||
Warning("Geoip data retrieval returned HTTP POST error code: $resp_code");
|
||||
Debug("Geoip data retrieval failure response message: $resp_msg");
|
||||
return ($unknown, $unknown, $unknown, $unknown);
|
||||
}
|
||||
|
||||
Debug("Found external ip address of: $ipaddr");
|
||||
|
||||
return $ipaddr;
|
||||
}
|
||||
|
||||
# As the name implies, just your average mysql count query
|
||||
|
|
|
@ -594,11 +594,12 @@ Debug(3, "Writing video");
|
|||
max_score = score;
|
||||
|
||||
if ( alarm_image ) {
|
||||
snprintf(event_file, sizeof(event_file), staticConfig.analyse_file_format, path, frames);
|
||||
|
||||
Debug(1, "Writing analysis frame %d", frames);
|
||||
if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
WriteFrameImage(alarm_image, timestamp, event_file, true);
|
||||
snprintf(event_file, sizeof(event_file), staticConfig.analyse_file_format, path, frames);
|
||||
Debug(1, "Writing analysis frame %d", frames);
|
||||
if ( ! WriteFrameImage(alarm_image, timestamp, event_file, true) ) {
|
||||
Error("Failed to write analysis frame image");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -60,30 +60,47 @@ class AppController extends Controller {
|
|||
// 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 ( ! ZM_OPT_USE_API ) {
|
||||
throw new UnauthorizedException(__('API Disabled'));
|
||||
return;
|
||||
}
|
||||
|
||||
# For use throughout the app. If not logged in, this will be null.
|
||||
global $user;
|
||||
$user = $this->Session->read('user');
|
||||
|
||||
if ( ZM_OPT_USE_AUTH ) {
|
||||
require_once '../../../includes/auth.php';
|
||||
|
||||
$mUser = $this->request->query('user') ? $this->request->query('user') : $this->request->data('user');
|
||||
$mPassword = $this->request->query('pass') ? $this->request->query('pass') : $this->request->data('pass');
|
||||
$mAuth = $this->request->query('auth') ? $this->request->query('auth') : $this->request->data('auth');
|
||||
|
||||
if ( $mUser and $mPassword ) {
|
||||
$user = userLogin($mUser, $mPassword);
|
||||
if ( !$user ) {
|
||||
throw new UnauthorizedException(__('User not found or incorrect password'));
|
||||
return;
|
||||
}
|
||||
} else if ( $mAuth ) {
|
||||
$user = getAuthUser($mAuth);
|
||||
if ( !$user ) {
|
||||
throw new UnauthorizedException(__('Invalid Auth Key'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We need to reject methods that are not authenticated
|
||||
// besides login and logout
|
||||
if (
|
||||
strcasecmp($this->params->action, 'login')
|
||||
&&
|
||||
strcasecmp($this->params->action,"logout")
|
||||
) {
|
||||
if ( !$this->Session->read('user.Username') ) {
|
||||
if ( strcasecmp($this->params->action, 'logout') ) {
|
||||
if ( !( $user and $user['Username'] ) ) {
|
||||
throw new UnauthorizedException(__('Not Authenticated'));
|
||||
return;
|
||||
} else if ( !$this->Session->read('user.Enabled') ) {
|
||||
} else if ( !( $user and $user['Enabled'] ) ) {
|
||||
throw new UnauthorizedException(__('User is not enabled'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} # end if ! login or logout
|
||||
} # end if ZM_OPT_AUTH
|
||||
|
||||
} # end function beforeFilter()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
App::uses('AppController', 'Controller');
|
||||
|
||||
/**
|
||||
* Events Controller
|
||||
*
|
||||
|
@ -16,8 +17,9 @@ class EventsController extends AppController {
|
|||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$canView = $this->Session->Read('eventPermission');
|
||||
if ( $canView == 'None' ) {
|
||||
global $user;
|
||||
$canView = (!$user) || ($user['Events'] != 'None');
|
||||
if ( !$canView ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -32,9 +34,10 @@ class EventsController extends AppController {
|
|||
public function index() {
|
||||
$this->Event->recursive = -1;
|
||||
|
||||
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
|
||||
if ( !empty($allowedMonitors) ) {
|
||||
if ( $allowedMonitors ) {
|
||||
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
||||
} else {
|
||||
$mon_options = '';
|
||||
|
@ -91,7 +94,7 @@ class EventsController extends AppController {
|
|||
}
|
||||
|
||||
$this->set(compact('events'));
|
||||
}
|
||||
} // end public function index()
|
||||
|
||||
/**
|
||||
* view method
|
||||
|
@ -108,9 +111,10 @@ class EventsController extends AppController {
|
|||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
||||
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
|
||||
if ( !empty($allowedMonitors) ) {
|
||||
if ( $allowedMonitors ) {
|
||||
$mon_options = array('Event.MonitorId' => $allowedMonitors);
|
||||
} else {
|
||||
$mon_options = '';
|
||||
|
@ -149,7 +153,9 @@ class EventsController extends AppController {
|
|||
*/
|
||||
public function add() {
|
||||
|
||||
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['Events'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -173,7 +179,9 @@ class EventsController extends AppController {
|
|||
*/
|
||||
public function edit($id = null) {
|
||||
|
||||
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['Events'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -204,7 +212,9 @@ class EventsController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
if ( $this->Session->Read('eventPermission') != 'Edit' ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['Events'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -259,7 +269,7 @@ class EventsController extends AppController {
|
|||
$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;");
|
||||
|
||||
foreach ($query as $result) {
|
||||
$results[$result['Events']['MonitorId']] = $result[0]['Count'];
|
||||
|
@ -336,7 +346,7 @@ class EventsController extends AppController {
|
|||
$thumbData['Width'] = (int)$thumbWidth;
|
||||
$thumbData['Height'] = (int)$thumbHeight;
|
||||
|
||||
return( $thumbData );
|
||||
return $thumbData;
|
||||
}
|
||||
|
||||
public function archive($id = null) {
|
||||
|
|
|
@ -30,94 +30,8 @@ class HostController extends AppController {
|
|||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
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(
|
||||
|
@ -130,8 +44,7 @@ class HostController extends AppController {
|
|||
'version',
|
||||
'apiversion'
|
||||
)));
|
||||
|
||||
}
|
||||
} // end function login()
|
||||
|
||||
// clears out session
|
||||
function logout() {
|
||||
|
@ -143,7 +56,7 @@ class HostController extends AppController {
|
|||
'_serialize' => array('result')
|
||||
));
|
||||
|
||||
}
|
||||
} // end function logout()
|
||||
|
||||
private function _getCredentials() {
|
||||
$credentials = '';
|
||||
|
@ -167,8 +80,7 @@ class HostController extends AppController {
|
|||
}
|
||||
}
|
||||
return array($credentials, $appendPassword);
|
||||
|
||||
}
|
||||
} // end function _getCredentials
|
||||
|
||||
function getCredentials() {
|
||||
// ignore debug warnings from other functions
|
||||
|
@ -181,8 +93,6 @@ class HostController extends AppController {
|
|||
) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If $mid is set, only return disk usage for that monitor
|
||||
// Else, return an array of total disk usage, and per-monitor
|
||||
// usage.
|
||||
|
|
|
@ -21,8 +21,10 @@ class MonitorsController extends AppController {
|
|||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$canView = $this->Session->Read('monitorPermission');
|
||||
if ($canView == 'None') {
|
||||
global $user;
|
||||
# We already tested for auth in appController, so we just need to test for specific permission
|
||||
$canView = (!$user) || ($user['Monitors'] != 'None');
|
||||
if ( !$canView ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -44,8 +46,9 @@ class MonitorsController extends AppController {
|
|||
$conditions = array();
|
||||
}
|
||||
|
||||
$allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($allowedMonitors)) {
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
if ( $allowedMonitors ) {
|
||||
$conditions['Monitor.Id' ] = $allowedMonitors;
|
||||
}
|
||||
$find_array = array('conditions'=>$conditions,'contain'=>array('Group'));
|
||||
|
@ -88,8 +91,9 @@ class MonitorsController extends AppController {
|
|||
if ( !$this->Monitor->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
$allowedMonitors=preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||
if ( !empty($allowedMonitors) ) {
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
if ( $allowedMonitors ) {
|
||||
$restricted = array('Monitor.' . $this->Monitor->primaryKey => $allowedMonitors);
|
||||
} else {
|
||||
$restricted = '';
|
||||
|
@ -115,7 +119,9 @@ class MonitorsController extends AppController {
|
|||
public function add() {
|
||||
if ( $this->request->is('post') ) {
|
||||
|
||||
if ( $this->Session->Read('systemPermission') != 'Edit' ) {
|
||||
global $user;
|
||||
$canAdd = (!$user) || ($user['System'] == 'Edit' );
|
||||
if ( !$canAdd ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -148,7 +154,9 @@ class MonitorsController extends AppController {
|
|||
if ( !$this->Monitor->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
if ( $this->Session->Read('monitorPermission') != 'Edit' ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['Monitors'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -215,7 +223,7 @@ class MonitorsController extends AppController {
|
|||
}
|
||||
|
||||
public function sourceTypes() {
|
||||
$sourceTypes = $this->Monitor->query("describe Monitors Type;");
|
||||
$sourceTypes = $this->Monitor->query('describe Monitors Type;');
|
||||
|
||||
preg_match('/^enum\((.*)\)$/', $sourceTypes[0]['COLUMNS']['Type'], $matches);
|
||||
foreach( explode(',', $matches[1]) as $value ) {
|
||||
|
@ -264,7 +272,6 @@ class MonitorsController extends AppController {
|
|||
$config = $this->Config->find('first', $options);
|
||||
$zmOptAuth = $config['Config']['Value'];
|
||||
|
||||
|
||||
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY'));
|
||||
$config = $this->Config->find('first', $options);
|
||||
$zmAuthRelay = $config['Config']['Value'];
|
||||
|
@ -372,5 +379,4 @@ class MonitorsController extends AppController {
|
|||
$status = exec( $shellcmd );
|
||||
}
|
||||
}
|
||||
|
||||
} // end class MonitorsController
|
||||
|
|
|
@ -8,7 +8,6 @@ App::uses('AppController', 'Controller');
|
|||
*/
|
||||
class ServersController extends AppController {
|
||||
|
||||
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
|
@ -16,18 +15,16 @@ class ServersController extends AppController {
|
|||
*/
|
||||
public $components = array('Paginator', 'RequestHandler');
|
||||
|
||||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$canView = $this->Session->Read('streamPermission');
|
||||
if ($canView =='None') {
|
||||
global $user;
|
||||
$canView = (!$user) || ($user['System'] != 'None');
|
||||
if ( !$canView ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
|
@ -78,8 +75,9 @@ public function beforeFilter() {
|
|||
public function add() {
|
||||
if ( $this->request->is('post') ) {
|
||||
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -103,14 +101,16 @@ public function beforeFilter() {
|
|||
public function edit($id = null) {
|
||||
$this->Server->id = $id;
|
||||
|
||||
if (!$this->Server->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid server'));
|
||||
}
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !$this->Server->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid server'));
|
||||
}
|
||||
if ( $this->Server->save($this->request->data) ) {
|
||||
$message = 'Saved';
|
||||
} else {
|
||||
|
@ -133,15 +133,17 @@ public function beforeFilter() {
|
|||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->Server->id = $id;
|
||||
if ( !$this->Server->exists() ) {
|
||||
throw new NotFoundException(__('Invalid server'));
|
||||
}
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
|
||||
#$this->daemonControl($this->Server->id, 'stop');
|
||||
|
|
|
@ -13,16 +13,14 @@ public $components = array('RequestHandler');
|
|||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$canView = $this->Session->Read('systemPermission');
|
||||
if ($canView =='None')
|
||||
{
|
||||
global $user;
|
||||
$canView = (!$user) || ($user['System'] != 'None');
|
||||
if ( !$canView ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
|
@ -86,8 +84,9 @@ public function beforeFilter() {
|
|||
throw new NotFoundException(__('Invalid state'));
|
||||
}
|
||||
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -111,8 +110,9 @@ public function beforeFilter() {
|
|||
*/
|
||||
public function delete($id = null) {
|
||||
$this->State->id = $id;
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -129,8 +129,9 @@ public function beforeFilter() {
|
|||
}
|
||||
|
||||
public function change() {
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@ class ZonesController extends AppController {
|
|||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$canView = $this->Session->Read('monitorPermission');
|
||||
if ( $canView =='None' ) {
|
||||
|
||||
global $user;
|
||||
$canView = (!$user) || $user['Monitors'] != 'None';
|
||||
if ( !$canView ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
@ -38,12 +40,12 @@ class ZonesController extends AppController {
|
|||
'_serialize' => array('zones')
|
||||
));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->Zone->recursive = -1;
|
||||
|
||||
$allowedMonitors = preg_split('@,@', $this->Session->Read('allowedMonitors'), NULL, PREG_SPLIT_NO_EMPTY);
|
||||
if ( !empty($allowedMonitors) ) {
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'],NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
if ( $allowedMonitors ) {
|
||||
$mon_options = array('Zones.MonitorId' => $allowedMonitors);
|
||||
} else {
|
||||
$mon_options = '';
|
||||
|
@ -62,6 +64,14 @@ class ZonesController extends AppController {
|
|||
*/
|
||||
public function add() {
|
||||
if ( $this->request->is('post') ) {
|
||||
|
||||
global $user;
|
||||
$canEdit = (!$user) || $user['Monitors'] == 'Edit';
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->Zone->create();
|
||||
if ( $this->Zone->save($this->request->data) ) {
|
||||
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
||||
|
@ -85,6 +95,12 @@ class ZonesController extends AppController {
|
|||
throw new NotFoundException(__('Invalid zone'));
|
||||
}
|
||||
if ( $this->request->is(array('post', 'put')) ) {
|
||||
global $user;
|
||||
$canEdit = (!$user) || $user['Monitors'] == 'Edit';
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
if ( $this->Zone->save($this->request->data) ) {
|
||||
return $this->flash(__('The zone has been saved.'), array('action' => 'index'));
|
||||
}
|
||||
|
@ -109,6 +125,12 @@ class ZonesController extends AppController {
|
|||
throw new NotFoundException(__('Invalid zone'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
global $user;
|
||||
$canEdit = (!$user) || $user['Monitors'] == 'Edit';
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient Privileges'));
|
||||
return;
|
||||
}
|
||||
if ( $this->Zone->delete() ) {
|
||||
return $this->flash(__('The zone has been deleted.'), array('action' => 'index'));
|
||||
} else {
|
||||
|
@ -144,4 +166,4 @@ class ZonesController extends AppController {
|
|||
'_serialize' => array('status')
|
||||
));
|
||||
}
|
||||
}
|
||||
} // end class
|
||||
|
|
|
@ -436,16 +436,34 @@ function htmlSelect( $name, $contents, $values, $behaviours=false ) {
|
|||
}
|
||||
|
||||
function htmlOptions($contents, $values) {
|
||||
$html = '';
|
||||
foreach ( $contents as $value=>$text ) {
|
||||
if ( is_array( $text ) )
|
||||
$text = $text['Name'];
|
||||
else if ( is_object( $text ) )
|
||||
$text = $text->Name();
|
||||
$selected = is_array( $values ) ? in_array( $value, $values ) : !strcmp($value, $values);
|
||||
$html .= "<option value=\"$value\"".($selected?" selected=\"selected\"":'').">$text</option>";
|
||||
$options_html = '';
|
||||
|
||||
foreach ( $contents as $value=>$option ) {
|
||||
$disabled = 0;
|
||||
$text = '';
|
||||
if ( is_array($option) ) {
|
||||
|
||||
if ( isset($option['Name']) )
|
||||
$text = $option['Name'];
|
||||
else if ( isset($option['text']) )
|
||||
$text = $option['text'];
|
||||
|
||||
if ( isset($option['disabled']) ) {
|
||||
$disabled = $option['disabled'];
|
||||
Error("Setting to disabled");
|
||||
}
|
||||
return $html;
|
||||
} else if ( is_object($option) ) {
|
||||
$text = $option->Name();
|
||||
} else {
|
||||
$text = $option;
|
||||
}
|
||||
$selected = is_array($values) ? in_array($value, $values) : !strcmp($value, $values);
|
||||
$options_html .= "<option value=\"$value\"".
|
||||
($selected?' selected="selected"':'').
|
||||
($disabled?' disabled="disabled"':'').
|
||||
">$text</option>";
|
||||
}
|
||||
return $options_html;
|
||||
}
|
||||
|
||||
function truncText( $text, $length, $deslash=1 ) {
|
||||
|
|
|
@ -410,25 +410,23 @@ if ( ZM_OPT_MESSAGE ) {
|
|||
</div>
|
||||
<hr/>
|
||||
<div id="contentButtons">
|
||||
<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>
|
||||
<button type="submit" onclick="submitToEvents(this);"><?php echo translate('ListMatches') ?></button>
|
||||
<button type="submit" onclick="submitToExport(this);"><?php echo translate('ExportMatches') ?></button>
|
||||
<button type="submit" name="executeButton" id="executeButton" onclick="executeFilter( this );"><?php echo translate('Execute') ?></button>
|
||||
<?php
|
||||
if ( canEdit('Events') ) {
|
||||
?>
|
||||
<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>
|
||||
<button type="submit" name="Save" value="Save" onclick="saveFilter(this);"><?php echo translate('Save') ?></button>
|
||||
<button type="submit" name="SaveAs" value="SaveAs" onclick="saveFilter(this);"><?php echo translate('SaveAs') ?></button>
|
||||
<?php
|
||||
if ( $filter->Id() ) {
|
||||
?>
|
||||
<button type="button" value="Delete " onclick="deleteFilter( this, '<?php echo $filter->Name() ?>' );">
|
||||
<?php echo translate('Delete') ?>
|
||||
</button>
|
||||
<button type="button" value="Delete" onclick="deleteFilter(this, '<?php echo $filter->Name() ?>');"><?php echo translate('Delete') ?></button>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<button value="<?php echo translate('Reset') ?>" onclick="resetFilter( this );"><?php echo translate('Reset') ?></button>
|
||||
<button type="button" value="Reset" onclick="resetFilter( this );"><?php echo translate('Reset') ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div><!--content-->
|
||||
|
|
|
@ -925,6 +925,8 @@ if ( $monitor->Type() == 'Local' ) {
|
|||
);
|
||||
if ($monitor->Type() == 'Ffmpeg' )
|
||||
$videowriteropts[2] = 'H264 Camera Passthrough';
|
||||
else
|
||||
$videowriteropts[2] = array('text'=>'H264 Camera Passthrough - only for FFMPEG','disabled'=>1);
|
||||
echo htmlselect( 'newMonitor[VideoWriter]', $videowriteropts, $monitor->VideoWriter() );
|
||||
?>
|
||||
</td></tr>
|
||||
|
|
Loading…
Reference in New Issue