From 086d435712cc416a651065e36b5f3875fd476833 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 7 Jun 2016 14:39:59 -0400 Subject: [PATCH] send zmcCommand to api on server --- web/includes/functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web/includes/functions.php b/web/includes/functions.php index 0c9339970..487ef01a4 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -835,6 +835,24 @@ function zmcControl( $monitor, $mode=false ) { } daemonControl( "start", "zmc", $zmcArgs ); } + } else { + $Server = new Server( $monitor['ServerId'] ); + + $url = $Server->Url() . '/zm/api/monitors.json?auth='.generateAuthHash( $_SESSION['remoteAddr'] ); + $data = array('Monitor[Function]' => $monitor['Function'] ); + + // use key 'http' even if you send the request to https://... + $options = array( + 'http' => array( + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($data) + ) + ); + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + if ($result === FALSE) { /* Handle error */ } + } }