mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
Updated services and fixed minor bugs.
This commit is contained in:
parent
4306a4fb4f
commit
2a12fec5ea
90 changed files with 1706 additions and 3 deletions
143
web/api/v1/edit/backup/exclusions/index.php
Normal file
143
web/api/v1/edit/backup/exclusions/index.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
// Init
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'BACKUP';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
|
||||
// List backup exclustions
|
||||
exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse web
|
||||
$v_username = $user;
|
||||
foreach ($data['WEB'] as $key => $value) {
|
||||
if (!empty($value)){
|
||||
$v_web .= $key . ":" . $value. "\n";
|
||||
} else {
|
||||
$v_web .= $key . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Parse dns
|
||||
foreach ($data['DNS'] as $key => $value) {
|
||||
if (!empty($value)){
|
||||
$v_dns .= $key . ":" . $value. "\n";
|
||||
} else {
|
||||
$v_dns .= $key . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Parse mail
|
||||
foreach ($data['MAIL'] as $key => $value) {
|
||||
if (!empty($value)){
|
||||
$v_mail .= $key . ":" . $value. "\n";
|
||||
} else {
|
||||
$v_mail .= $key . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Parse databases
|
||||
foreach ($data['DB'] as $key => $value) {
|
||||
if (!empty($value)){
|
||||
$v_db .= $key . ":" . $value. "\n";
|
||||
} else {
|
||||
$v_db .= $key . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Parse user directories
|
||||
foreach ($data['USER'] as $key => $value) {
|
||||
if (!empty($value)){
|
||||
$v_userdir .= $key . ":" . $value. "\n";
|
||||
} else {
|
||||
$v_userdir .= $key . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$v_web = $_POST['v_web'];
|
||||
$v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']);
|
||||
$v_web_tmp = rtrim($v_web_tmp, ",");
|
||||
$v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp);
|
||||
|
||||
$v_dns = $_POST['v_dns'];
|
||||
$v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']);
|
||||
$v_dns_tmp = rtrim($v_dns_tmp, ",");
|
||||
$v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp);
|
||||
|
||||
$v_mail = $_POST['v_mail'];
|
||||
$v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']);
|
||||
$v_mail_tmp = rtrim($v_mail_tmp, ",");
|
||||
$v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp);
|
||||
|
||||
$v_db = $_POST['v_db'];
|
||||
$v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']);
|
||||
$v_db_tmp = rtrim($v_db_tmp, ",");
|
||||
$v_db_tmp = "DB=" . escapeshellarg($v_db_tmp);
|
||||
|
||||
$v_cron = $_POST['v_cron'];
|
||||
$v_cron_tmp = str_replace("\r\n", ",", $_POST['v_cron']);
|
||||
$v_cron_tmp = rtrim($v_cron_tmp, ",");
|
||||
$v_cron_tmp = "CRON=" . escapeshellarg($v_cron_tmp);
|
||||
|
||||
$v_userdir = $_POST['v_userdir'];
|
||||
$v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']);
|
||||
$v_userdir_tmp = rtrim($v_userdir_tmp, ",");
|
||||
$v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp);
|
||||
|
||||
// Create temporary exeption list on a filesystem
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$tmp = $mktemp_output[0];
|
||||
$fp = fopen($tmp, 'w');
|
||||
fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n");
|
||||
fclose($fp);
|
||||
unset($mktemp_output);
|
||||
|
||||
// Save changes
|
||||
exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __("Changes has been saved.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'edit_backup_exclusions');
|
||||
|
||||
$result = array(
|
||||
'web' => $v_web,
|
||||
'dns' => $v_dns,
|
||||
'mail' => $v_mail,
|
||||
'db' => $v_db,
|
||||
'userdir' => $v_userdir,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
82
web/api/v1/edit/server/bind9/index.php
Normal file
82
web/api/v1/edit/server/bind9/index.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update options
|
||||
if (!empty($_POST['v_options'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_options']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." bind9-opt ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." bind9 ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_options_path = '/etc/bind/named.conf.options';
|
||||
$v_config_path = '/etc/bind/named.conf';
|
||||
$v_service_name = strtoupper('bind9');
|
||||
|
||||
// Read config
|
||||
$v_options = shell_exec(VESTA_CMD."v-open-fs-config ".$v_options_path);
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'options_path' => $v_options_path,
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'options' => $v_options,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
65
web/api/v1/edit/server/clamd/index.php
Normal file
65
web/api/v1/edit/server/clamd/index.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." clamd ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = shell_exec(VESTA_CMD.'v-list-sys-clamd-config plain');
|
||||
$v_service_name = strtoupper('clamav');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
206
web/api/v1/edit/server/dovecot/index.php
Normal file
206
web/api/v1/edit/server/dovecot/index.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config1
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config1']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config1']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-1 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config2
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config2']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config2']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-2 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config3
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config3']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config3']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-3 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config4
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config4']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config4']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-4 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config5
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config5']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config5']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-5 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config6
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config6']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config6']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-6 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config7
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config7']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config7']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-7 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config8
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config8']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config8']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." dovecot-8 " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-dovecot-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
$v_config_path1 = $data['CONFIG']['config_path1'];
|
||||
$v_config_path2 = $data['CONFIG']['config_path2'];
|
||||
$v_config_path3 = $data['CONFIG']['config_path3'];
|
||||
$v_config_path4 = $data['CONFIG']['config_path4'];
|
||||
$v_config_path5 = $data['CONFIG']['config_path5'];
|
||||
$v_config_path6 = $data['CONFIG']['config_path6'];
|
||||
$v_config_path7 = $data['CONFIG']['config_path7'];
|
||||
$v_config_path8 = $data['CONFIG']['config_path8'];
|
||||
$v_service_name = strtoupper('dovecot');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
if (!empty($v_config_path1)) $v_config1 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path1);
|
||||
if (!empty($v_config_path2)) $v_config2 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path2);
|
||||
if (!empty($v_config_path3)) $v_config3 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path3);
|
||||
if (!empty($v_config_path4)) $v_config4 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path4);
|
||||
if (!empty($v_config_path5)) $v_config5 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path5);
|
||||
if (!empty($v_config_path6)) $v_config6 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path6);
|
||||
if (!empty($v_config_path7)) $v_config7 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path7);
|
||||
if (!empty($v_config_path8)) $v_config8 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path8);
|
||||
|
||||
$result = array(
|
||||
'config_path' => $v_config_path,
|
||||
'config_path1' => $v_config_path1,
|
||||
'config_path2' => $v_config_path2,
|
||||
'config_path3' => $v_config_path3,
|
||||
'config_path4' => $v_config_path4,
|
||||
'config_path5' => $v_config_path5,
|
||||
'config_path6' => $v_config_path6,
|
||||
'config_path7' => $v_config_path7,
|
||||
'config_path8' => $v_config_path8,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $config,
|
||||
'config1' => $config1,
|
||||
'config2' => $config2,
|
||||
'config3' => $config3,
|
||||
'config4' => $config4,
|
||||
'config5' => $config5,
|
||||
'config6' => $config6,
|
||||
'config7' => $config7,
|
||||
'config8' => $config8,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
65
web/api/v1/edit/server/exim4/index.php
Normal file
65
web/api/v1/edit/server/exim4/index.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." exim4 ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = '/etc/exim4/exim4.conf.template';
|
||||
$v_service_name = strtoupper('exim');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
64
web/api/v1/edit/server/httpd/index.php
Normal file
64
web/api/v1/edit/server/httpd/index.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." httpd ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = '/etc/httpd/conf/httpd.conf';
|
||||
$v_service_name = strtoupper('httpd');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'config_path' => '/etc/httpd/conf/httpd.conf',
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
79
web/api/v1/edit/server/mysqld/index.php
Normal file
79
web/api/v1/edit/server/mysqld/index.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." mysqld ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-mysql-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_max_user_connections = $data['CONFIG']['max_user_connections'];
|
||||
$v_max_connections = $data['CONFIG']['max_connections'];
|
||||
$v_wait_timeout = $data['CONFIG']['wait_timeout'];
|
||||
$v_interactive_timeout = $data['CONFIG']['interactive_timeout'];
|
||||
$v_max_allowed_packet = $data['CONFIG']['max_allowed_packet'];
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
$v_service_name = strtoupper('mysql');
|
||||
|
||||
# Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'max_user_connections' => $v_max_user_connections,
|
||||
'max_connections' => $v_max_connections,
|
||||
'wait_timeout' => $v_wait_timeout,
|
||||
'interactive_timeout' => $v_interactive_timeout,
|
||||
'max_allowed_packet' => $v_max_allowed_packet,
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
65
web/api/v1/edit/server/named/index.php
Normal file
65
web/api/v1/edit/server/named/index.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." named ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = '/etc/named.conf';
|
||||
$v_service_name = strtoupper('named');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'service_name' => $v_service_name,
|
||||
'config_path' => $v_config_path,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
89
web/api/v1/edit/server/nginx/index.php
Normal file
89
web/api/v1/edit/server/nginx/index.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." nginx ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-nginx-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_worker_processes = $data['CONFIG']['worker_processes'];
|
||||
$v_worker_connections = $data['CONFIG']['worker_connections'];
|
||||
$v_send_timeout = $data['CONFIG']['send_timeout'];
|
||||
$v_proxy_connect_timeout = $data['CONFIG']['proxy_connect_timeout'];
|
||||
$v_proxy_send_timeout = $data['CONFIG']['proxy_send_timeout'];
|
||||
$v_proxy_read_timeout = $data['CONFIG']['proxy_read_timeout'];
|
||||
$v_client_max_body_size = $data['CONFIG']['client_max_body_size'];
|
||||
$v_gzip = $data['CONFIG']['gzip'];
|
||||
$v_gzip_comp_level = $data['CONFIG']['gzip_comp_level'];
|
||||
$v_charset = $data['CONFIG']['charset'];
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
$v_service_name = strtoupper('nginx');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'worker_processes' => $data['CONFIG']['worker_processes'],
|
||||
'worker_connections' => $data['CONFIG']['worker_connections'],
|
||||
'send_timeout' => $data['CONFIG']['send_timeout'],
|
||||
'proxy_connect_timeout' => $data['CONFIG']['proxy_connect_timeout'],
|
||||
'proxy_send_timeout' => $data['CONFIG']['proxy_send_timeout'],
|
||||
'proxy_read_timeout' => $data['CONFIG']['proxy_read_timeout'],
|
||||
'client_max_body_size' => $data['CONFIG']['client_max_body_size'],
|
||||
'gzip' => $data['CONFIG']['gzip'],
|
||||
'gzip_comp_level' => $data['CONFIG']['gzip_comp_level'],
|
||||
'charset' => $data['CONFIG']['charset'],
|
||||
'config_path' => $data['CONFIG']['config_path'],
|
||||
'service_name' => strtoupper('nginx'),
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
82
web/api/v1/edit/server/php-fpm/index.php
Normal file
82
web/api/v1/edit/server/php-fpm/index.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." php ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-php-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_memory_limit = $data['CONFIG']['memory_limit'];
|
||||
$v_max_execution_time = $data['CONFIG']['max_execution_time'];
|
||||
$v_max_input_time = $data['CONFIG']['max_input_time'];
|
||||
$v_upload_max_filesize = $data['CONFIG']['upload_max_filesize'];
|
||||
$v_post_max_size = $data['CONFIG']['post_max_size'];
|
||||
$v_display_errors = $data['CONFIG']['display_errors'];
|
||||
$v_error_reporting = $data['CONFIG']['error_reporting'];
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
|
||||
# Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'memory_limit' => $data['CONFIG']['memory_limit'],
|
||||
'max_execution_time' => $data['CONFIG']['max_execution_time'],
|
||||
'max_input_time' => $data['CONFIG']['max_input_time'],
|
||||
'upload_max_filesize' => $data['CONFIG']['upload_max_filesize'],
|
||||
'post_max_size' => $data['CONFIG']['post_max_size'],
|
||||
'display_errors' => $data['CONFIG']['display_errors'],
|
||||
'error_reporting' => $data['CONFIG']['error_reporting'],
|
||||
'config_path' => $data['CONFIG']['config_path'],
|
||||
'web_system' => $_SESSION['WEB_SYSTEM'],
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
82
web/api/v1/edit/server/php5-fpm/index.php
Normal file
82
web/api/v1/edit/server/php5-fpm/index.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." php ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-php-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_memory_limit = $data['CONFIG']['memory_limit'];
|
||||
$v_max_execution_time = $data['CONFIG']['max_execution_time'];
|
||||
$v_max_input_time = $data['CONFIG']['max_input_time'];
|
||||
$v_upload_max_filesize = $data['CONFIG']['upload_max_filesize'];
|
||||
$v_post_max_size = $data['CONFIG']['post_max_size'];
|
||||
$v_display_errors = $data['CONFIG']['display_errors'];
|
||||
$v_error_reporting = $data['CONFIG']['error_reporting'];
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
|
||||
# Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'memory_limit' => $data['CONFIG']['memory_limit'],
|
||||
'max_execution_time' => $data['CONFIG']['max_execution_time'],
|
||||
'max_input_time' => $data['CONFIG']['max_input_time'],
|
||||
'upload_max_filesize' => $data['CONFIG']['upload_max_filesize'],
|
||||
'post_max_size' => $data['CONFIG']['post_max_size'],
|
||||
'display_errors' => $data['CONFIG']['display_errors'],
|
||||
'error_reporting' => $data['CONFIG']['error_reporting'],
|
||||
'config_path' => $data['CONFIG']['config_path'],
|
||||
'web_system' => $_SESSION['WEB_SYSTEM'],
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
87
web/api/v1/edit/server/postgresql/index.php
Normal file
87
web/api/v1/edit/server/postgresql/index.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update option
|
||||
if (!empty($_POST['v_options'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_options']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." postgresql-hba ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Update config
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config']))) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($new_conf);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." postgresql " .$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List config
|
||||
exec (VESTA_CMD."v-list-sys-pgsql-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
$v_options_path = $data['CONFIG']['pg_hba_path'];
|
||||
$v_config_path = $data['CONFIG']['config_path'];
|
||||
$v_service_name = strtoupper('postgresql');
|
||||
|
||||
// Read config
|
||||
$v_options = shell_exec(VESTA_CMD."v-open-fs-config ".$v_options_path);
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'options_path' => $v_options_path,
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'options' => $v_options,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
65
web/api/v1/edit/server/spamassassin/index.php
Normal file
65
web/api/v1/edit/server/spamassassin/index.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." spamassassin ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = shell_exec(VESTA_CMD.'v-list-sys-spamd-config plain');
|
||||
$v_service_name = strtoupper('spamassassin');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
65
web/api/v1/edit/server/spamd/index.php
Normal file
65
web/api/v1/edit/server/spamd/index.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = 'yes';
|
||||
if (empty($_POST['v_restart'])) $v_restart = 'no';
|
||||
|
||||
// Update config
|
||||
if (!empty($_POST['v_config'])) {
|
||||
exec ('mktemp', $mktemp_output, $return_var);
|
||||
$new_conf = $mktemp_output[0];
|
||||
$fp = fopen($new_conf, 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." spamd ".$v_restart, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v_config_path = shell_exec(VESTA_CMD.'v-list-sys-spamd-config plain');
|
||||
$v_service_name = strtoupper('spamassassin');
|
||||
|
||||
// Read config
|
||||
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
|
||||
|
||||
$result = array(
|
||||
'config_path' => $v_config_path,
|
||||
'service_name' => $v_service_name,
|
||||
'config' => $v_config,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
Loading…
Add table
Add a link
Reference in a new issue