index.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. $snapshot = quoteshellarg($_POST["snapshot"]);
  9. $web = [];
  10. $dns = [];
  11. $mail = [];
  12. $db = [];
  13. $cron = [];
  14. $udir = [];
  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["file"])) {
  31. $udir = quoteshellarg(implode(",", $_POST["file"]));
  32. }
  33. if ($action == "restore") {
  34. if (!empty($web)) {
  35. exec(
  36. HESTIA_CMD .
  37. "v-schedule-user-restore-restic " .
  38. $user .
  39. " " .
  40. $snapshot .
  41. " " .
  42. "web" .
  43. " " .
  44. $web,
  45. $output,
  46. $return_var,
  47. );
  48. }
  49. if (!empty($dns)) {
  50. exec(
  51. HESTIA_CMD .
  52. "v-schedule-user-restore-restic " .
  53. $user .
  54. " " .
  55. $snapshot .
  56. " " .
  57. "dns" .
  58. " " .
  59. $dns,
  60. $output,
  61. $return_var,
  62. );
  63. }
  64. if (!empty($mail)) {
  65. exec(
  66. HESTIA_CMD .
  67. "v-schedule-user-restore-restic " .
  68. $user .
  69. " " .
  70. $snapshot .
  71. " " .
  72. "db" .
  73. " " .
  74. $db,
  75. $output,
  76. $return_var,
  77. );
  78. if (!empty($dns)) {
  79. exec(
  80. HESTIA_CMD .
  81. "v-schedule-user-restore-restic " .
  82. $user .
  83. " " .
  84. $snapshot .
  85. " " .
  86. "dns" .
  87. " " .
  88. $dns,
  89. $output,
  90. $return_var,
  91. );
  92. }
  93. }
  94. if (!empty($cron)) {
  95. exec(
  96. HESTIA_CMD . "v-schedule-user-restore-restic " . $user . " " . $snapshot . " " . "cron",
  97. $output,
  98. $return_var,
  99. );
  100. }
  101. if (!empty($file)) {
  102. exec(
  103. HESTIA_CMD .
  104. "v-schedule-user-restore-restic " .
  105. $user .
  106. " " .
  107. $snapshot .
  108. " " .
  109. "file" .
  110. $file,
  111. $output,
  112. $return_var,
  113. );
  114. }
  115. }
  116. if ($return_var == 0) {
  117. $_SESSION["error_msg"] = _(
  118. "Task has been added to the queue. You will receive an email notification when your restore has been completed.",
  119. );
  120. } else {
  121. $_SESSION["error_msg"] = implode("<br>", $output);
  122. }
  123. var_dump($_POST);
  124. var_dump($output);
  125. header("Location: /list/backup/incremental/?snapshot=" . $_POST["snapshot"]);