index.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $action = $_POST["action"];
  8. $backup = quoteshellarg($_POST["backup"]);
  9. $web = "no";
  10. $dns = "no";
  11. $mail = "no";
  12. $db = "no";
  13. $cron = "no";
  14. $udir = "no";
  15. if (!empty($_POST["web"])) {
  16. $web = quoteshellarg(implode(",", $_POST["web"]));
  17. }
  18. if (!empty($_POST["dns"])) {
  19. $dns = quoteshellarg(implode(",", $_POST["dns"]));
  20. }
  21. if (!empty($_POST["mail"])) {
  22. $mail = quoteshellarg(implode(",", $_POST["mail"]));
  23. }
  24. if (!empty($_POST["db"])) {
  25. $db = quoteshellarg(implode(",", $_POST["db"]));
  26. }
  27. if (!empty($_POST["cron"])) {
  28. $cron = "yes";
  29. }
  30. if (!empty($_POST["udir"])) {
  31. $udir = quoteshellarg(implode(",", $_POST["udir"]));
  32. }
  33. if ($action == "restore") {
  34. exec(
  35. HESTIA_CMD .
  36. "v-schedule-user-restore " .
  37. $user .
  38. " " .
  39. $backup .
  40. " " .
  41. $web .
  42. " " .
  43. $dns .
  44. " " .
  45. $mail .
  46. " " .
  47. $db .
  48. " " .
  49. $cron .
  50. " " .
  51. $udir,
  52. $output,
  53. $return_var,
  54. );
  55. if ($return_var == 0) {
  56. $_SESSION["error_msg"] = _("RESTORE_SCHEDULED");
  57. } else {
  58. $_SESSION["error_msg"] = implode("<br>", $output);
  59. if (empty($_SESSION["error_msg"])) {
  60. $_SESSION["error_msg"] = _("Error: Hestia did not return any output.");
  61. }
  62. if ($return_var == 4) {
  63. $_SESSION["error_msg"] = _("RESTORE_EXISTS");
  64. }
  65. }
  66. }
  67. header("Location: /list/backup/?backup=" . $_POST["backup"]);