index.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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"] = _(
  57. "Task has been added to the queue. You will receive an email notification when your restore has been completed.",
  58. );
  59. } else {
  60. $_SESSION["error_msg"] = implode("<br>", $output);
  61. if (empty($_SESSION["error_msg"])) {
  62. $_SESSION["error_msg"] = _("Error: Hestia did not return any output.");
  63. }
  64. if ($return_var == 4) {
  65. $_SESSION["error_msg"] = _(
  66. "An existing restoration task is already running. Please wait for it to finish before launching it again.",
  67. );
  68. }
  69. }
  70. header("Location: /list/backup/?backup=" . $_GET["backup"]);