index.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $domain = $_POST["domain"];
  8. $account = $_POST["account"];
  9. $action = $_POST["action"];
  10. if ($_SESSION["userContext"] === "admin") {
  11. if (empty($account)) {
  12. switch ($action) {
  13. case "rebuild":
  14. $cmd = "v-rebuild-mail-domain";
  15. break;
  16. case "delete":
  17. $cmd = "v-delete-mail-domain";
  18. break;
  19. case "suspend":
  20. $cmd = "v-suspend-mail-domain";
  21. break;
  22. case "unsuspend":
  23. $cmd = "v-unsuspend-mail-domain";
  24. break;
  25. default:
  26. header("Location: /list/mail/");
  27. exit();
  28. }
  29. } else {
  30. switch ($action) {
  31. case "delete":
  32. $cmd = "v-delete-mail-account";
  33. break;
  34. case "suspend":
  35. $cmd = "v-suspend-mail-account";
  36. break;
  37. case "unsuspend":
  38. $cmd = "v-unsuspend-mail-account";
  39. break;
  40. default:
  41. header("Location: /list/mail/?domain=" . $domain);
  42. exit();
  43. }
  44. }
  45. } else {
  46. if (empty($account)) {
  47. switch ($action) {
  48. case "delete":
  49. $cmd = "v-delete-mail-domain";
  50. break;
  51. case "suspend":
  52. $cmd = "v-suspend-mail-domain";
  53. break;
  54. case "unsuspend":
  55. $cmd = "v-unsuspend-mail-domain";
  56. break;
  57. default:
  58. header("Location: /list/mail/");
  59. exit();
  60. }
  61. } else {
  62. switch ($action) {
  63. case "delete":
  64. $cmd = "v-delete-mail-account";
  65. break;
  66. case "suspend":
  67. $cmd = "v-suspend-mail-account";
  68. break;
  69. case "unsuspend":
  70. $cmd = "v-unsuspend-mail-account";
  71. break;
  72. default:
  73. header("Location: /list/mail/?domain=" . $domain);
  74. exit();
  75. }
  76. }
  77. }
  78. if (empty($account)) {
  79. foreach ($domain as $value) {
  80. // Mail
  81. $value = quoteshellarg($value);
  82. exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
  83. $restart = "yes";
  84. }
  85. } else {
  86. foreach ($account as $value) {
  87. // Mail Account
  88. $value = quoteshellarg($value);
  89. $dom = quoteshellarg($domain);
  90. exec(HESTIA_CMD . $cmd . " " . $user . " " . $dom . " " . $value, $output, $return_var);
  91. $restart = "yes";
  92. }
  93. }
  94. if (empty($account)) {
  95. header("Location: /list/mail/");
  96. exit();
  97. } else {
  98. header("Location: /list/mail/?domain=" . $domain);
  99. exit();
  100. }