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($_GET);
  7. $backup = quoteshellarg($_GET["backup"]);
  8. $web = "no";
  9. $dns = "no";
  10. $mail = "no";
  11. $db = "no";
  12. $cron = "no";
  13. $udir = "no";
  14. if ($_GET["type"] == "web") {
  15. $web = quoteshellarg($_GET["object"]);
  16. }
  17. if ($_GET["type"] == "dns") {
  18. $dns = quoteshellarg($_GET["object"]);
  19. }
  20. if ($_GET["type"] == "mail") {
  21. $mail = quoteshellarg($_GET["object"]);
  22. }
  23. if ($_GET["type"] == "db") {
  24. $db = quoteshellarg($_GET["object"]);
  25. }
  26. if ($_GET["type"] == "cron") {
  27. $cron = "yes";
  28. }
  29. if ($_GET["type"] == "udir") {
  30. $udir = quoteshellarg($_GET["object"]);
  31. }
  32. if (!empty($_GET["type"])) {
  33. $restore_cmd =
  34. HESTIA_CMD .
  35. "v-schedule-user-restore " .
  36. $user .
  37. " " .
  38. $backup .
  39. " " .
  40. $web .
  41. " " .
  42. $dns .
  43. " " .
  44. $mail .
  45. " " .
  46. $db .
  47. " " .
  48. $cron .
  49. " " .
  50. $udir;
  51. } else {
  52. $restore_cmd = HESTIA_CMD . "v-schedule-user-restore " . $user . " " . $backup;
  53. }
  54. exec($restore_cmd, $output, $return_var);
  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. header("Location: /list/backup/?backup=" . $_GET["backup"]);