index.php 1.4 KB

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