Merge branch 'master' into fix_token_auth_sessions
This commit is contained in:
commit
fdb66aaa72
|
@ -118,13 +118,13 @@ class Group extends ZM_Object {
|
|||
if ( is_array($group_id) ) {
|
||||
$group_id_sql_part = ' IN ('.implode(',', array_map(function(){return '?';}, $group_id ) ).')';
|
||||
|
||||
$MonitorIds = dbFetchAll('SELECT MonitorId FROM Groups_Monitors WHERE GroupId'.$group_id_sql_part, 'MonitorId', $group_id);
|
||||
$MonitorIds = dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId`'.$group_id_sql_part, 'MonitorId', $group_id);
|
||||
|
||||
$MonitorIds = array_merge($MonitorIds, dbFetchAll('SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId'.$group_id_sql_part.')', 'MonitorId', $group_id));
|
||||
$MonitorIds = array_merge($MonitorIds, dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId` IN (SELECT `Id` FROM `Groups` WHERE `ParentId`'.$group_id_sql_part.')', 'MonitorId', $group_id));
|
||||
} else {
|
||||
$MonitorIds = dbFetchAll('SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id));
|
||||
$MonitorIds = dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId`=?', 'MonitorId', array($group_id));
|
||||
|
||||
$MonitorIds = array_merge($MonitorIds, dbFetchAll('SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id)));
|
||||
$MonitorIds = array_merge($MonitorIds, dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId` IN (SELECT `Id` FROM `Groups` WHERE `ParentId` = ?)', 'MonitorId', array($group_id)));
|
||||
}
|
||||
$groupSql = " find_in_set( M.Id, '".implode(',', $MonitorIds)."' )";
|
||||
}
|
||||
|
@ -138,11 +138,11 @@ class Group extends ZM_Object {
|
|||
} else if ( isset($_COOKIE['zmMonitorId']) ) {
|
||||
$monitor_id = $_COOKIE['zmMonitorId'];
|
||||
}
|
||||
$sql = 'SELECT * FROM Monitors';
|
||||
$sql = 'SELECT `Id`,`Name` FROM `Monitors`';
|
||||
if ( $options ) {
|
||||
$sql .= ' WHERE '. implode(' AND ', array(
|
||||
( isset($options['groupSql']) ? $options['groupSql']:'')
|
||||
) ).' ORDER BY Sequence ASC';
|
||||
) ).' ORDER BY `Sequence` ASC';
|
||||
}
|
||||
$monitors_dropdown = array(''=>'All');
|
||||
|
||||
|
@ -153,7 +153,7 @@ class Group extends ZM_Object {
|
|||
$monitors_dropdown[$monitor['Id']] = $monitor['Name'];
|
||||
}
|
||||
|
||||
echo htmlSelect('monitor_id', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);'));
|
||||
echo htmlSelect('monitor_id', $monitors_dropdown, $monitor_id, array('data-on-change-this'=>'changeMonitor'));
|
||||
return $monitor_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,11 @@ class ZM_Object {
|
|||
|
||||
public function __construct($IdOrRow = NULL) {
|
||||
$class = get_class($this);
|
||||
global $object_cache;
|
||||
if ( ! isset($object_cache[$class]) )
|
||||
$object_cache[$class] = array();
|
||||
$cache = $object_cache[$class];
|
||||
|
||||
$table = $class::$table;
|
||||
|
||||
$row = NULL;
|
||||
if ( $IdOrRow ) {
|
||||
if ( is_integer($IdOrRow) or ctype_digit($IdOrRow) ) {
|
||||
$table = $class::$table;
|
||||
$row = dbFetchOne("SELECT * FROM `$table` WHERE `Id`=?", NULL, array($IdOrRow));
|
||||
if ( !$row ) {
|
||||
Error("Unable to load $class record for Id=$IdOrRow");
|
||||
|
@ -25,17 +20,24 @@ class ZM_Object {
|
|||
} elseif ( is_array($IdOrRow) ) {
|
||||
$row = $IdOrRow;
|
||||
}
|
||||
} # end if isset($IdOrRow)
|
||||
|
||||
if ( $row ) {
|
||||
global $object_cache;
|
||||
if ( ! isset($object_cache[$class]) ) {
|
||||
$object_cache[$class] = array();
|
||||
}
|
||||
$cache = &$object_cache[$class];
|
||||
|
||||
foreach ($row as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
$cache[$row['Id']] = $this;
|
||||
}
|
||||
} else {
|
||||
# Set defaults
|
||||
foreach ( $this->defaults as $k => $v ) $this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
} # end if isset($IdOrRow)
|
||||
} # end function __construct
|
||||
|
||||
public function __call($fn, array $args){
|
||||
if ( count($args) ) {
|
||||
|
@ -48,7 +50,7 @@ class ZM_Object {
|
|||
return $this->defaults{$fn};
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
Warning("Unknown function call Sensor->$fn from ".print_r($backTrace,true));
|
||||
Warning("Unknown function call Object->$fn from ".print_r($backTrace,true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,13 +100,13 @@ class ZM_Object {
|
|||
}
|
||||
}
|
||||
return $results;
|
||||
} # end public function find()
|
||||
} # end public function _find()
|
||||
|
||||
public static function _find_one($class, $parameters = array(), $options = array() ) {
|
||||
global $object_cache;
|
||||
if ( ! isset($object_cache[$class]) )
|
||||
$object_cache[$class] = array();
|
||||
$cache = $object_cache[$class];
|
||||
$cache = &$object_cache[$class];
|
||||
if (
|
||||
( count($parameters) == 1 ) and
|
||||
isset($parameters['Id']) and
|
||||
|
@ -175,7 +177,7 @@ class ZM_Object {
|
|||
|
||||
if ( method_exists($this, $field) ) {
|
||||
$old_value = $this->$field();
|
||||
Logger::Debug("Checking method $field () ".print_r($old_value,true)." => " . print_r($value,true));
|
||||
Logger::Debug("Checking method $field () ".print_r($old_value,true).' => ' . print_r($value,true));
|
||||
if ( is_array($old_value) ) {
|
||||
$diff = array_recursive_diff($old_value, $value);
|
||||
Logger::Debug("Checking method $field () diff is".print_r($diff,true));
|
||||
|
@ -186,13 +188,13 @@ class ZM_Object {
|
|||
$changes[$field] = $value;
|
||||
}
|
||||
} else if ( array_key_exists($field, $this) ) {
|
||||
Logger::Debug("Checking field $field => ".$this->{$field} . " ?= " .$value);
|
||||
Logger::Debug("Checking field $field => ".$this->{$field} . ' ?= ' .$value);
|
||||
if ( $this->{$field} != $value ) {
|
||||
$changes[$field] = $value;
|
||||
}
|
||||
} else if ( array_key_exists($field, $this->defaults) ) {
|
||||
|
||||
Logger::Debug("Checking default $field => ".$this->defaults[$field] . " " .$value);
|
||||
Logger::Debug("Checking default $field => ".$this->defaults[$field] . ' ' .$value);
|
||||
if ( $this->defaults[$field] != $value ) {
|
||||
$changes[$field] = $value;
|
||||
}
|
||||
|
|
|
@ -2400,13 +2400,13 @@ function check_timezone() {
|
|||
#");
|
||||
|
||||
if ( $sys_tzoffset != $php_tzoffset )
|
||||
ZM\Fatal("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
|
||||
ZM\Error("ZoneMinder is not installed properly: php's date.timezone does not match the system timezone!");
|
||||
|
||||
if ( $sys_tzoffset != $mysql_tzoffset )
|
||||
ZM\Error("ZoneMinder is not installed properly: mysql's timezone does not match the system timezone! Event lists will display incorrect times.");
|
||||
|
||||
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone')))
|
||||
ZM\Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
|
||||
ZM\Error("ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,6 @@ if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Verify the system, php, and mysql timezones all match
|
||||
check_timezone();
|
||||
|
||||
if ( isset($_GET['skin']) ) {
|
||||
$skin = $_GET['skin'];
|
||||
|
@ -170,6 +168,7 @@ $user = null;
|
|||
if ( isset($_REQUEST['view']) )
|
||||
$view = detaintPath($_REQUEST['view']);
|
||||
|
||||
|
||||
# Add CSP Headers
|
||||
$cspNonce = bin2hex(openssl_random_pseudo_bytes(16));
|
||||
|
||||
|
@ -191,6 +190,11 @@ isset($view) || $view = NULL;
|
|||
isset($request) || $request = NULL;
|
||||
isset($action) || $action = NULL;
|
||||
|
||||
if ( (!$view and !$request) or ($view == 'console') ) {
|
||||
// Verify the system, php, and mysql timezones all match
|
||||
check_timezone();
|
||||
}
|
||||
|
||||
ZM\Logger::Debug("View: $view Request: $request Action: $action User: " . ( isset($user) ? $user['Username'] : 'none' ));
|
||||
if (
|
||||
ZM_ENABLE_CSRF_MAGIC &&
|
||||
|
|
Loading…
Reference in New Issue