| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- // Init
- error_reporting(NULL);
- ob_start();
- session_start();
- $TAB = 'SERVER';
- include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
- // Check user
- if ($_SESSION['user'] != 'admin') {
- header("Location: /list/user");
- exit;
- }
- // Get server hostname
- $v_hostname = exec('hostname');
- // List available timezones and get current one
- $v_timezones = list_timezones();
- exec (VESTA_CMD."v-get-sys-timezone", $output, $return_var);
- $v_timezone = $output[0];
- unset($output);
- if ($v_timezone == 'Etc/UTC' ) $v_timezone = 'UTC';
- if ($v_timezone == 'Pacific/Honolulu' ) $v_timezone = 'HAST';
- if ($v_timezone == 'US/Aleutian' ) $v_timezone = 'HADT';
- if ($v_timezone == 'Etc/GMT+9' ) $v_timezone = 'AKST';
- if ($v_timezone == 'America/Anchorage' ) $v_timezone = 'AKDT';
- if ($v_timezone == 'America/Dawson_Creek' ) $v_timezone = 'PST';
- if ($v_timezone == 'PST8PDT' ) $v_timezone = 'PDT';
- if ($v_timezone == 'MST7MDT' ) $v_timezone = 'MDT';
- if ($v_timezone == 'Canada/Saskatchewan' ) $v_timezone = 'CST';
- if ($v_timezone == 'CST6CDT' ) $v_timezone = 'CDT';
- if ($v_timezone == 'EST5EDT' ) $v_timezone = 'EDT';
- if ($v_timezone == 'America/Puerto_Rico' ) $v_timezone = 'AST';
- if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT';
- // List supported languages
- exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var);
- $languages = json_decode(implode('', $output), true);
- unset($output);
- // List backup settings
- $v_backup_dir = "/backup";
- if (!empty($_SESSION['BACKUP'])) $v_backup_dir = $_SESSION['BACKUP'];
- $v_backup_gzip = '5';
- if (!empty($_SESSION['BACKUP_GZIP'])) $v_backup_gzip = $_SESSION['BACKUP_GZIP'];
- $backup_types = split(",",$_SESSION['BACKUP_SYSTEM']);
- foreach ($backup_types as $backup_type) {
- if ($backup_type == 'local') {
- $v_backup = 'yes';
- } else {
- exec (VESTA_CMD."v-list-backup-host ".$backup_type. " json", $output, $return_var);
- $v_remote_backup = json_decode(implode('', $output), true);
- unset($output);
- $v_backup_host = $v_remote_backup[$backup_type]['HOST'];
- $v_backup_type = $v_remote_backup[$backup_type]['TYPE'];
- $v_backup_username = $v_remote_backup[$backup_type]['USERNAME'];
- $v_backup_password = "••••••••";
- $v_backup_port = $v_remote_backup[$backup_type]['PORT'];
- $v_backup_bpath = $v_remote_backup[$backup_type]['BPATH'];
- }
- }
- // Check POST request
- if (!empty($_POST['save'])) {
- // Change hostname
- if ((!empty($_POST['v_hostname'])) && ($v_hostname != $_POST['v_hostname'])) {
- exec (VESTA_CMD."v-change-sys-hostname ".escapeshellarg($_POST['v_hostname']), $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- $v_hostname = $_POST['v_hostname'];
- }
- // Change timezone
- if (empty($_SESSION['error_msg'])) {
- if (!empty($_POST['v_timezone'])) {
- $v_tz = $_POST['v_timezone'];
- if ($v_tz == 'UTC' ) $v_tz = 'Etc/UTC';
- if ($v_tz == 'HAST' ) $v_tz = 'Pacific/Honolulu';
- if ($v_tz == 'HADT' ) $v_tz = 'US/Aleutian';
- if ($v_tz == 'AKST' ) $v_tz = 'Etc/GMT+9';
- if ($v_tz == 'AKDT' ) $v_tz = 'America/Anchorage';
- if ($v_tz == 'PST' ) $v_tz = 'America/Dawson_Creek';
- if ($v_tz == 'PDT' ) $v_tz = 'PST8PDT';
- if ($v_tz == 'MDT' ) $v_tz = 'MST7MDT';
- if ($v_tz == 'CST' ) $v_tz = 'Canada/Saskatchewan';
- if ($v_tz == 'CDT' ) $v_tz = 'CST6CDT';
- if ($v_tz == 'EDT' ) $v_tz = 'EST5EDT';
- if ($v_tz == 'AST' ) $v_tz = 'America/Puerto_Rico';
- if ($v_tz == 'ADT' ) $v_tz = 'America/Halifax';
- if ($v_timezone != $v_tz) {
- exec (VESTA_CMD."v-change-sys-timezone ".escapeshellarg($v_tz), $output, $return_var);
- check_return_code($return_var,$output);
- $v_timezone = $v_tz;
- unset($output);
- }
- }
- }
- // Change default language
- if (empty($_SESSION['error_msg'])) {
- if ((!empty($_POST['v_language'])) && ($_SESSION['LANGUAGE'] != $_POST['v_language'])) {
- exec (VESTA_CMD."v-change-sys-language ".escapeshellarg($_POST['v_language']), $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- if (empty($_SESSION['error_msg'])) $_SESSION['LANGUAGE'] = $_POST['v_language'];
- }
- }
- // Set disk_quota support
- if (empty($_SESSION['error_msg'])) {
- if ((!empty($_POST['v_quota'])) && ($_SESSION['DISK_QUOTA'] != $_POST['v_quota'])) {
- if($_POST['v_quota'] == 'yes') {
- exec (VESTA_CMD."v-add-sys-quota", $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- if (empty($_SESSION['error_msg'])) $_SESSION['DISK_QUOTA'] = 'yes';
- } else {
- exec (VESTA_CMD."v-delete-sys-quota", $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- if (empty($_SESSION['error_msg'])) $_SESSION['DISK_QUOTA'] = 'no';
- }
- }
- }
- // Disable local backup
- if (empty($_SESSION['error_msg'])) {
- if (($_POST['v_backup'] == 'no') && ($v_backup == 'yes' )) {
- exec (VESTA_CMD."v-delete-backup-quota", $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- }
- }
- // Flush field values on success
- if (empty($_SESSION['error_msg'])) {
- $_SESSION['ok_msg'] = __('Changes has been saved.');
- }
- }
- // Header
- include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
- // Panel
- top_panel($user,$TAB);
- // Display body
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_server.html');
- // Flush session messages
- unset($_SESSION['error_msg']);
- unset($_SESSION['ok_msg']);
- // Footer
- include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
|