index.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. $TAB = 'BACKUP EXCLUSIONS';
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. // Header
  9. include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
  10. // Panel
  11. top_panel($user,$TAB);
  12. // Edit as someone else?
  13. if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
  14. $user=escapeshellarg($_GET['user']);
  15. }
  16. exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." 'json'", $output, $return_var);
  17. check_return_code($return_var,$output);
  18. if (empty($_SESSION['error_msg'])) {
  19. $data = json_decode(implode('', $output), true);
  20. unset($output);
  21. $v_username = $user;
  22. foreach ($data['WEB'] as $key => $value) {
  23. if (!empty($value)){
  24. $v_web .= $key . ":" . $value. "\n";
  25. } else {
  26. $v_web .= $key . "\n";
  27. }
  28. }
  29. foreach ($data['DNS'] as $key => $value) {
  30. if (!empty($value)){
  31. $v_dns .= $key . ":" . $value. "\n";
  32. } else {
  33. $v_dns .= $key . "\n";
  34. }
  35. }
  36. foreach ($data['MAIL'] as $key => $value) {
  37. if (!empty($value)){
  38. $v_mail .= $key . ":" . $value. "\n";
  39. } else {
  40. $v_mail .= $key . "\n";
  41. }
  42. }
  43. foreach ($data['DB'] as $key => $value) {
  44. if (!empty($value)){
  45. $v_db .= $key . ":" . $value. "\n";
  46. } else {
  47. $v_db .= $key . "\n";
  48. }
  49. }
  50. foreach ($data['USER'] as $key => $value) {
  51. if (!empty($value)){
  52. $v_userdir .= $key . ":" . $value. "\n";
  53. } else {
  54. $v_userdir .= $key . "\n";
  55. }
  56. }
  57. // Action
  58. if (!empty($_POST['save'])) {
  59. $v_web = $_POST['v_web'];
  60. $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']);
  61. $v_web_tmp = rtrim($v_web_tmp, ",");
  62. $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp);
  63. $v_dns = $_POST['v_dns'];
  64. $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']);
  65. $v_dns_tmp = rtrim($v_dns_tmp, ",");
  66. $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp);
  67. $v_mail = $_POST['v_mail'];
  68. $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']);
  69. $v_mail_tmp = rtrim($v_mail_tmp, ",");
  70. $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp);
  71. $v_db = $_POST['v_db'];
  72. $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']);
  73. $v_db_tmp = rtrim($v_db_tmp, ",");
  74. $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp);
  75. $v_cron = $_POST['v_cron'];
  76. $v_cron_tmp = str_replace("\r\n", ",", $_POST['v_cron']);
  77. $v_cron_tmp = rtrim($v_cron_tmp, ",");
  78. $v_cron_tmp = "CRON=" . escapeshellarg($v_cron_tmp);
  79. $v_userdir = $_POST['v_userdir'];
  80. $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']);
  81. $v_userdir_tmp = rtrim($v_userdir_tmp, ",");
  82. $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp);
  83. exec ('mktemp', $mktemp_output, $return_var);
  84. $tmp = $mktemp_output[0];
  85. $fp = fopen($tmp, 'w');
  86. fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n");
  87. fclose($fp);
  88. exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var);
  89. check_return_code($return_var,$output);
  90. if (empty($_SESSION['error_msg'])) {
  91. $_SESSION['ok_msg'] = __("Changes has been saved.");
  92. }
  93. }
  94. }
  95. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_backup_exclusions.html');
  96. unset($_SESSION['error_msg']);
  97. unset($_SESSION['ok_msg']);
  98. // Footer
  99. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');