index.php 951 B

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