index.php 1.0 KB

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