index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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["database"])) {
  8. header("Location: /list/db/");
  9. exit();
  10. }
  11. if (empty($_POST["action"])) {
  12. header("Location: /list/db/");
  13. exit();
  14. }
  15. $database = $_POST["database"];
  16. $action = $_POST["action"];
  17. if ($_SESSION["userContext"] === "admin") {
  18. switch ($action) {
  19. case "rebuild":
  20. $cmd = "v-rebuild-database";
  21. break;
  22. case "delete":
  23. $cmd = "v-delete-database";
  24. break;
  25. case "suspend":
  26. $cmd = "v-suspend-database";
  27. break;
  28. case "unsuspend":
  29. $cmd = "v-unsuspend-database";
  30. break;
  31. default:
  32. header("Location: /list/db/");
  33. exit();
  34. }
  35. } else {
  36. switch ($action) {
  37. case "delete":
  38. $cmd = "v-delete-database";
  39. break;
  40. case "suspend":
  41. $cmd = "v-suspend-database";
  42. break;
  43. case "unsuspend":
  44. $cmd = "v-unsuspend-database";
  45. break;
  46. default:
  47. header("Location: /list/db/");
  48. exit();
  49. }
  50. }
  51. foreach ($database as $value) {
  52. $value = quoteshellarg($value);
  53. exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
  54. }
  55. header("Location: /list/db/");