From 82188c266edd6e21dceba649096eba672da0e7be Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:30:59 -0400 Subject: [PATCH] Fixup Monitor->sendControlCommand. start/stop/quit should be run through zmdc.pl now instead of talking directly to zmcontrol. --- web/includes/Monitor.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index c788b5fb8..f9341c71a 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -495,12 +495,16 @@ class Monitor extends ZM_Object { } } if ( !count($options) ) { - if ( $command == 'quit' ) { - $options['command'] = 'quit'; - } else if ( $command == 'start' ) { - $options['command'] = 'start'; - } else if ( $command == 'stop' ) { - $options['command'] = 'stop'; + + if ( $command == 'quit' or $command == 'start' or $command == 'stop' ) { + # These are special as we now run zmcontrol as a daemon through zmdc. + $status = daemonStatus('zmcontrol.pl', array('--id', $this->{'Id'})); + Logger::Debug("Current status $status"); + if ( $status or ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) ) { + daemonControl($command, 'zmcontrol.pl', '--id '.$this->{'Id'}); + return; + } + $options['command'] = $command; } else { Warning("No commands to send to zmcontrol from $command"); return false; @@ -538,12 +542,12 @@ class Monitor extends ZM_Object { $url = ZM_BASE_PROTOCOL . '://'.$Server->Hostname().'/zm/api/monitors/daemonControl/'.$this->{'Id'}.'/'.$command.'/zmcontrol.pl.json'; if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { - $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); + $url .= '?auth='.generateAuthHash(ZM_AUTH_HASH_IPS); } else if ( ZM_AUTH_RELAY == 'plain' ) { - $url = '?user='.$_SESSION['username']; - $url = '?pass='.$_SESSION['password']; + $url .= '?user='.$_SESSION['username']; + $url .= '?pass='.$_SESSION['password']; } else if ( ZM_AUTH_RELAY == 'none' ) { - $url = '?user='.$_SESSION['username']; + $url .= '?user='.$_SESSION['username']; } } Logger::Debug("sending command to $url");