index.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  7. // Check token
  8. if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
  9. header('Location: /login/');
  10. exit();
  11. }
  12. $backup = escapeshellarg($_GET['backup']);
  13. $web = 'no';
  14. $dns = 'no';
  15. $mail = 'no';
  16. $db = 'no';
  17. $cron = 'no';
  18. $udir = 'no';
  19. if ($_GET['type'] == 'web') $web = escapeshellarg($_GET['object']);
  20. if ($_GET['type'] == 'dns') $dns = escapeshellarg($_GET['object']);
  21. if ($_GET['type'] == 'mail') $mail = escapeshellarg($_GET['object']);
  22. if ($_GET['type'] == 'db') $db = escapeshellarg($_GET['object']);
  23. if ($_GET['type'] == 'cron') $cron = 'yes';
  24. if ($_GET['type'] == 'udir') $udir = escapeshellarg($_GET['object']);
  25. if (!empty($_GET['type'])) {
  26. $restore_cmd = HESTIA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir;
  27. } else {
  28. $restore_cmd = HESTIA_CMD."v-schedule-user-restore ".$user." ".$backup;
  29. }
  30. exec ($restore_cmd, $output, $return_var);
  31. if ($return_var == 0) {
  32. $_SESSION['error_msg'] = __('RESTORE_SCHEDULED');
  33. } else {
  34. $_SESSION['error_msg'] = implode('<br>', $output);
  35. if (empty($_SESSION['error_msg'])) {
  36. $_SESSION['error_msg'] = __('Error: hestia did not return any output.');
  37. }
  38. if ($return_var == 4) {
  39. $_SESSION['error_msg'] = __('RESTORE_EXISTS');
  40. }
  41. }
  42. header("Location: /list/backup/?backup=" . $_GET['backup']);