Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
17a29f7e83
|
@ -529,6 +529,7 @@ sub kill_until_dead {
|
|||
.". Sending KILL to pid $$process{pid}\n"
|
||||
);
|
||||
kill( 'KILL', $$process{pid} );
|
||||
last;
|
||||
}
|
||||
|
||||
sigprocmask(SIG_UNBLOCK, $blockset) or die "dying at unblock...\n";
|
||||
|
|
|
@ -1,23 +1,4 @@
|
|||
<?php
|
||||
function unparse_url($parsed_url, $substitutions = array() ) {
|
||||
$fields = array('scheme','host','port','user','pass','path','query','fragment');
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
if ( isset( $substitutions[$field] ) ) {
|
||||
$parsed_url[$field] = $substitutions[$field];
|
||||
}
|
||||
}
|
||||
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
||||
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
||||
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
|
||||
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
|
||||
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
|
||||
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
|
||||
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
|
||||
return "$scheme$user$pass$host$port$path$query$fragment";
|
||||
}
|
||||
|
||||
$defaultMonitor = new Monitor();
|
||||
$defaultMonitor->set(array(
|
||||
|
|
|
@ -162,14 +162,16 @@ class MonitorsController extends AppController {
|
|||
'_serialize' => array('message')
|
||||
));
|
||||
|
||||
// - restart or stop this monitor after change
|
||||
$func = $this->Monitor->find('first', array(
|
||||
'fields' => array('Function'),
|
||||
$Monitor = $this->Monitor->find('first', array(
|
||||
'fields' => array('Function','ServerId'),
|
||||
'conditions' => array('Id' => $id)
|
||||
))['Monitor']['Function'];
|
||||
))['Monitor'];
|
||||
|
||||
// - restart or stop this monitor after change
|
||||
$func = $Monitor['Function'];
|
||||
// We don't pass the request data as the monitor object because it may be a subset of the full monitor array
|
||||
$this->daemonControl( $this->Monitor->id, 'stop' );
|
||||
if ( ( $func != 'None' ) and ( $this->Monitor->ServerId == ZM_SERVER_ID ) ) {
|
||||
if ( ( $func != 'None' ) and ( $Monitor['ServerId'] == ZM_SERVER_ID ) ) {
|
||||
$this->daemonControl( $this->Monitor->id, 'start' );
|
||||
}
|
||||
} // end function edit
|
||||
|
|
|
@ -18,6 +18,7 @@ private $defaults = array(
|
|||
'AnalysisFPS' => null,
|
||||
'CaptureFPS' => null,
|
||||
'ZoneCount' => 0,
|
||||
'Triggers' => null,
|
||||
);
|
||||
private $control_fields = array(
|
||||
'Name' => '',
|
||||
|
@ -126,7 +127,7 @@ private $control_fields = array(
|
|||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
if ( ! $row ) {
|
||||
Error("Unable to load Server record for Id=" . $IdOrRow );
|
||||
Error("Unable to load Monitor record for Id=" . $IdOrRow );
|
||||
}
|
||||
} elseif ( is_array( $IdOrRow ) ) {
|
||||
$row = $IdOrRow;
|
||||
|
@ -324,8 +325,9 @@ private $control_fields = array(
|
|||
if ( $mode == 'restart' ) {
|
||||
daemonControl( 'stop', 'zmc', $zmcArgs );
|
||||
}
|
||||
if ( $this->{'Function'} != 'None' )
|
||||
if ( $this->{'Function'} != 'None' ) {
|
||||
daemonControl( 'start', 'zmc', $zmcArgs );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$Server = $this->Server();
|
||||
|
@ -341,6 +343,7 @@ private $control_fields = array(
|
|||
$url = '&user='.$_SESSION['username'];
|
||||
}
|
||||
}
|
||||
Logger::Debug("sending command to $url");
|
||||
$data = array('Monitor[Function]' => $this->{'Function'} );
|
||||
|
||||
// use key 'http' even if you send the request to https://...
|
||||
|
@ -352,10 +355,17 @@ private $control_fields = array(
|
|||
)
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
if ($result === FALSE) { /* Handle error */ }
|
||||
try {
|
||||
$result = file_get_contents($url, false, $context);
|
||||
if ($result === FALSE) { /* Handle error */
|
||||
Error("Error restarting zmc using $url");
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
Error("Except $e thrown trying to restart zmc");
|
||||
}
|
||||
}
|
||||
} // end function zmcControl
|
||||
|
||||
function zmaControl( $mode=false ) {
|
||||
if ( (!defined('ZM_SERVER_ID')) or ( ZM_SERVER_ID==$this->{'ServerId'} ) ) {
|
||||
if ( $this->{'Function'} == 'None' || $this->{'Function'} == 'Monitor' || $mode == 'stop' ) {
|
||||
|
|
|
@ -120,7 +120,7 @@ public static function find_all( $parameters = null, $options = null ) {
|
|||
}
|
||||
$used = $this->disk_used_space();
|
||||
$usage = round( ($used / $total) * 100);
|
||||
Logger::Debug("Used $usage = round( ( $used / $total ) * 100 )");
|
||||
//Logger::Debug("Used $usage = round( ( $used / $total ) * 100 )");
|
||||
return $usage;
|
||||
}
|
||||
public function disk_total_space() {
|
||||
|
|
|
@ -530,6 +530,7 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
$restart = true;
|
||||
} elseif ( ! $user['MonitorIds'] ) { // Can only create new monitors if we are not restricted to specific monitors
|
||||
# FIXME This is actually a race condition. Should lock the table.
|
||||
$maxSeq = dbFetchOne( 'SELECT max(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence' );
|
||||
|
@ -570,15 +571,16 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
}
|
||||
|
||||
if ( $restart ) {
|
||||
$new_monitor = dbFetchOne( 'SELECT * FROM Monitors WHERE Id = ?', NULL, array($mid) );
|
||||
|
||||
$new_monitor = new Monitor($mid);
|
||||
//fixDevices();
|
||||
//if ( $cookies )
|
||||
//session_write_close();
|
||||
|
||||
zmcControl( $new_monitor, 'start' );
|
||||
zmaControl( $new_monitor, 'start' );
|
||||
$new_monitor->zmcControl('start');
|
||||
$new_monitor->zmaControl('start');
|
||||
|
||||
if ( $new_monitor['Controllable'] ) {
|
||||
if ( $new_monitor->Controllable() ) {
|
||||
require_once( 'control_functions.php' );
|
||||
sendControlCommand( $mid, 'quit' );
|
||||
}
|
||||
|
|
|
@ -841,6 +841,7 @@ function daemonControl( $command, $daemon=false, $args=false ) {
|
|||
}
|
||||
$string = escapeshellcmd( $string );
|
||||
#$string .= ' 2>/dev/null >&- <&- >/dev/null';
|
||||
Logger::Debug("daemonControl $string");
|
||||
exec( $string );
|
||||
}
|
||||
|
||||
|
@ -2314,4 +2315,23 @@ function csrf_startup() {
|
|||
csrf_conf('rewrite-js', 'includes/csrf/csrf-magic.js');
|
||||
}
|
||||
|
||||
function unparse_url($parsed_url, $substitutions = array() ) {
|
||||
$fields = array('scheme','host','port','user','pass','path','query','fragment');
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
if ( isset( $substitutions[$field] ) ) {
|
||||
$parsed_url[$field] = $substitutions[$field];
|
||||
}
|
||||
}
|
||||
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
||||
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
||||
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
|
||||
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
|
||||
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
|
||||
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
|
||||
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
|
||||
return "$scheme$user$pass$host$port$path$query$fragment";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -154,7 +154,7 @@ class Logger {
|
|||
|
||||
$this->initialised = true;
|
||||
|
||||
Logger::Debug( "LogOpts: level=".self::$codes[$this->level]."/".self::$codes[$this->effectiveLevel].", screen=".self::$codes[$this->termLevel].", database=".self::$codes[$this->databaseLevel].", logfile=".self::$codes[$this->fileLevel]."->".$this->logFile.", weblog=".self::$codes[$this->weblogLevel].", syslog=".self::$codes[$this->syslogLevel] );
|
||||
//Logger::Debug( "LogOpts: level=".self::$codes[$this->level]."/".self::$codes[$this->effectiveLevel].", screen=".self::$codes[$this->termLevel].", database=".self::$codes[$this->databaseLevel].", logfile=".self::$codes[$this->fileLevel]."->".$this->logFile.", weblog=".self::$codes[$this->weblogLevel].", syslog=".self::$codes[$this->syslogLevel] );
|
||||
}
|
||||
|
||||
private function terminate() {
|
||||
|
|
Loading…
Reference in New Issue