index.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. header('Content-Type: application/json');
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. $backup = escapeshellarg($_GET['backup']);
  9. $web = 'no';
  10. $dns = 'no';
  11. $mail = 'no';
  12. $db = 'no';
  13. $cron = 'no';
  14. $udir = 'no';
  15. if ($_GET['type'] == 'web') $web = escapeshellarg($_GET['object']);
  16. if ($_GET['type'] == 'dns') $dns = escapeshellarg($_GET['object']);
  17. if ($_GET['type'] == 'mail') $mail = escapeshellarg($_GET['object']);
  18. if ($_GET['type'] == 'db') $db = escapeshellarg($_GET['object']);
  19. if ($_GET['type'] == 'cron') $cron = 'yes';
  20. if ($_GET['type'] == 'udir') $udir = escapeshellarg($_GET['object']);
  21. if (!empty($_GET['type'])) {
  22. $restore_cmd = VESTA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir;
  23. } else {
  24. $restore_cmd = VESTA_CMD."v-schedule-user-restore ".$user." ".$backup;
  25. }
  26. exec ($restore_cmd, $output, $return_var);
  27. if ($return_var == 0) {
  28. $_SESSION['error_msg'] = __('RESTORE_SCHEDULED');
  29. } else {
  30. $_SESSION['error_msg'] = implode('<br>', $output);
  31. if (empty($_SESSION['error_msg'])) {
  32. $_SESSION['error_msg'] = __('Error: vesta did not return any output.');
  33. }
  34. if ($return_var == 4) {
  35. $_SESSION['error_msg'] = __('RESTORE_EXISTS');
  36. }
  37. }
  38. $result = array(
  39. 'ok' => $_SESSION['ok_msg'],
  40. 'error' => $_SESSION['error_msg'],
  41. );
  42. echo json_encode($result);
  43. unset($_SESSION['error_msg']);
  44. unset($_SESSION['ok_msg']);