index.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 = HESTIA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir;
  34. } else {
  35. $restore_cmd = HESTIA_CMD."v-schedule-user-restore ".$user." ".$backup;
  36. }
  37. exec($restore_cmd, $output, $return_var);
  38. if ($return_var == 0) {
  39. $_SESSION['error_msg'] = _('RESTORE_SCHEDULED');
  40. } else {
  41. $_SESSION['error_msg'] = implode('<br>', $output);
  42. if (empty($_SESSION['error_msg'])) {
  43. $_SESSION['error_msg'] = _('Error: Hestia did not return any output.');
  44. }
  45. if ($return_var == 4) {
  46. $_SESSION['error_msg'] = _('RESTORE_EXISTS');
  47. }
  48. }
  49. header("Location: /list/backup/?backup=" . $_GET['backup']);