index.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. ob_start();
  4. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  5. // Check token
  6. verify_csrf($_POST);
  7. if (empty($_POST["domain"])) {
  8. header("Location: /list/mail");
  9. exit();
  10. }
  11. if (empty($_POST["action"])) {
  12. header("Location: /list/mail");
  13. exit();
  14. }
  15. $domain = $_POST["domain"];
  16. if (empty($_POST["account"])) {
  17. $account = "";
  18. } else {
  19. $account = $_POST["account"];
  20. }
  21. $action = $_POST["action"];
  22. if ($_SESSION["userContext"] === "admin") {
  23. if (empty($_POST["account"])) {
  24. switch ($action) {
  25. case "rebuild":
  26. $cmd = "v-rebuild-mail-domain";
  27. break;
  28. case "delete":
  29. $cmd = "v-delete-mail-domain";
  30. break;
  31. case "suspend":
  32. $cmd = "v-suspend-mail-domain";
  33. break;
  34. case "unsuspend":
  35. $cmd = "v-unsuspend-mail-domain";
  36. break;
  37. default:
  38. header("Location: /list/mail/");
  39. exit();
  40. }
  41. } else {
  42. switch ($action) {
  43. case "delete":
  44. $cmd = "v-delete-mail-account";
  45. break;
  46. case "suspend":
  47. $cmd = "v-suspend-mail-account";
  48. break;
  49. case "unsuspend":
  50. $cmd = "v-unsuspend-mail-account";
  51. break;
  52. default:
  53. header("Location: /list/mail/?domain=" . $domain);
  54. exit();
  55. }
  56. }
  57. } else {
  58. if (empty($_POST["account"])) {
  59. switch ($action) {
  60. case "delete":
  61. $cmd = "v-delete-mail-domain";
  62. break;
  63. case "suspend":
  64. $cmd = "v-suspend-mail-domain";
  65. break;
  66. case "unsuspend":
  67. $cmd = "v-unsuspend-mail-domain";
  68. break;
  69. default:
  70. header("Location: /list/mail/");
  71. exit();
  72. }
  73. } else {
  74. switch ($action) {
  75. case "delete":
  76. $cmd = "v-delete-mail-account";
  77. break;
  78. case "suspend":
  79. $cmd = "v-suspend-mail-account";
  80. break;
  81. case "unsuspend":
  82. $cmd = "v-unsuspend-mail-account";
  83. break;
  84. default:
  85. header("Location: /list/mail/?domain=" . $domain);
  86. exit();
  87. }
  88. }
  89. }
  90. if (empty($_POST["account"])) {
  91. if (is_array($domain)) {
  92. foreach ($domain as $value) {
  93. // Mail
  94. $value = quoteshellarg($value);
  95. exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
  96. $restart = "yes";
  97. }
  98. } else {
  99. header("Location: /list/mail/?domain=" . $domain);
  100. exit();
  101. }
  102. } else {
  103. foreach ($account as $value) {
  104. // Mail Account
  105. $value = quoteshellarg($value);
  106. $dom = quoteshellarg($domain);
  107. exec(HESTIA_CMD . $cmd . " " . $user . " " . $dom . " " . $value, $output, $return_var);
  108. $restart = "yes";
  109. }
  110. }
  111. if (empty($account)) {
  112. header("Location: /list/mail/");
  113. exit();
  114. } else {
  115. header("Location: /list/mail/?domain=" . $domain);
  116. exit();
  117. }