Merge branch 'master' of github.com:zoneminder/ZoneMinder
commit
689956bba7
|
@ -0,0 +1,12 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: [connortechnology,pliablepixels] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: zoneminder # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@ -1,9 +1,10 @@
|
|||
ZoneMinder
|
||||
==========
|
||||
|
||||
[![Build Status](https://travis-ci.org/ZoneMinder/zoneminder.png)](https://travis-ci.org/ZoneMinder/zoneminder) [![Bountysource](https://api.bountysource.com/badge/team?team_id=204&style=bounties_received)](https://www.bountysource.com/teams/zoneminder/issues?utm_source=ZoneMinder&utm_medium=shield&utm_campaign=bounties_received)
|
||||
|
||||
[![Build Status](https://travis-ci.org/ZoneMinder/zoneminder.png)](https://travis-ci.org/ZoneMinder/zoneminder)
|
||||
[![Bounty Source](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://join.slack.com/t/zoneminder-chat/shared_invite/enQtNTU0NDkxMDM5NDQwLTdhZmQ5Y2M2NWQyN2JkYTBiN2ZkMzIzZGQ0MDliMTRmM2FjZWRlYzUwYTQ2MjMwMTVjMzQ1NjYxOTdmMjE2MTE)
|
||||
[![IRC Network](https://img.shields.io/badge/irc-%23zoneminder-blue.svg "IRC Freenode")](https://webchat.freenode.net/?channels=zoneminder)
|
||||
|
||||
All documentation for ZoneMinder is now online at https://zoneminder.readthedocs.org
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
%global _hardened_build 1
|
||||
|
||||
Name: zoneminder
|
||||
Version: 1.33.14
|
||||
Version: 1.33.15
|
||||
Release: 1%{?dist}
|
||||
Summary: A camera monitoring and analysis tool
|
||||
Group: System Environment/Daemons
|
||||
|
@ -411,6 +411,9 @@ EOF
|
|||
%dir %attr(755,nginx,nginx) %{_localstatedir}/spool/zoneminder-upload
|
||||
|
||||
%changelog
|
||||
* Sun Dec 08 2019 Isaac Connor <isaac@zoneminder.com> - 1.33.15-1
|
||||
- Bump to 1.33.15 Development
|
||||
|
||||
* Sun Aug 11 2019 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.33.14-1
|
||||
- Bump to 1.33.13 Development
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ $statusData = array(
|
|||
'MinEventId' => array( 'sql' => '(SELECT min(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
|
||||
'MaxEventId' => array( 'sql' => '(SELECT max(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
|
||||
'TotalEvents' => array( 'sql' => '(SELECT count(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
|
||||
'Status' => array( 'zmu' => '-m '.escapeshellarg($_REQUEST['id'][0]).' -s' ),
|
||||
'FrameRate' => array( 'zmu' => '-m '.escapeshellarg($_REQUEST['id'][0]).' -f' ),
|
||||
'Status' => (isset($_REQUEST['id'])?array( 'zmu' => '-m '.escapeshellarg($_REQUEST['id'][0]).' -s' ):null),
|
||||
'FrameRate' => (isset($_REQUEST['id'])?array( 'zmu' => '-m '.escapeshellarg($_REQUEST['id'][0]).' -f' ):null),
|
||||
),
|
||||
),
|
||||
'events' => array(
|
||||
|
@ -204,6 +204,7 @@ function collectData() {
|
|||
$fieldSql = array();
|
||||
$joinSql = array();
|
||||
$groupSql = array();
|
||||
$values = array();
|
||||
|
||||
$elements = &$entitySpec['elements'];
|
||||
$lc_elements = array_change_key_case( $elements );
|
||||
|
@ -258,7 +259,6 @@ function collectData() {
|
|||
if ( $id && !empty($entitySpec['selector']) ) {
|
||||
$index = 0;
|
||||
$where = array();
|
||||
$values = array();
|
||||
foreach( $entitySpec['selector'] as $selIndex => $selector ) {
|
||||
$selectorParamName = ':selector' . $selIndex;
|
||||
if ( is_array( $selector ) ) {
|
||||
|
|
|
@ -51,10 +51,10 @@ class Event extends ZM_Object {
|
|||
if ( $new ) {
|
||||
$this->{'Storage'} = $new;
|
||||
}
|
||||
if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) ) {
|
||||
if ( ! ( property_exists($this, 'Storage') and $this->{'Storage'} ) ) {
|
||||
if ( isset($this->{'StorageId'}) and $this->{'StorageId'} )
|
||||
$this->{'Storage'} = Storage::find_one(array('Id'=>$this->{'StorageId'}));
|
||||
if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) )
|
||||
if ( ! ( property_exists($this, 'Storage') and $this->{'Storage'} ) )
|
||||
$this->{'Storage'} = new Storage(NULL);
|
||||
}
|
||||
return $this->{'Storage'};
|
||||
|
@ -64,10 +64,10 @@ class Event extends ZM_Object {
|
|||
if ( $new ) {
|
||||
$this->{'SecondaryStorage'} = $new;
|
||||
}
|
||||
if ( ! ( array_key_exists('SecondaryStorage', $this) and $this->{'SecondaryStorage'} ) ) {
|
||||
if ( ! ( property_exists($this, 'SecondaryStorage') and $this->{'SecondaryStorage'} ) ) {
|
||||
if ( isset($this->{'SecondaryStorageId'}) and $this->{'SecondaryStorageId'} )
|
||||
$this->{'SecondaryStorage'} = Storage::find_one(array('Id'=>$this->{'SecondaryStorageId'}));
|
||||
if ( ! ( array_key_exists('SecondaryStorage', $this) and $this->{'SecondaryStorage'} ) )
|
||||
if ( ! ( property_exists($this, 'SecondaryStorage') and $this->{'SecondaryStorage'} ) )
|
||||
$this->{'SecondaryStorage'} = new Storage(NULL);
|
||||
}
|
||||
return $this->{'SecondaryStorage'};
|
||||
|
@ -262,7 +262,7 @@ class Event extends ZM_Object {
|
|||
if ( is_null($new) or ( $new != '' ) ) {
|
||||
$this->{'DiskSpace'} = $new;
|
||||
}
|
||||
if ( (!array_key_exists('DiskSpace',$this)) or (null === $this->{'DiskSpace'}) ) {
|
||||
if ( (!property_exists($this, 'DiskSpace')) or (null === $this->{'DiskSpace'}) ) {
|
||||
$this->{'DiskSpace'} = folder_size($this->Path());
|
||||
dbQuery('UPDATE Events SET DiskSpace=? WHERE Id=?', array($this->{'DiskSpace'}, $this->{'Id'}));
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ class Event extends ZM_Object {
|
|||
} // end function createListThumbnail
|
||||
|
||||
function ThumbnailWidth( ) {
|
||||
if ( ! ( array_key_exists('ThumbnailWidth', $this) ) ) {
|
||||
if ( ! ( property_exists($this, 'ThumbnailWidth') ) ) {
|
||||
if ( ZM_WEB_LIST_THUMB_WIDTH ) {
|
||||
$this->{'ThumbnailWidth'} = ZM_WEB_LIST_THUMB_WIDTH;
|
||||
$scale = (SCALE_BASE*ZM_WEB_LIST_THUMB_WIDTH)/$this->{'Width'};
|
||||
|
@ -315,7 +315,7 @@ class Event extends ZM_Object {
|
|||
} // end function ThumbnailWidth
|
||||
|
||||
function ThumbnailHeight( ) {
|
||||
if ( ! ( array_key_exists('ThumbnailHeight', $this) ) ) {
|
||||
if ( ! ( property_exists($this, 'ThumbnailHeight') ) ) {
|
||||
if ( ZM_WEB_LIST_THUMB_WIDTH ) {
|
||||
$this->{'ThumbnailWidth'} = ZM_WEB_LIST_THUMB_WIDTH;
|
||||
$scale = (SCALE_BASE*ZM_WEB_LIST_THUMB_WIDTH)/$this->{'Width'};
|
||||
|
|
|
@ -39,8 +39,8 @@ class Filter extends ZM_Object {
|
|||
$this->{'Query'} = func_get_arg(0);;
|
||||
$this->{'Query_json'} = jsonEncode($this->{'Query'});
|
||||
}
|
||||
if ( !array_key_exists('Query', $this) ) {
|
||||
if ( array_key_exists('Query_json', $this) and $this->{'Query_json'} ) {
|
||||
if ( !property_exists($this, 'Query') ) {
|
||||
if ( property_exists($this, 'Query_json') and $this->{'Query_json'} ) {
|
||||
$this->{'Query'} = jsonDecode($this->{'Query_json'});
|
||||
} else {
|
||||
$this->{'Query'} = array();
|
||||
|
|
|
@ -18,7 +18,7 @@ class Group extends ZM_Object {
|
|||
}
|
||||
|
||||
public function delete() {
|
||||
if ( array_key_exists('Id', $this) ) {
|
||||
if ( property_exists($this, 'Id') ) {
|
||||
dbQuery('DELETE FROM Groups_Monitors WHERE GroupId=?', array($this->{'Id'}));
|
||||
dbQuery('UPDATE Groups SET ParentId=NULL WHERE ParentId=?', array($this->{'Id'}));
|
||||
dbQuery('DELETE FROM Groups WHERE Id=?', array($this->{'Id'}));
|
||||
|
@ -35,7 +35,7 @@ class Group extends ZM_Object {
|
|||
if ( isset($new) ) {
|
||||
$this->{'depth'} = $new;
|
||||
}
|
||||
if ( !array_key_exists('depth', $this) or ($this->{'depth'} === null) ) {
|
||||
if ( !property_exists($this, 'depth') or ($this->{'depth'} === null) ) {
|
||||
$this->{'depth'} = 0;
|
||||
if ( $this->{'ParentId'} != null ) {
|
||||
$Parent = Group::find_one(array('Id'=>$this->{'ParentId'}));
|
||||
|
@ -46,7 +46,7 @@ class Group extends ZM_Object {
|
|||
} // end public function depth
|
||||
|
||||
public function MonitorIds( ) {
|
||||
if ( ! array_key_exists('MonitorIds', $this) ) {
|
||||
if ( ! property_exists($this, 'MonitorIds') ) {
|
||||
$this->{'MonitorIds'} = dbFetchAll('SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($this->{'Id'}));
|
||||
}
|
||||
return $this->{'MonitorIds'};
|
||||
|
|
|
@ -116,11 +116,11 @@ private $status_fields = array(
|
|||
);
|
||||
|
||||
public function Control() {
|
||||
if ( !array_key_exists('Control', $this) ) {
|
||||
if ( !property_exists($this, 'Control') ) {
|
||||
if ( $this->ControlId() )
|
||||
$this->{'Control'} = Control::find_one(array('Id'=>$this->{'ControlId'}));
|
||||
|
||||
if ( !(array_key_exists('Control', $this) and $this->{'Control'}) )
|
||||
if ( !(property_exists($this, 'Control') and $this->{'Control'}) )
|
||||
$this->{'Control'} = new Control();
|
||||
}
|
||||
return $this->{'Control'};
|
||||
|
@ -138,7 +138,7 @@ private $status_fields = array(
|
|||
$this->{$fn} = $args[0];
|
||||
}
|
||||
}
|
||||
if ( array_key_exists($fn, $this) ) {
|
||||
if ( property_exists($this, $fn) ) {
|
||||
return $this->{$fn};
|
||||
} else if ( array_key_exists($fn, $this->defaults) ) {
|
||||
if ( is_array($this->defaults[$fn]) ) {
|
||||
|
@ -211,9 +211,9 @@ private $status_fields = array(
|
|||
$this->{'Width'} = $new;
|
||||
|
||||
$field = ( $this->Orientation() == 'ROTATE_90' or $this->Orientation() == 'ROTATE_270' ) ? 'Height' : 'Width';
|
||||
if ( array_key_exists($field, $this) )
|
||||
if ( property_exists($this, $field) )
|
||||
return $this->{$field};
|
||||
return $this->defaults{$field};
|
||||
return $this->defaults[$field];
|
||||
} // end function Width
|
||||
|
||||
public function ViewHeight($new=null) {
|
||||
|
@ -221,9 +221,9 @@ private $status_fields = array(
|
|||
$this->{'Height'} = $new;
|
||||
|
||||
$field = ( $this->Orientation() == 'ROTATE_90' or $this->Orientation() == 'ROTATE_270' ) ? 'Width' : 'Height';
|
||||
if ( array_key_exists($field, $this) )
|
||||
if ( property_exists($this, $field) )
|
||||
return $this->{$field};
|
||||
return $this->defaults{$field};
|
||||
return $this->defaults[$field];
|
||||
} // end function Height
|
||||
|
||||
public function SignalCheckColour($new=null) {
|
||||
|
@ -234,10 +234,10 @@ private $status_fields = array(
|
|||
|
||||
// Validate that it's a valid colour (we seem to allow color names, not just hex).
|
||||
// This also helps prevent XSS.
|
||||
if (array_key_exists($field, $this) && preg_match('/^[#0-9a-zA-Z]+$/', $this->{$field})) {
|
||||
if ( property_exists($this, $field) && preg_match('/^[#0-9a-zA-Z]+$/', $this->{$field})) {
|
||||
return $this->{$field};
|
||||
}
|
||||
return $this->defaults{$field};
|
||||
return $this->defaults[$field];
|
||||
} // end function SignalCheckColour
|
||||
|
||||
public static function find( $parameters = array(), $options = array() ) {
|
||||
|
@ -253,7 +253,7 @@ private $status_fields = array(
|
|||
Warning('Attempt to control a monitor with no Id');
|
||||
return;
|
||||
}
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( array_key_exists('ServerId', $this) and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
if ( $this->Type() == 'Local' ) {
|
||||
$zmcArgs = '-d '.$this->{'Device'};
|
||||
} else {
|
||||
|
@ -306,7 +306,7 @@ private $status_fields = array(
|
|||
return;
|
||||
}
|
||||
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( array_key_exists('ServerId', $this) and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
if ( $this->{'Function'} == 'None' || $this->{'Function'} == 'Monitor' || $mode == 'stop' ) {
|
||||
if ( ZM_OPT_CONTROL ) {
|
||||
daemonControl('stop', 'zmtrack.pl', '-m '.$this->{'Id'});
|
||||
|
@ -367,8 +367,8 @@ private $status_fields = array(
|
|||
}
|
||||
}
|
||||
|
||||
if ( !array_key_exists('GroupIds', $this) ) {
|
||||
if ( array_key_exists('Id', $this) and $this->{'Id'} ) {
|
||||
if ( !property_exists($this, 'GroupIds') ) {
|
||||
if ( property_exists($this, 'Id') and $this->{'Id'} ) {
|
||||
$this->{'GroupIds'} = dbFetchAll('SELECT `GroupId` FROM `Groups_Monitors` WHERE `MonitorId`=?', 'GroupId', array($this->{'Id'}) );
|
||||
if ( ! $this->{'GroupIds'} )
|
||||
$this->{'GroupIds'} = array();
|
||||
|
@ -417,7 +417,7 @@ private $status_fields = array(
|
|||
if ( $new ) {
|
||||
$this->{'Storage'} = $new;
|
||||
}
|
||||
if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) ) {
|
||||
if ( ! ( property_exists($this, 'Storage') and $this->{'Storage'} ) ) {
|
||||
$this->{'Storage'} = isset($this->{'StorageId'}) ?
|
||||
Storage::find_one(array('Id'=>$this->{'StorageId'})) :
|
||||
new Storage(NULL);
|
||||
|
@ -493,7 +493,7 @@ public function sendControlCommand($command) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( array_key_exists('ServerId', $this) and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
|
||||
# Local
|
||||
Logger::Debug('Trying to send options ' . print_r($options, true));
|
||||
|
||||
|
|
|
@ -1,133 +1,22 @@
|
|||
<?php
|
||||
namespace ZM;
|
||||
require_once('Object.php');
|
||||
|
||||
require_once('database.php');
|
||||
|
||||
class MontageLayout {
|
||||
|
||||
private $defaults = array(
|
||||
class MontageLayout extends ZM_Object {
|
||||
protected static $table = 'MontageLayouts';
|
||||
protected $defaults = array(
|
||||
'Id' => null,
|
||||
'Name' => '',
|
||||
'Positions' => 0,
|
||||
);
|
||||
|
||||
public function __construct( $IdOrRow = NULL ) {
|
||||
if ( $IdOrRow ) {
|
||||
$row = NULL;
|
||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||
$row = dbFetchOne( 'SELECT * FROM MontageLayouts WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
if ( ! $row ) {
|
||||
Error("Unable to load MontageLayout record for Id=" . $IdOrRow );
|
||||
}
|
||||
} else if ( is_array( $IdOrRow ) ) {
|
||||
$row = $IdOrRow;
|
||||
} else {
|
||||
Error("Unknown argument passed to MontageLayout Constructor ($IdOrRow)");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $row ) {
|
||||
foreach ($row as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
} else {
|
||||
Error('No row for MontageLayout ' . $IdOrRow );
|
||||
}
|
||||
} # end if isset($IdOrRow)
|
||||
} // end function __construct
|
||||
|
||||
public function __call($fn, array $args){
|
||||
if ( count($args) ) {
|
||||
$this->{$fn} = $args[0];
|
||||
}
|
||||
if ( array_key_exists($fn, $this) ) {
|
||||
return $this->{$fn};
|
||||
} else {
|
||||
if ( array_key_exists( $fn, $this->defaults ) ) {
|
||||
return $this->defaults{$fn};
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
$file = $backTrace[1]['file'];
|
||||
$line = $backTrace[1]['line'];
|
||||
Warning( "Unknown function call MontageLayout->$fn from $file:$line" );
|
||||
}
|
||||
}
|
||||
public static function find( $parameters = array(), $options = array() ) {
|
||||
return ZM_Object::_find(get_class(), $parameters, $options);
|
||||
}
|
||||
|
||||
public function set( $data ) {
|
||||
foreach ($data as $k => $v) {
|
||||
if ( is_array( $v ) ) {
|
||||
# perhaps should turn into a comma-separated string
|
||||
$this->{$k} = implode(',',$v);
|
||||
} else if ( is_string( $v ) ) {
|
||||
$this->{$k} = trim( $v );
|
||||
} else if ( is_integer( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
} else if ( is_bool( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
} else {
|
||||
Error( "Unknown type $k => $v of var " . gettype( $v ) );
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
public static function find_one( $parameters = array(), $options = array() ) {
|
||||
return ZM_Object::_find_one(get_class(), $parameters, $options);
|
||||
}
|
||||
public static function find( $parameters = null, $options = null ) {
|
||||
$filters = array();
|
||||
$sql = 'SELECT * FROM MontageLayouts ';
|
||||
$values = array();
|
||||
|
||||
if ( $parameters ) {
|
||||
$fields = array();
|
||||
$sql .= 'WHERE ';
|
||||
foreach ( $parameters as $field => $value ) {
|
||||
if ( $value == null ) {
|
||||
$fields[] = $field.' IS NULL';
|
||||
} else if ( is_array( $value ) ) {
|
||||
$func = function(){return '?';};
|
||||
$fields[] = $field.' IN ('.implode(',', array_map( $func, $value ) ). ')';
|
||||
$values += $value;
|
||||
|
||||
} else {
|
||||
$fields[] = $field.'=?';
|
||||
$values[] = $value;
|
||||
}
|
||||
}
|
||||
$sql .= implode(' AND ', $fields );
|
||||
}
|
||||
if ( $options and isset($options['order']) ) {
|
||||
$sql .= ' ORDER BY ' . $options['order'];
|
||||
}
|
||||
$result = dbQuery($sql, $values);
|
||||
if ( $result ) {
|
||||
$results = $result->fetchALL();
|
||||
foreach ( $results as $row ) {
|
||||
$filters[] = new MontageLayout($row);
|
||||
}
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
public function save( $new_values = null ) {
|
||||
if ( $new_values ) {
|
||||
foreach ( $new_values as $k=>$v ) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array_values( array_filter( array_keys($this->defaults), function($field){return $field != 'Id';} ) );
|
||||
$values = null;
|
||||
if ( isset($this->{'Id'}) ) {
|
||||
$sql = 'UPDATE MontageLayouts SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
$values[] = $this->{'Id'};
|
||||
dbQuery($sql, $values);
|
||||
} else {
|
||||
$sql = 'INSERT INTO MontageLayouts ('.implode( ',', $fields ).') VALUES ('.implode(',',array_map( function(){return '?';}, $fields ) ).')';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
dbQuery($sql, $values);
|
||||
global $dbConn;
|
||||
$this->{'Id'} = $dbConn->lastInsertId();
|
||||
}
|
||||
} // end function save
|
||||
|
||||
} // end class MontageLayout
|
||||
?>
|
||||
|
|
|
@ -45,7 +45,7 @@ class ZM_Object {
|
|||
$this->{$fn} = $args[0];
|
||||
}
|
||||
|
||||
if ( array_key_exists($fn, $this) ) {
|
||||
if ( property_exists($this, $fn) ) {
|
||||
return $this->{$fn};
|
||||
} else {
|
||||
if ( array_key_exists($fn, $this->defaults) ) {
|
||||
|
@ -140,10 +140,10 @@ class ZM_Object {
|
|||
foreach ($this->defaults as $key => $value) {
|
||||
if ( is_callable(array($this, $key)) ) {
|
||||
$json[$key] = $this->$key();
|
||||
} else if ( array_key_exists($key, $this) ) {
|
||||
} else if ( property_exists($this, $key) ) {
|
||||
$json[$key] = $this->{$key};
|
||||
} else {
|
||||
$json[$key] = $this->defaults{$key};
|
||||
$json[$key] = $this->defaults[$key];
|
||||
}
|
||||
}
|
||||
return json_encode($json);
|
||||
|
@ -215,7 +215,7 @@ class ZM_Object {
|
|||
} else if ( $this->$field() != $value ) {
|
||||
$changes[$field] = $value;
|
||||
}
|
||||
} else if ( array_key_exists($field, $this) ) {
|
||||
} else if ( property_exists($this, $field) ) {
|
||||
$type = (array_key_exists($field, $this->defaults) && is_array($this->defaults[$field])) ? $this->defaults[$field]['type'] : 'scalar';
|
||||
Logger::Debug("Checking field $field => current ".
|
||||
(is_array($this->{$field}) ? implode(',',$this->{$field}) : $this->{$field}) . ' ?= ' .
|
||||
|
|
|
@ -80,7 +80,7 @@ class Server extends ZM_Object {
|
|||
|
||||
public function PathToZMS( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this{'PathToZMS'} = $new;
|
||||
$this->{'PathToZMS'} = $new;
|
||||
if ( $this->Id() and $this->{'PathToZMS'} ) {
|
||||
return $this->{'PathToZMS'};
|
||||
} else {
|
||||
|
|
|
@ -80,7 +80,7 @@ class Storage extends ZM_Object {
|
|||
}
|
||||
|
||||
public function disk_total_space() {
|
||||
if ( !array_key_exists('disk_total_space', $this) ) {
|
||||
if ( !property_exists($this, 'disk_total_space') ) {
|
||||
$path = $this->Path();
|
||||
if ( file_exists($path) ) {
|
||||
$this->{'disk_total_space'} = disk_total_space($path);
|
||||
|
@ -94,7 +94,7 @@ class Storage extends ZM_Object {
|
|||
|
||||
public function disk_used_space() {
|
||||
# This isn't a function like this in php, so we have to add up the space used in each event.
|
||||
if ( ( !array_key_exists('disk_used_space', $this)) or !$this->{'disk_used_space'} ) {
|
||||
if ( ( !property_exists($this, 'disk_used_space')) or !$this->{'disk_used_space'} ) {
|
||||
if ( $this->{'Type'} == 's3fs' ) {
|
||||
$this->{'disk_used_space'} = $this->event_disk_space();
|
||||
} else {
|
||||
|
@ -112,7 +112,7 @@ class Storage extends ZM_Object {
|
|||
|
||||
public function event_disk_space() {
|
||||
# This isn't a function like this in php, so we have to add up the space used in each event.
|
||||
if ( (! array_key_exists('DiskSpace', $this)) or (!$this->{'DiskSpace'}) ) {
|
||||
if ( (! property_exists($this, 'DiskSpace')) or (!$this->{'DiskSpace'}) ) {
|
||||
$used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()));
|
||||
|
||||
do {
|
||||
|
@ -130,8 +130,8 @@ class Storage extends ZM_Object {
|
|||
} // end function event_disk_space
|
||||
|
||||
public function Server() {
|
||||
if ( ! array_key_exists('Server',$this) ) {
|
||||
if ( array_key_exists('ServerId', $this) ) {
|
||||
if ( ! property_exists($this, 'Server') ) {
|
||||
if ( property_exists($this, 'ServerId') ) {
|
||||
$this->{'Server'} = Server::find_one(array('Id'=>$this->{'ServerId'}));
|
||||
|
||||
if ( !$this->{'Server'} ) {
|
||||
|
|
|
@ -39,7 +39,7 @@ if ( $action == 'function' ) {
|
|||
$oldFunction = $monitor['Function'];
|
||||
$oldEnabled = $monitor['Enabled'];
|
||||
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
||||
dbQuery('UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?',
|
||||
dbQuery('UPDATE Monitors SET `Function`=?, `Enabled`=? WHERE `Id`=?',
|
||||
array($newFunction, $newEnabled, $mid));
|
||||
|
||||
$monitor['Function'] = $newFunction;
|
||||
|
|
|
@ -31,19 +31,19 @@ if ( $action == 'state' ) {
|
|||
}
|
||||
} else if ( $action == 'save' ) {
|
||||
if ( !empty($_REQUEST['runState']) || !empty($_REQUEST['newState']) ) {
|
||||
$sql = 'SELECT Id,Function,Enabled FROM Monitors ORDER BY Id';
|
||||
$sql = 'SELECT `Id`,`Function`,`Enabled` FROM Monitors ORDER BY Id';
|
||||
$definitions = array();
|
||||
foreach( dbFetchAll($sql) as $monitor ) {
|
||||
foreach ( dbFetchAll($sql) as $monitor ) {
|
||||
$definitions[] = $monitor['Id'].':'.$monitor['Function'].':'.$monitor['Enabled'];
|
||||
}
|
||||
$definition = join(',', $definitions);
|
||||
if ( $_REQUEST['newState'] )
|
||||
$_REQUEST['runState'] = $_REQUEST['newState'];
|
||||
dbQuery('REPLACE INTO States SET Name=?, Definition=?', array($_REQUEST['runState'],$definition));
|
||||
dbQuery('REPLACE INTO `States` SET `Name`=?, `Definition`=?', array($_REQUEST['runState'],$definition));
|
||||
}
|
||||
} else if ( $action == 'delete' ) {
|
||||
if ( isset($_REQUEST['runState']) )
|
||||
dbQuery('DELETE FROM States WHERE Name=?', array($_REQUEST['runState']));
|
||||
dbQuery('DELETE FROM `States` WHERE `Name`=?', array($_REQUEST['runState']));
|
||||
}
|
||||
$view = 'console';
|
||||
?>
|
||||
|
|
|
@ -220,19 +220,19 @@ function generateAuthHash($useRemoteAddr, $force=false) {
|
|||
function visibleMonitor($mid) {
|
||||
global $user;
|
||||
|
||||
return ( empty($user['MonitorIds']) || in_array($mid, explode(',', $user['MonitorIds'])) );
|
||||
return ( $user && empty($user['MonitorIds']) || in_array($mid, explode(',', $user['MonitorIds'])) );
|
||||
}
|
||||
|
||||
function canView($area, $mid=false) {
|
||||
global $user;
|
||||
|
||||
return ( ($user[$area] == 'View' || $user[$area] == 'Edit') && ( !$mid || visibleMonitor($mid) ) );
|
||||
return ( $user && ($user[$area] == 'View' || $user[$area] == 'Edit') && ( !$mid || visibleMonitor($mid) ) );
|
||||
}
|
||||
|
||||
function canEdit($area, $mid=false) {
|
||||
global $user;
|
||||
|
||||
return ( $user[$area] == 'Edit' && ( !$mid || visibleMonitor($mid) ));
|
||||
return ( $user && ($user[$area] == 'Edit') && ( !$mid || visibleMonitor($mid) ));
|
||||
}
|
||||
|
||||
function userFromSession() {
|
||||
|
|
|
@ -110,16 +110,10 @@ function dbError($sql) {
|
|||
|
||||
function dbEscape( $string ) {
|
||||
global $dbConn;
|
||||
if ( version_compare(phpversion(), '4.3.0', '<'))
|
||||
if ( get_magic_quotes_gpc() )
|
||||
return $dbConn->quote(stripslashes($string));
|
||||
else
|
||||
return $dbConn->quote($string);
|
||||
if ( version_compare(phpversion(), '5.4', '<=') and get_magic_quotes_gpc() )
|
||||
return $dbConn->quote(stripslashes($string));
|
||||
else
|
||||
if ( get_magic_quotes_gpc() )
|
||||
return $dbConn->quote(stripslashes($string));
|
||||
else
|
||||
return $dbConn->quote($string);
|
||||
return $dbConn->quote($string);
|
||||
}
|
||||
|
||||
function dbQuery($sql, $params=NULL) {
|
||||
|
|
|
@ -46,7 +46,7 @@ var popupSizes = {
|
|||
'group': {'width': 760, 'height': 600},
|
||||
'groups': {'width': 540, 'height': 420},
|
||||
'image': {'addWidth': 48, 'addHeight': 80},
|
||||
'log': {'width': 1080, 'height': 720},
|
||||
'log': {'width': 1180, 'height': 720},
|
||||
'login': {'width': 720, 'height': 480},
|
||||
'logout': {'width': 260, 'height': 150},
|
||||
'monitor': {'width': 800, 'height': 780},
|
||||
|
|
Loading…
Reference in New Issue