index.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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["service"])) {
  8. header("Location: /list/server/");
  9. exit();
  10. }
  11. if (empty($_POST["action"])) {
  12. header("Location: /list/server/");
  13. exit();
  14. }
  15. $service = $_POST["service"];
  16. $action = $_POST["action"];
  17. if ($_SESSION["userContext"] === "admin") {
  18. switch ($action) {
  19. case "stop":
  20. $cmd = "v-stop-service";
  21. break;
  22. case "start":
  23. $cmd = "v-start-service";
  24. break;
  25. case "restart":
  26. $cmd = "v-restart-service";
  27. break;
  28. default:
  29. header("Location: /list/server/");
  30. exit();
  31. }
  32. if (!empty($_POST["system"]) && $action == "restart") {
  33. $_SESSION["error_srv"] = _("The system is going down for reboot NOW!");
  34. exec(HESTIA_CMD . "v-restart-system yes", $output, $return_var);
  35. unset($output);
  36. header("Location: /list/server/");
  37. exit();
  38. }
  39. foreach ($service as $value) {
  40. $value = quoteshellarg($value);
  41. exec(HESTIA_CMD . $cmd . " " . $value, $output, $return_var);
  42. }
  43. }
  44. header("Location: /list/server/");