call_sogo_ctrl.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. session_start();
  3. $AuthUsers = array("admin");
  4. if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role'], $AuthUsers)) {
  5. echo "Not allowed." . PHP_EOL;
  6. exit();
  7. }
  8. if ($_GET['ACTION'] == "start") {
  9. $request = xmlrpc_encode_request("supervisor.startProcessGroup", 'sogo-group', array('encoding'=>'utf-8'));
  10. $context = stream_context_create(array('http' => array(
  11. 'method' => "POST",
  12. 'header' => "Content-Length: " . strlen($request),
  13. 'content' => $request
  14. )));
  15. $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
  16. $response = xmlrpc_decode($file);
  17. if (isset($response['faultString'])) {
  18. echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
  19. }
  20. else {
  21. echo '<b><span class="pull-right text-success">OK</span></b>';
  22. }
  23. }
  24. elseif ($_GET['ACTION'] == "stop") {
  25. $request = xmlrpc_encode_request("supervisor.stopProcessGroup", 'sogo-group', array('encoding'=>'utf-8'));
  26. $context = stream_context_create(array('http' => array(
  27. 'method' => "POST",
  28. 'header' => "Content-Length: " . strlen($request),
  29. 'content' => $request
  30. )));
  31. $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
  32. $response = xmlrpc_decode($file);
  33. if (isset($response['faultString'])) {
  34. echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
  35. }
  36. else {
  37. echo '<b><span class="pull-right text-success">OK</span></b>';
  38. }
  39. }
  40. ?>