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($_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"] = _(
  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. }
  71. header("Location: /list/backup/?backup=" . $_POST["backup"]);