index.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/web/");
  9. exit();
  10. }
  11. if (empty($_POST["action"])) {
  12. header("Location: /list/web");
  13. exit();
  14. }
  15. $domain = $_POST["domain"];
  16. $action = $_POST["action"];
  17. if ($_SESSION["userContext"] === "admin") {
  18. switch ($action) {
  19. case "delete":
  20. $cmd = "v-delete-web-domain";
  21. break;
  22. case "rebuild":
  23. $cmd = "v-rebuild-web-domain";
  24. break;
  25. case "suspend":
  26. $cmd = "v-suspend-web-domain";
  27. break;
  28. case "unsuspend":
  29. $cmd = "v-unsuspend-web-domain";
  30. break;
  31. case "purge":
  32. $cmd = "v-purge-nginx-cache";
  33. break;
  34. default:
  35. header("Location: /list/web/");
  36. exit();
  37. }
  38. } else {
  39. switch ($action) {
  40. case "delete":
  41. $cmd = "v-delete-web-domain";
  42. break;
  43. case "suspend":
  44. $cmd = "v-suspend-web-domain";
  45. break;
  46. case "unsuspend":
  47. $cmd = "v-unsuspend-web-domain";
  48. break;
  49. case "purge":
  50. $cmd = "v-purge-nginx-cache";
  51. break;
  52. default:
  53. header("Location: /list/web/");
  54. exit();
  55. }
  56. }
  57. foreach ($domain as $value) {
  58. $value = quoteshellarg($value);
  59. exec(HESTIA_CMD . $cmd . " " . $user . " " . $value . " no", $output, $return_var);
  60. $restart = "yes";
  61. }
  62. if (isset($restart)) {
  63. exec(HESTIA_CMD . "v-restart-web", $output, $return_var);
  64. exec(HESTIA_CMD . "v-restart-proxy", $output, $return_var);
  65. exec(HESTIA_CMD . "v-restart-dns", $output, $return_var);
  66. exec(HESTIA_CMD . "v-restart-web-backend", $output, $return_var);
  67. }
  68. header("Location: /list/web/");