index.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. $TAB = 'SERVER';
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. // Check user
  9. if ($_SESSION['user'] != 'admin') {
  10. header("Location: /list/user");
  11. exit;
  12. }
  13. // Get server hostname
  14. $v_hostname = exec('hostname');
  15. // List available timezones and get current one
  16. $v_timezones = list_timezones();
  17. exec (VESTA_CMD."v-get-sys-timezone", $output, $return_var);
  18. $v_timezone = $output[0];
  19. unset($output);
  20. if ($v_timezone == 'Etc/UTC' ) $v_timezone = 'UTC';
  21. if ($v_timezone == 'Pacific/Honolulu' ) $v_timezone = 'HAST';
  22. if ($v_timezone == 'US/Aleutian' ) $v_timezone = 'HADT';
  23. if ($v_timezone == 'Etc/GMT+9' ) $v_timezone = 'AKST';
  24. if ($v_timezone == 'America/Anchorage' ) $v_timezone = 'AKDT';
  25. if ($v_timezone == 'America/Dawson_Creek' ) $v_timezone = 'PST';
  26. if ($v_timezone == 'PST8PDT' ) $v_timezone = 'PDT';
  27. if ($v_timezone == 'MST7MDT' ) $v_timezone = 'MDT';
  28. if ($v_timezone == 'Canada/Saskatchewan' ) $v_timezone = 'CST';
  29. if ($v_timezone == 'CST6CDT' ) $v_timezone = 'CDT';
  30. if ($v_timezone == 'EST5EDT' ) $v_timezone = 'EDT';
  31. if ($v_timezone == 'America/Puerto_Rico' ) $v_timezone = 'AST';
  32. if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT';
  33. // List supported languages
  34. exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var);
  35. $languages = json_decode(implode('', $output), true);
  36. unset($output);
  37. // List backup settings
  38. $v_backup_dir = "/backup";
  39. if (!empty($_SESSION['BACKUP'])) $v_backup_dir = $_SESSION['BACKUP'];
  40. $v_backup_gzip = '5';
  41. if (!empty($_SESSION['BACKUP_GZIP'])) $v_backup_gzip = $_SESSION['BACKUP_GZIP'];
  42. $backup_types = split(",",$_SESSION['BACKUP_SYSTEM']);
  43. foreach ($backup_types as $backup_type) {
  44. if ($backup_type == 'local') {
  45. $v_backup = 'yes';
  46. } else {
  47. exec (VESTA_CMD."v-list-backup-host ".$backup_type. " json", $output, $return_var);
  48. $v_remote_backup = json_decode(implode('', $output), true);
  49. unset($output);
  50. $v_backup_host = $v_remote_backup[$backup_type]['HOST'];
  51. $v_backup_type = $v_remote_backup[$backup_type]['TYPE'];
  52. $v_backup_username = $v_remote_backup[$backup_type]['USERNAME'];
  53. $v_backup_password = "••••••••";
  54. $v_backup_port = $v_remote_backup[$backup_type]['PORT'];
  55. $v_backup_bpath = $v_remote_backup[$backup_type]['BPATH'];
  56. }
  57. }
  58. // Check POST request
  59. if (!empty($_POST['save'])) {
  60. // Change hostname
  61. if ((!empty($_POST['v_hostname'])) && ($v_hostname != $_POST['v_hostname'])) {
  62. exec (VESTA_CMD."v-change-sys-hostname ".escapeshellarg($_POST['v_hostname']), $output, $return_var);
  63. check_return_code($return_var,$output);
  64. unset($output);
  65. $v_hostname = $_POST['v_hostname'];
  66. }
  67. // Change timezone
  68. if (empty($_SESSION['error_msg'])) {
  69. if (!empty($_POST['v_timezone'])) {
  70. $v_tz = $_POST['v_timezone'];
  71. if ($v_tz == 'UTC' ) $v_tz = 'Etc/UTC';
  72. if ($v_tz == 'HAST' ) $v_tz = 'Pacific/Honolulu';
  73. if ($v_tz == 'HADT' ) $v_tz = 'US/Aleutian';
  74. if ($v_tz == 'AKST' ) $v_tz = 'Etc/GMT+9';
  75. if ($v_tz == 'AKDT' ) $v_tz = 'America/Anchorage';
  76. if ($v_tz == 'PST' ) $v_tz = 'America/Dawson_Creek';
  77. if ($v_tz == 'PDT' ) $v_tz = 'PST8PDT';
  78. if ($v_tz == 'MDT' ) $v_tz = 'MST7MDT';
  79. if ($v_tz == 'CST' ) $v_tz = 'Canada/Saskatchewan';
  80. if ($v_tz == 'CDT' ) $v_tz = 'CST6CDT';
  81. if ($v_tz == 'EDT' ) $v_tz = 'EST5EDT';
  82. if ($v_tz == 'AST' ) $v_tz = 'America/Puerto_Rico';
  83. if ($v_tz == 'ADT' ) $v_tz = 'America/Halifax';
  84. if ($v_timezone != $v_tz) {
  85. exec (VESTA_CMD."v-change-sys-timezone ".escapeshellarg($v_tz), $output, $return_var);
  86. check_return_code($return_var,$output);
  87. $v_timezone = $v_tz;
  88. unset($output);
  89. }
  90. }
  91. }
  92. // Change default language
  93. if (empty($_SESSION['error_msg'])) {
  94. if ((!empty($_POST['v_language'])) && ($_SESSION['LANGUAGE'] != $_POST['v_language'])) {
  95. exec (VESTA_CMD."v-change-sys-language ".escapeshellarg($_POST['v_language']), $output, $return_var);
  96. check_return_code($return_var,$output);
  97. unset($output);
  98. if (empty($_SESSION['error_msg'])) $_SESSION['LANGUAGE'] = $_POST['v_language'];
  99. }
  100. }
  101. // Set disk_quota support
  102. if (empty($_SESSION['error_msg'])) {
  103. if ((!empty($_POST['v_quota'])) && ($_SESSION['DISK_QUOTA'] != $_POST['v_quota'])) {
  104. if($_POST['v_quota'] == 'yes') {
  105. exec (VESTA_CMD."v-add-sys-quota", $output, $return_var);
  106. check_return_code($return_var,$output);
  107. unset($output);
  108. if (empty($_SESSION['error_msg'])) $_SESSION['DISK_QUOTA'] = 'yes';
  109. } else {
  110. exec (VESTA_CMD."v-delete-sys-quota", $output, $return_var);
  111. check_return_code($return_var,$output);
  112. unset($output);
  113. if (empty($_SESSION['error_msg'])) $_SESSION['DISK_QUOTA'] = 'no';
  114. }
  115. }
  116. }
  117. // Disable local backup
  118. if (empty($_SESSION['error_msg'])) {
  119. if (($_POST['v_backup'] == 'no') && ($v_backup == 'yes' )) {
  120. exec (VESTA_CMD."v-delete-backup-quota", $output, $return_var);
  121. check_return_code($return_var,$output);
  122. unset($output);
  123. }
  124. }
  125. // Flush field values on success
  126. if (empty($_SESSION['error_msg'])) {
  127. $_SESSION['ok_msg'] = __('Changes has been saved.');
  128. }
  129. }
  130. // Header
  131. include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
  132. // Panel
  133. top_panel($user,$TAB);
  134. // Display body
  135. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_server.html');
  136. // Flush session messages
  137. unset($_SESSION['error_msg']);
  138. unset($_SESSION['ok_msg']);
  139. // Footer
  140. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');