call_sogo_ctrl.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.startProcess", 'reconf-domains', 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. sleep(4);
  22. $request = xmlrpc_encode_request("supervisor.startProcess", 'sogo', array('encoding'=>'utf-8'));
  23. $context = stream_context_create(array('http' => array(
  24. 'method' => "POST",
  25. 'header' => "Content-Length: " . strlen($request),
  26. 'content' => $request
  27. )));
  28. $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
  29. $response = xmlrpc_decode($file);
  30. if (isset($response['faultString'])) {
  31. echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
  32. }
  33. else {
  34. echo '<b><span class="pull-right text-success">OK</span></b>';
  35. }
  36. }
  37. }
  38. elseif ($_GET['ACTION'] == "stop") {
  39. $request = xmlrpc_encode_request("supervisor.stopProcess", 'sogo', array('encoding'=>'utf-8'));
  40. $context = stream_context_create(array('http' => array(
  41. 'method' => "POST",
  42. 'header' => "Content-Length: " . strlen($request),
  43. 'content' => $request
  44. )));
  45. $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
  46. $response = xmlrpc_decode($file);
  47. if (isset($response['faultString'])) {
  48. echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
  49. }
  50. else {
  51. sleep(1);
  52. $request = xmlrpc_encode_request("supervisor.stopProcess", 'reconf-domains', array('encoding'=>'utf-8'));
  53. $context = stream_context_create(array('http' => array(
  54. 'method' => "POST",
  55. 'header' => "Content-Length: " . strlen($request),
  56. 'content' => $request
  57. )));
  58. $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
  59. $response = xmlrpc_decode($file);
  60. if (isset($response['faultString'])) {
  61. echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
  62. }
  63. else {
  64. echo '<b><span class="pull-right text-success">OK</span></b>';
  65. }
  66. }
  67. }
  68. ?>