index.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
  9. header('location: /login/');
  10. exit();
  11. }
  12. $action = $_POST['action'];
  13. $backup = escapeshellarg($_POST['backup']);
  14. $web = 'no';
  15. $dns = 'no';
  16. $mail = 'no';
  17. $db = 'no';
  18. $cron = 'no';
  19. $udir = 'no';
  20. if (!empty($_POST['web'])) $web = escapeshellarg(implode(",",$_POST['web']));
  21. if (!empty($_POST['dns'])) $dns = escapeshellarg(implode(",",$_POST['dns']));
  22. if (!empty($_POST['mail'])) $mail = escapeshellarg(implode(",",$_POST['mail']));
  23. if (!empty($_POST['db'])) $db = escapeshellarg(implode(",",$_POST['db']));
  24. if (!empty($_POST['cron'])) $cron = 'yes';
  25. if (!empty($_POST['udir'])) $udir = escapeshellarg(implode(",",$_POST['udir']));
  26. if ($action == 'restore') {
  27. exec (VESTA_CMD."v-schedule-user-restore ".$user." ".$backup." ".$web." ".$dns." ".$mail." ".$db." ".$cron." ".$udir, $output, $return_var);
  28. if ($return_var == 0) {
  29. $_SESSION['error_msg'] = __('RESTORE_SCHEDULED');
  30. } else {
  31. $_SESSION['error_msg'] = implode('<br>', $output);
  32. if (empty($_SESSION['error_msg'])) {
  33. $_SESSION['error_msg'] = __('Error: vesta did not return any output.');
  34. }
  35. if ($return_var == 4) {
  36. $_SESSION['error_msg'] = __('RESTORE_EXISTS');
  37. }
  38. }
  39. }
  40. header("Location: /list/backup/?backup=" . $_POST['backup']);