index.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. if (empty($_POST["backup"])) {
  8. header("Location: /list/backup/");
  9. exit();
  10. }
  11. if (empty($_POST["action"])) {
  12. header("Location: /list/backup");
  13. exit();
  14. }
  15. $action = $_POST["action"];
  16. $backup = quoteshellarg($_POST["backup"]);
  17. $web = "no";
  18. $dns = "no";
  19. $mail = "no";
  20. $db = "no";
  21. $cron = "no";
  22. $udir = "no";
  23. if (!empty($_POST["web"])) {
  24. $web = quoteshellarg(implode(",", $_POST["web"]));
  25. }
  26. if (!empty($_POST["dns"])) {
  27. $dns = quoteshellarg(implode(",", $_POST["dns"]));
  28. }
  29. if (!empty($_POST["mail"])) {
  30. $mail = quoteshellarg(implode(",", $_POST["mail"]));
  31. }
  32. if (!empty($_POST["db"])) {
  33. $db = quoteshellarg(implode(",", $_POST["db"]));
  34. }
  35. if (!empty($_POST["cron"])) {
  36. $cron = "yes";
  37. }
  38. if (!empty($_POST["udir"])) {
  39. $udir = quoteshellarg(implode(",", $_POST["udir"]));
  40. }
  41. if ($action == "restore") {
  42. exec(
  43. HESTIA_CMD .
  44. "v-schedule-user-restore " .
  45. $user .
  46. " " .
  47. $backup .
  48. " " .
  49. $web .
  50. " " .
  51. $dns .
  52. " " .
  53. $mail .
  54. " " .
  55. $db .
  56. " " .
  57. $cron .
  58. " " .
  59. $udir,
  60. $output,
  61. $return_var,
  62. );
  63. if ($return_var == 0) {
  64. $_SESSION["error_msg"] = _(
  65. "Task has been added to the queue. You will receive an email notification when your restore has been completed.",
  66. );
  67. } else {
  68. $_SESSION["error_msg"] = implode("<br>", $output);
  69. if (empty($_SESSION["error_msg"])) {
  70. $_SESSION["error_msg"] = _("Error: Hestia did not return any output.");
  71. }
  72. if ($return_var == 4) {
  73. $_SESSION["error_msg"] = _(
  74. "An existing restoration task is already running. Please wait for it to finish before launching it again.",
  75. );
  76. }
  77. }
  78. }
  79. header("Location: /list/backup/?backup=" . $_POST["backup"]);