index.php 925 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. ob_start();
  4. // Main include
  5. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  6. // Check token
  7. verify_csrf($_POST);
  8. // Check user
  9. if ($_SESSION["userContext"] != "admin") {
  10. header("Location: /list/user");
  11. exit();
  12. }
  13. if (empty($_POST["ipchain"])) {
  14. header("Location: /list/firewall/banlist/");
  15. exit();
  16. }
  17. if (empty($_POST["action"])) {
  18. header("Location: /list/firewall/banlist/");
  19. exit();
  20. }
  21. $ipchain = $_POST["ipchain"];
  22. $action = $_POST["action"];
  23. switch ($action) {
  24. case "delete":
  25. $cmd = "v-delete-firewall-ban";
  26. break;
  27. default:
  28. header("Location: /list/firewall/banlist/");
  29. exit();
  30. }
  31. foreach ($ipchain as $value) {
  32. [$ip, $chain] = explode(":", $value);
  33. $v_ip = quoteshellarg($ip);
  34. $v_chain = quoteshellarg($chain);
  35. exec(HESTIA_CMD . $cmd . " " . $v_ip . " " . $v_chain, $output, $return_var);
  36. }
  37. header("Location: /list/firewall/banlist");