mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
Integrated new api interface.
This commit is contained in:
parent
4a9bfc94ad
commit
4306a4fb4f
116 changed files with 10371 additions and 0 deletions
102
web/api/v1/edit/cron/index.php
Normal file
102
web/api/v1/edit/cron/index.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
// Init
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
session_start();
|
||||
$TAB = 'CRON';
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
// Check job id
|
||||
if (empty($_GET['job'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// List cron job
|
||||
$v_job = escapeshellarg($_GET['job']);
|
||||
exec (VESTA_CMD."v-list-cron-job ".$user." ".$v_job." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse cron job
|
||||
$v_username = $user;
|
||||
$v_job = $_GET['job'];
|
||||
$v_min = $data[$v_job]['MIN'];
|
||||
$v_hour = $data[$v_job]['HOUR'];
|
||||
$v_day = $data[$v_job]['DAY'];
|
||||
$v_month = $data[$v_job]['MONTH'];
|
||||
$v_wday = $data[$v_job]['WDAY'];
|
||||
$v_cmd = $data[$v_job]['CMD'];
|
||||
$v_date = $data[$v_job]['DATE'];
|
||||
$v_time = $data[$v_job]['TIME'];
|
||||
$v_suspended = $data[$v_job]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$v_username = $user;
|
||||
$v_job = escapeshellarg($_GET['job']);
|
||||
$v_min = escapeshellarg($_POST['v_min']);
|
||||
$v_hour = escapeshellarg($_POST['v_hour']);
|
||||
$v_day = escapeshellarg($_POST['v_day']);
|
||||
$v_month = escapeshellarg($_POST['v_month']);
|
||||
$v_wday = escapeshellarg($_POST['v_wday']);
|
||||
$v_cmd = escapeshellarg($_POST['v_cmd']);
|
||||
|
||||
// Save changes
|
||||
exec (VESTA_CMD."v-change-cron-job ".$v_username." ".$v_job." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
$v_cmd = $_POST['v_cmd'];
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __("Changes has been saved.");
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'edit_cron');
|
||||
|
||||
$result = array(
|
||||
'username' => $user,
|
||||
'job' => $_GET['job'],
|
||||
'min' => $data[$v_job]['MIN'],
|
||||
'hour' => $data[$v_job]['HOUR'],
|
||||
'day' => $data[$v_job]['DAY'],
|
||||
'month' => $data[$v_job]['MONTH'],
|
||||
'wday' => $data[$v_job]['WDAY'],
|
||||
'cmd' => $data[$v_job]['CMD'],
|
||||
'date' => $data[$v_job]['DATE'],
|
||||
'time' => $data[$v_job]['TIME'],
|
||||
'suspended' => $data[$v_job]['SUSPENDED'],
|
||||
'status' => $v_status,
|
||||
'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']);
|
109
web/api/v1/edit/db/index.php
Normal file
109
web/api/v1/edit/db/index.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
// Init
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'DB';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php');
|
||||
|
||||
// Check database id
|
||||
if (empty($_GET['database'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
|
||||
// List datbase
|
||||
$v_database = escapeshellarg($_GET['database']);
|
||||
exec (VESTA_CMD."v-list-database ".$user." ".$v_database." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse database
|
||||
$v_username = $user;
|
||||
$v_database = $_GET['database'];
|
||||
$v_dbuser = $data[$v_database]['DBUSER'];
|
||||
$v_password = "";
|
||||
$v_host = $data[$v_database]['HOST'];
|
||||
$v_type = $data[$v_database]['TYPE'];
|
||||
$v_charset = $data[$v_database]['CHARSET'];
|
||||
$v_date = $data[$v_database]['DATE'];
|
||||
$v_time = $data[$v_database]['TIME'];
|
||||
$v_suspended = $data[$v_database]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
$v_database = escapeshellarg($_GET['database']);
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
$v_username = $user;
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Change database user
|
||||
if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
$v_dbuser = escapeshellarg($v_dbuser);
|
||||
exec (VESTA_CMD."v-change-database-user ".$v_username." ".$v_database." ".$v_dbuser, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_dbuser = $user."_".preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
|
||||
}
|
||||
|
||||
// Change database password
|
||||
if ((!empty($_POST['v_password'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_password, "w");
|
||||
fwrite($fp, $_POST['v_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($v_password);
|
||||
$v_password = escapeshellarg($_POST['v_password']);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'edit_db');
|
||||
|
||||
$result = array(
|
||||
'username' => $user,
|
||||
'database' => $_GET['database'],
|
||||
'dbuser' => $data[$_GET['database']]['DBUSER'],
|
||||
'password' => $_POST['v_password'],
|
||||
'host' => $data[$_GET['database']]['HOST'],
|
||||
'type' => $data[$_GET['database']]['TYPE'],
|
||||
'charset' => $data[$_GET['database']]['CHARSET'],
|
||||
'date' => $data[$_GET['database']]['DATE'],
|
||||
'time' => $data[$_GET['database']]['TIME'],
|
||||
'suspended' => $data[$_GET['database']]['SUSPENDED'],
|
||||
'status' => $v_status,
|
||||
'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']);
|
225
web/api/v1/edit/dns/index.php
Normal file
225
web/api/v1/edit/dns/index.php
Normal file
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'DNS';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check domain name
|
||||
if (empty($_GET['domain'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
|
||||
// List dns domain
|
||||
if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$user." ".$v_domain." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse dns domain
|
||||
$v_username = $user;
|
||||
$v_domain = $_GET['domain'];
|
||||
$v_ip = $data[$v_domain]['IP'];
|
||||
$v_template = $data[$v_domain]['TPL'];
|
||||
$v_ttl = $data[$v_domain]['TTL'];
|
||||
$v_exp = $data[$v_domain]['EXP'];
|
||||
$v_soa = $data[$v_domain]['SOA'];
|
||||
$v_date = $data[$v_domain]['DATE'];
|
||||
$v_time = $data[$v_domain]['TIME'];
|
||||
$v_suspended = $data[$v_domain]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
// List dns templates
|
||||
exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var);
|
||||
$templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// List dns record
|
||||
if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) {
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-list-dns-records ".$user." ".$v_domain." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse dns record
|
||||
$v_username = $user;
|
||||
$v_domain = $_GET['domain'];
|
||||
$v_record_id = $_GET['record_id'];
|
||||
$v_rec = $data[$v_record_id]['RECORD'];
|
||||
$v_type = $data[$v_record_id]['TYPE'];
|
||||
$v_val = $data[$v_record_id]['VALUE'];
|
||||
$v_priority = $data[$v_record_id]['PRIORITY'];
|
||||
$v_suspended = $data[$v_record_id]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
$v_date = $data[$v_record_id]['DATE'];
|
||||
$v_time = $data[$v_record_id]['TIME'];
|
||||
}
|
||||
|
||||
// Check POST request for dns domain
|
||||
if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
|
||||
$v_domain = escapeshellarg($_POST['v_domain']);
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Change domain IP
|
||||
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$restart_dns = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change domain template
|
||||
if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_template = escapeshellarg($_POST['v_template']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-tpl ".$v_username." ".$v_domain." ".$v_template." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
|
||||
// Change SOA record
|
||||
if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_soa = escapeshellarg($_POST['v_soa']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-soa ".$v_username." ".$v_domain." ".$v_soa." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
|
||||
// Change expiriation date
|
||||
if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_exp = escapeshellarg($_POST['v_exp']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-exp ".$v_username." ".$v_domain." ".$v_exp." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change domain ttl
|
||||
if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_ttl = escapeshellarg($_POST['v_ttl']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-ttl ".$v_username." ".$v_domain." ".$v_ttl." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
|
||||
// Restart dns server
|
||||
if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-restart-dns", $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.');
|
||||
}
|
||||
}
|
||||
|
||||
// Check POST request for dns record
|
||||
if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['record_id']))) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Protect input
|
||||
$v_domain = escapeshellarg($_POST['v_domain']);
|
||||
$v_record_id = escapeshellarg($_POST['v_record_id']);
|
||||
|
||||
// Change dns record
|
||||
if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_val = escapeshellarg($_POST['v_val']);
|
||||
$v_priority = escapeshellarg($_POST['v_priority']);
|
||||
exec (VESTA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_val = $_POST['v_val'];
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
|
||||
// Change dns record id
|
||||
if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_old_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-change-dns-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
|
||||
// Restart dns server
|
||||
if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-restart-dns", $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.');
|
||||
}
|
||||
|
||||
// Change url if record id was changed
|
||||
if ((empty($_SESSION['error_msg'])) && ($_GET['record_id'] != $_POST['v_record_id'])) {
|
||||
header("Location: /edit/dns/?domain=".$_GET['domain']."&record_id=".$_POST['v_record_id']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'username' => $user,
|
||||
'domain' => $v_domain,
|
||||
'domain' => $_GET['domain'],
|
||||
'ip' => $data[$v_domain]['IP'],
|
||||
'record_id' => $v_record_id,
|
||||
'rec' => $v_rec,
|
||||
'type' => $v_type,
|
||||
'val' => $v_val,
|
||||
'priority' => $v_priority,
|
||||
'template' => $data[$v_domain]['TPL'],
|
||||
'ttl' => $data[$v_domain]['TTL'],
|
||||
'exp' => $data[$v_domain]['EXP'],
|
||||
'soa' => $data[$v_domain]['SOA'],
|
||||
'date' => $v_date,
|
||||
'time' => $v_time,
|
||||
'suspended' => $v_suspended,
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg'],
|
||||
'status' => $v_status,
|
||||
'dns_system' => $_SESSION['DNS_SYSTEM'],
|
||||
'YYYY-MM-DD' => __('YYYY-MM-DD'),
|
||||
'templates' => $templates
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
51
web/api/v1/edit/file/index.php
Normal file
51
web/api/v1/edit/file/index.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
$user = $_SESSION['user'];
|
||||
|
||||
// Check login_as feature
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
|
||||
$user=$_SESSION['look'];
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST['path'])) {
|
||||
$content = '';
|
||||
$path = $_REQUEST['path'];
|
||||
if (!empty($_POST['save'])) {
|
||||
$fn = tempnam ('/tmp', 'vst-save-file-');
|
||||
if ($fn) {
|
||||
$contents = $_POST['contents'];
|
||||
$contents = preg_replace("/\r/", "", $contents);
|
||||
$f = fopen ($fn, 'w+');
|
||||
fwrite($f, $contents);
|
||||
fclose($f);
|
||||
chmod($fn, 0644);
|
||||
|
||||
if ($f) {
|
||||
exec (VESTA_CMD . "v-copy-fs-file {$user} {$fn} ".escapeshellarg($path), $output, $return_var);
|
||||
$error = check_return_code($return_var, $output);
|
||||
if ($return_var != 0) {
|
||||
$error = 'Error while saving file';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
unlink($fn);
|
||||
}
|
||||
}
|
||||
|
||||
exec (VESTA_CMD . "v-open-fs-file {$user} ".escapeshellarg($path), $content, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = 'Error while opening file'; // todo: handle this more styled
|
||||
exit;
|
||||
}
|
||||
$content = implode("\n", $content)."\n";
|
||||
} else {
|
||||
$content = '';
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'error' => $error,
|
||||
'content' => $content
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
103
web/api/v1/edit/firewall/index.php
Normal file
103
web/api/v1/edit/firewall/index.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'FIREWALL';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check ip argument
|
||||
if (empty($_GET['rule'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// List rule
|
||||
$v_rule = escapeshellarg($_GET['rule']);
|
||||
exec (VESTA_CMD."v-list-firewall-rule ".$v_rule." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse rule
|
||||
$v_rule = $_GET['rule'];
|
||||
$v_action = $data[$v_rule]['ACTION'];
|
||||
$v_protocol = $data[$v_rule]['PROTOCOL'];
|
||||
$v_port = $data[$v_rule]['PORT'];
|
||||
$v_ip = $data[$v_rule]['IP'];
|
||||
$v_comment = $data[$v_rule]['COMMENT'];
|
||||
$v_date = $data[$v_rule]['DATE'];
|
||||
$v_time = $data[$v_rule]['TIME'];
|
||||
$v_suspended = $data[$v_rule]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$v_rule = escapeshellarg($_GET['rule']);
|
||||
$v_action = escapeshellarg($_POST['v_action']);
|
||||
$v_protocol = escapeshellarg($_POST['v_protocol']);
|
||||
$v_port = str_replace(" ",",", $_POST['v_port']);
|
||||
$v_port = preg_replace('/\,+/', ',', $v_port);
|
||||
$v_port = trim($v_port, ",");
|
||||
$v_port = escapeshellarg($v_port);
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
$v_comment = escapeshellarg($_POST['v_comment']);
|
||||
|
||||
// Change Status
|
||||
exec (VESTA_CMD."v-change-firewall-rule ".$v_rule." ".$v_action." ".$v_ip." ".$v_port." ".$v_protocol." ".$v_comment, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
$v_rule = $_GET['v_rule'];
|
||||
$v_action = $_POST['v_action'];
|
||||
$v_protocol = $_POST['v_protocol'];
|
||||
$v_port = str_replace(" ",",", $_POST['v_port']);
|
||||
$v_port = preg_replace('/\,+/', ',', $v_port);
|
||||
$v_port = trim($v_port, ",");
|
||||
$v_ip = $_POST['v_ip'];
|
||||
$v_comment = $_POST['v_comment'];
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'rule' => $_GET['rule'],
|
||||
'action' => $data[$v_rule]['ACTION'],
|
||||
'protocol' => $data[$v_rule]['PROTOCOL'],
|
||||
'port' => $data[$v_rule]['PORT'],
|
||||
'ip' => $data[$v_rule]['IP'],
|
||||
'comment' => $data[$v_rule]['COMMENT'],
|
||||
'date' => $data[$v_rule]['DATE'],
|
||||
'time' => $data[$v_rule]['TIME'],
|
||||
'suspended' => $data[$v_rule]['SUSPENDED'],
|
||||
'status' => $v_status,
|
||||
'actions' => [ __('DROP'), __('ACCEPT') ],
|
||||
'protocols' => [ __('TCP'), __('UDP'), __('ICMP') ],
|
||||
'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']);
|
124
web/api/v1/edit/ip/index.php
Normal file
124
web/api/v1/edit/ip/index.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'IP';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check ip argument
|
||||
if (empty($_GET['ip'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// List ip
|
||||
$v_ip = escapeshellarg($_GET['ip']);
|
||||
exec (VESTA_CMD."v-list-sys-ip ".$v_ip." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse ip
|
||||
$v_username = $user;
|
||||
$v_ip = $_GET['ip'];
|
||||
$v_netmask = $data[$v_ip]['NETMASK'];
|
||||
$v_interace = $data[$v_ip]['INTERFACE'];
|
||||
$v_name = $data[$v_ip]['NAME'];
|
||||
$v_nat = $data[$v_ip]['NAT'];
|
||||
$v_ipstatus = $data[$v_ip]['STATUS'];
|
||||
if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes';
|
||||
$v_owner = $data[$v_ip]['OWNER'];
|
||||
$v_date = $data[$v_ip]['DATE'];
|
||||
$v_time = $data[$v_ip]['TIME'];
|
||||
$v_suspended = $data[$v_ip]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
|
||||
// List users
|
||||
exec (VESTA_CMD."v-list-sys-users json", $output, $return_var);
|
||||
$users = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
|
||||
// Change Status
|
||||
if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." dedicated", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_dedicated = 'yes';
|
||||
}
|
||||
if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." shared", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unset($v_dedicated);
|
||||
}
|
||||
|
||||
// Change owner
|
||||
if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_owner = escapeshellarg($_POST['v_owner']);
|
||||
exec (VESTA_CMD."v-change-sys-ip-owner ".$v_ip." ".$v_owner, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_owner = $_POST['v_owner'];
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change associated domain
|
||||
if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_name = escapeshellarg($_POST['v_name']);
|
||||
exec (VESTA_CMD."v-change-sys-ip-name ".$v_ip." ".$v_name, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change NAT address
|
||||
if (($v_nat != $_POST['v_nat']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_nat = escapeshellarg($_POST['v_nat']);
|
||||
exec (VESTA_CMD."v-change-sys-ip-nat ".$v_ip." ".$v_nat, $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.');
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'username' => $user,
|
||||
'ip' => $_GET['ip'],
|
||||
'netmask' => $data[$v_ip]['NETMASK'],
|
||||
'interface' => $data[$v_ip]['INTERFACE'],
|
||||
'name' => $data[$v_ip]['NAME'],
|
||||
'nat' => $data[$v_ip]['NAT'],
|
||||
'ipstatus' => $data[$v_ip]['STATUS'],
|
||||
'dedicated' => $v_dedicated,
|
||||
'owner' => $data[$v_ip]['OWNER'],
|
||||
'date' => $data[$v_ip]['DATE'],
|
||||
'time' => $data[$v_ip]['TIME'],
|
||||
'suspended' => $data[$v_ip]['SUSPENDED'],
|
||||
'status' => 'active',
|
||||
'users' => $users,
|
||||
'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']);
|
372
web/api/v1/edit/mail/index.php
Normal file
372
web/api/v1/edit/mail/index.php
Normal file
|
@ -0,0 +1,372 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'MAIL';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check domain argument
|
||||
if (empty($_GET['domain'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
$v_username = $user;
|
||||
|
||||
// List mail domain
|
||||
if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
exec (VESTA_CMD."v-list-mail-domain ".$user." ".$v_domain." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse domain
|
||||
$v_domain = $_GET['domain'];
|
||||
$v_antispam = $data[$v_domain]['ANTISPAM'];
|
||||
$v_antivirus = $data[$v_domain]['ANTIVIRUS'];
|
||||
$v_dkim = $data[$v_domain]['DKIM'];
|
||||
$v_catchall = $data[$v_domain]['CATCHALL'];
|
||||
$v_date = $data[$v_domain]['DATE'];
|
||||
$v_time = $data[$v_domain]['TIME'];
|
||||
$v_suspended = $data[$v_domain]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
}
|
||||
|
||||
// List mail account
|
||||
if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) {
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_account = escapeshellarg($_GET['account']);
|
||||
exec (VESTA_CMD."v-list-mail-account ".$user." ".$v_domain." ".$v_account." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse mail account
|
||||
$v_username = $user;
|
||||
$v_domain = $_GET['domain'];
|
||||
$v_account = $_GET['account'];
|
||||
$v_password = "";
|
||||
$v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']);
|
||||
$valiases = explode(",", $data[$v_account]['ALIAS']);
|
||||
$v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']);
|
||||
$vfwd = explode(",", $data[$v_account]['FWD']);
|
||||
$v_fwd_only = $data[$v_account]['FWD_ONLY'];
|
||||
$v_quota = $data[$v_account]['QUOTA'];
|
||||
$v_autoreply = $data[$v_account]['AUTOREPLY'];
|
||||
$v_suspended = $data[$v_account]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
$v_date = $data[$v_account]['DATE'];
|
||||
$v_time = $data[$v_account]['TIME'];
|
||||
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_account = escapeshellarg($_GET['account']);
|
||||
|
||||
// Parse autoreply
|
||||
if ( $v_autoreply == 'yes' ) {
|
||||
exec (VESTA_CMD."v-list-mail-account-autoreply ".$user." ".$v_domain." ".$v_account." json", $output, $return_var);
|
||||
$autoreply_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_autoreply_message = $autoreply_str[$v_account]['MSG'];
|
||||
$v_autoreply_message=str_replace("\\n", "\n", $v_autoreply_message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check POST request for mail domain
|
||||
if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['account']))) {
|
||||
$v_domain = escapeshellarg($_POST['v_domain']);
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Delete antispam
|
||||
if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_antispam = 'no';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Add antispam
|
||||
if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_antispam = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Delete antivirus
|
||||
if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_antivirus = 'no';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Add antivirs
|
||||
if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_antivirus = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Delete DKIM
|
||||
if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_dkim = 'no';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Add DKIM
|
||||
if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_dkim = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Delete catchall
|
||||
if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-domain-catchall ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_catchall = '';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change catchall address
|
||||
if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) {
|
||||
if ($v_catchall != $_POST['v_catchall']) {
|
||||
$v_catchall = escapeshellarg($_POST['v_catchall']);
|
||||
exec (VESTA_CMD."v-change-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
|
||||
// Add catchall
|
||||
if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_catchall = escapeshellarg($_POST['v_catchall']);
|
||||
exec (VESTA_CMD."v-add-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $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.');
|
||||
}
|
||||
}
|
||||
|
||||
// Check POST request for mail account
|
||||
if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['account']))) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
header('location: /login/');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Validate email
|
||||
if ((!empty($_POST['v_send_email'])) && (empty($_SESSION['error_msg']))) {
|
||||
if (!filter_var($_POST['v_send_email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$_SESSION['error_msg'] = __('Please enter valid email address.');
|
||||
}
|
||||
}
|
||||
|
||||
$v_domain = escapeshellarg($_POST['v_domain']);
|
||||
$v_account = escapeshellarg($_POST['v_account']);
|
||||
$v_send_email = $_POST['v_send_email'];
|
||||
$v_credentials = $_POST['v_credentials'];
|
||||
|
||||
// Change password
|
||||
if ((!empty($_POST['v_password'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_password, "w");
|
||||
fwrite($fp, $_POST['v_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-mail-account-password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($v_password);
|
||||
$v_password = escapeshellarg($_POST['v_password']);;
|
||||
}
|
||||
|
||||
// Change quota
|
||||
if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) {
|
||||
if (empty($_POST['v_quota'])) {
|
||||
$v_quota = 0;
|
||||
} else {
|
||||
$v_quota = escapeshellarg($_POST['v_quota']);
|
||||
}
|
||||
exec (VESTA_CMD."v-change-mail-account-quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change account aliases
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$waliases = preg_replace("/\n/", " ", $_POST['v_aliases']);
|
||||
$waliases = preg_replace("/,/", " ", $waliases);
|
||||
$waliases = preg_replace('/\s+/', ' ',$waliases);
|
||||
$waliases = trim($waliases);
|
||||
$aliases = explode(" ", $waliases);
|
||||
$v_aliases = str_replace(' ', "\n", $waliases);
|
||||
$result = array_diff($valiases, $aliases);
|
||||
foreach ($result as $alias) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." ".escapeshellarg($alias), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
$result = array_diff($aliases, $valiases);
|
||||
foreach ($result as $alias) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
|
||||
exec (VESTA_CMD."v-add-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." ".escapeshellarg($alias), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change forwarders
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
|
||||
$wfwd = preg_replace("/,/", " ", $wfwd);
|
||||
$wfwd = preg_replace('/\s+/', ' ',$wfwd);
|
||||
$wfwd = trim($wfwd);
|
||||
$fwd = explode(" ", $wfwd);
|
||||
$v_fwd = str_replace(' ', "\n", $wfwd);
|
||||
$result = array_diff($vfwd, $fwd);
|
||||
foreach ($result as $forward) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($forward))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." ".escapeshellarg($forward), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
$result = array_diff($fwd, $vfwd);
|
||||
foreach ($result as $forward) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($forward))) {
|
||||
exec (VESTA_CMD."v-add-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." ".escapeshellarg($forward), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete FWD_ONLY flag
|
||||
if (($v_fwd_only == 'yes') && (empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_fwd_only = '';
|
||||
}
|
||||
|
||||
// Add FWD_ONLY flag
|
||||
if (($v_fwd_only != 'yes') && (!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_fwd_only = 'yes';
|
||||
}
|
||||
|
||||
// Delete autoreply
|
||||
if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_autoreply = 'no';
|
||||
$v_autoreply_message = '';
|
||||
}
|
||||
|
||||
// Add autoreply
|
||||
if ((!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) {
|
||||
if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) {
|
||||
$v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']);
|
||||
$v_autoreply_message = escapeshellarg($v_autoreply_message);
|
||||
exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_autoreply = 'yes';
|
||||
$v_autoreply_message = $_POST['v_autoreply_message'];
|
||||
}
|
||||
}
|
||||
|
||||
// Email login credentials
|
||||
if ((!empty($v_send_email)) && (empty($_SESSION['error_msg']))) {
|
||||
$to = $v_send_email;
|
||||
$subject = __("Email Credentials");
|
||||
$hostname = exec('hostname');
|
||||
$from = __('MAIL_FROM', $hostname);
|
||||
$mailtext = $v_credentials;
|
||||
send_email($to, $subject, $mailtext, $from);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
|
||||
$webmail = "http://".$http_host."/webmail/";
|
||||
if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL'];
|
||||
|
||||
if (empty($hostname)) {
|
||||
$uname_arr=posix_uname();
|
||||
$hostname=$uname_arr['nodename'];
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'antispam' => $data[$v_domain]['ANTISPAM'],
|
||||
'antivirus' => $data[$v_domain]['ANTIVIRUS'],
|
||||
'dkim' => $data[$v_domain]['DKIM'],
|
||||
'catchall' => $data[$v_domain]['CATCHALL'],
|
||||
'status' => $v_status,
|
||||
'username' => $user,
|
||||
'domain' => $v_domain,
|
||||
'account' => $v_account,
|
||||
'password' => $v_password,
|
||||
'aliases' => $v_aliases,
|
||||
'valiases' => $valiases,
|
||||
'fwd' => $v_fwd,
|
||||
'vfwd' => $vfwd,
|
||||
'fwd_only' => $v_fwd_only,
|
||||
'quota' => $v_quota,
|
||||
'autoreply' => $v_autoreply,
|
||||
'quota' => $v_quota,
|
||||
'date' => $v_date,
|
||||
'time' => $v_time,
|
||||
'send_email' => $v_send_email,
|
||||
'credentials' => $v_credentials,
|
||||
'webmail' => $webmail,
|
||||
'hostname' => $hostname,
|
||||
'autoreply_message' => $v_autoreply_message,
|
||||
'v_suspended' => $v_suspended,
|
||||
'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']);
|
270
web/api/v1/edit/package/index.php
Normal file
270
web/api/v1/edit/package/index.php
Normal file
|
@ -0,0 +1,270 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'PACKAGE';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check package argument
|
||||
if (empty($_GET['package'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// List package
|
||||
$v_package = escapeshellarg($_GET['package']);
|
||||
exec (VESTA_CMD."v-list-user-package ".$v_package." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse package
|
||||
$v_package = $_GET['package'];
|
||||
$v_web_template = $data[$v_package]['WEB_TEMPLATE'];
|
||||
$v_backend_template = $data[$v_package]['BACKEND_TEMPLATE'];
|
||||
$v_proxy_template = $data[$v_package]['PROXY_TEMPLATE'];
|
||||
$v_dns_template = $data[$v_package]['DNS_TEMPLATE'];
|
||||
$v_web_domains = $data[$v_package]['WEB_DOMAINS'];
|
||||
$v_web_aliases = $data[$v_package]['WEB_ALIASES'];
|
||||
$v_dns_domains = $data[$v_package]['DNS_DOMAINS'];
|
||||
$v_dns_records = $data[$v_package]['DNS_RECORDS'];
|
||||
$v_mail_domains = $data[$v_package]['MAIL_DOMAINS'];
|
||||
$v_mail_accounts = $data[$v_package]['MAIL_ACCOUNTS'];
|
||||
$v_databases = $data[$v_package]['DATABASES'];
|
||||
$v_cron_jobs = $data[$v_package]['CRON_JOBS'];
|
||||
$v_disk_quota = $data[$v_package]['DISK_QUOTA'];
|
||||
$v_bandwidth = $data[$v_package]['BANDWIDTH'];
|
||||
$v_shell = $data[$v_package]['SHELL'];
|
||||
$v_ns = $data[$v_package]['NS'];
|
||||
$nameservers = explode(",", $v_ns);
|
||||
$v_ns1 = $nameservers[0];
|
||||
$v_ns2 = $nameservers[1];
|
||||
$v_ns3 = $nameservers[2];
|
||||
$v_ns4 = $nameservers[3];
|
||||
$v_ns5 = $nameservers[4];
|
||||
$v_ns6 = $nameservers[5];
|
||||
$v_ns7 = $nameservers[6];
|
||||
$v_ns8 = $nameservers[7];
|
||||
$v_backups = $data[$v_package]['BACKUPS'];
|
||||
$v_date = $data[$v_package]['DATE'];
|
||||
$v_time = $data[$v_package]['TIME'];
|
||||
$v_status = 'active';
|
||||
|
||||
// List web templates
|
||||
exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
|
||||
$web_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List backend templates
|
||||
if (!empty($_SESSION['WEB_BACKEND'])) {
|
||||
exec (VESTA_CMD."v-list-web-templates-backend json", $output, $return_var);
|
||||
$backend_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// List proxy templates
|
||||
if (!empty($_SESSION['PROXY_SYSTEM'])) {
|
||||
exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var);
|
||||
$proxy_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
|
||||
// List dns templates
|
||||
exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var);
|
||||
$dns_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List shels
|
||||
exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var);
|
||||
$shells = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Check empty fields
|
||||
if (empty($_POST['v_package'])) $errors[] = __('package');
|
||||
if (empty($_POST['v_web_template'])) $errors[] = __('web template');
|
||||
if (!empty($_SESSION['WEB_BACKEND'])) {
|
||||
if (empty($_POST['v_backend_template'])) $errors[] = __('backend template');
|
||||
}
|
||||
if (!empty($_SESSION['PROXY_SYSTEM'])) {
|
||||
if (empty($_POST['v_proxy_template'])) $errors[] = __('proxy template');
|
||||
}
|
||||
if (empty($_POST['v_dns_template'])) $errors[] = __('dns template');
|
||||
if (empty($_POST['v_shell'])) $errrors[] = __('shell');
|
||||
if (!isset($_POST['v_web_domains'])) $errors[] = __('web domains');
|
||||
if (!isset($_POST['v_web_aliases'])) $errors[] = __('web aliases');
|
||||
if (!isset($_POST['v_dns_domains'])) $errors[] = __('dns domains');
|
||||
if (!isset($_POST['v_dns_records'])) $errors[] = __('dns records');
|
||||
if (!isset($_POST['v_mail_domains'])) $errors[] = __('mail domains');
|
||||
if (!isset($_POST['v_mail_accounts'])) $errors[] = __('mail accounts');
|
||||
if (!isset($_POST['v_databases'])) $errors[] = __('databases');
|
||||
if (!isset($_POST['v_cron_jobs'])) $errors[] = __('cron jobs');
|
||||
if (!isset($_POST['v_backups'])) $errors[] = __('backups');
|
||||
if (!isset($_POST['v_disk_quota'])) $errors[] = __('quota');
|
||||
if (!isset($_POST['v_bandwidth'])) $errors[] = __('bandwidth');
|
||||
if (empty($_POST['v_ns1'])) $errors[] = __('ns1');
|
||||
if (empty($_POST['v_ns2'])) $errors[] = __('ns2');
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
}
|
||||
|
||||
// Protect input
|
||||
$v_package = escapeshellarg($_POST['v_package']);
|
||||
$v_web_template = escapeshellarg($_POST['v_web_template']);
|
||||
if (!empty($_SESSION['WEB_BACKEND'])) {
|
||||
$v_backend_template = escapeshellarg($_POST['v_backend_template']);
|
||||
}
|
||||
if (!empty($_SESSION['PROXY_SYSTEM'])) {
|
||||
$v_proxy_template = escapeshellarg($_POST['v_proxy_template']);
|
||||
}
|
||||
$v_dns_template = escapeshellarg($_POST['v_dns_template']);
|
||||
$v_shell = escapeshellarg($_POST['v_shell']);
|
||||
$v_web_domains = escapeshellarg($_POST['v_web_domains']);
|
||||
$v_web_aliases = escapeshellarg($_POST['v_web_aliases']);
|
||||
$v_dns_domains = escapeshellarg($_POST['v_dns_domains']);
|
||||
$v_dns_records = escapeshellarg($_POST['v_dns_records']);
|
||||
$v_mail_domains = escapeshellarg($_POST['v_mail_domains']);
|
||||
$v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']);
|
||||
$v_databases = escapeshellarg($_POST['v_databases']);
|
||||
$v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']);
|
||||
$v_backups = escapeshellarg($_POST['v_backups']);
|
||||
$v_disk_quota = escapeshellarg($_POST['v_disk_quota']);
|
||||
$v_bandwidth = escapeshellarg($_POST['v_bandwidth']);
|
||||
$v_ns1 = trim($_POST['v_ns1'], '.');
|
||||
$v_ns2 = trim($_POST['v_ns2'], '.');
|
||||
$v_ns3 = trim($_POST['v_ns3'], '.');
|
||||
$v_ns4 = trim($_POST['v_ns4'], '.');
|
||||
$v_ns5 = trim($_POST['v_ns5'], '.');
|
||||
$v_ns6 = trim($_POST['v_ns6'], '.');
|
||||
$v_ns7 = trim($_POST['v_ns7'], '.');
|
||||
$v_ns8 = trim($_POST['v_ns8'], '.');
|
||||
$v_ns = $v_ns1.",".$v_ns2;
|
||||
if (!empty($v_ns3)) $v_ns .= ",".$v_ns3;
|
||||
if (!empty($v_ns4)) $v_ns .= ",".$v_ns4;
|
||||
if (!empty($v_ns5)) $v_ns .= ",".$v_ns5;
|
||||
if (!empty($v_ns6)) $v_ns .= ",".$v_ns6;
|
||||
if (!empty($v_ns7)) $v_ns .= ",".$v_ns7;
|
||||
if (!empty($v_ns8)) $v_ns .= ",".$v_ns8;
|
||||
$v_ns = escapeshellarg($v_ns);
|
||||
$v_time = escapeshellarg(date('H:i:s'));
|
||||
$v_date = escapeshellarg(date('Y-m-d'));
|
||||
|
||||
// Create temprorary directory
|
||||
exec ('mktemp -d', $output, $return_var);
|
||||
$tmpdir = $output[0];
|
||||
unset($output);
|
||||
|
||||
// Save package file on a fs
|
||||
$pkg = "WEB_TEMPLATE=".$v_web_template."\n";
|
||||
$pkg .= "BACKEND_TEMPLATE=".$v_backend_template."\n";
|
||||
$pkg .= "PROXY_TEMPLATE=".$v_proxy_template."\n";
|
||||
$pkg .= "DNS_TEMPLATE=".$v_dns_template."\n";
|
||||
$pkg .= "WEB_DOMAINS=".$v_web_domains."\n";
|
||||
$pkg .= "WEB_ALIASES=".$v_web_aliases."\n";
|
||||
$pkg .= "DNS_DOMAINS=".$v_dns_domains."\n";
|
||||
$pkg .= "DNS_RECORDS=".$v_dns_records."\n";
|
||||
$pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n";
|
||||
$pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n";
|
||||
$pkg .= "DATABASES=".$v_databases."\n";
|
||||
$pkg .= "CRON_JOBS=".$v_cron_jobs."\n";
|
||||
$pkg .= "DISK_QUOTA=".$v_disk_quota."\n";
|
||||
$pkg .= "BANDWIDTH=".$v_bandwidth."\n";
|
||||
$pkg .= "NS=".$v_ns."\n";
|
||||
$pkg .= "SHELL=".$v_shell."\n";
|
||||
$pkg .= "BACKUPS=".$v_backups."\n";
|
||||
$pkg .= "TIME=".$v_time."\n";
|
||||
$pkg .= "DATE=".$v_date."\n";
|
||||
$fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w');
|
||||
fwrite($fp, $pkg);
|
||||
fclose($fp);
|
||||
|
||||
// Save changes
|
||||
exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package." yes", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
// Remove temporary dir
|
||||
exec ('rm -rf '.$tmpdir, $output, $return_var);
|
||||
unset($output);
|
||||
|
||||
// Propogate new package
|
||||
exec (VESTA_CMD."v-update-user-package ".$v_package." json", $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.');
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'package' => $_GET['package'],
|
||||
'web_template' => $data[$v_package]['WEB_TEMPLATE'],
|
||||
'backend_template' => $data[$v_package]['BACKEND_TEMPLATE'],
|
||||
'proxy_template' => $data[$v_package]['PROXY_TEMPLATE'],
|
||||
'dns_template' => $data[$v_package]['DNS_TEMPLATE'],
|
||||
'web_domains' => $data[$v_package]['WEB_DOMAINS'],
|
||||
'web_aliases' => $data[$v_package]['WEB_ALIASES'],
|
||||
'dns_domains' => $data[$v_package]['DNS_DOMAINS'],
|
||||
'dns_records' => $data[$v_package]['DNS_RECORDS'],
|
||||
'mail_domains' => $data[$v_package]['MAIL_DOMAINS'],
|
||||
'mail_accounts' => $data[$v_package]['MAIL_ACCOUNTS'],
|
||||
'databases' => $data[$v_package]['DATABASES'],
|
||||
'cron_jobs' => $data[$v_package]['CRON_JOBS'],
|
||||
'disk_quota' => $data[$v_package]['DISK_QUOTA'],
|
||||
'bandwidth' => $data[$v_package]['BANDWIDTH'],
|
||||
'shell' => $data[$v_package]['SHELL'],
|
||||
'ns' => $data[$v_package]['NS'],
|
||||
'nameservers' => explode(",", $v_ns),
|
||||
'ns1' => $nameservers[0],
|
||||
'ns2' => $nameservers[1],
|
||||
'ns3' => $nameservers[2],
|
||||
'ns4' => $nameservers[3],
|
||||
'ns5' => $nameservers[4],
|
||||
'ns6' => $nameservers[5],
|
||||
'ns7' => $nameservers[6],
|
||||
'ns8' => $nameservers[7],
|
||||
'backups' => $data[$v_package]['BACKUPS'],
|
||||
'date' => $data[$v_package]['DATE'],
|
||||
'time' => $data[$v_package]['TIME'],
|
||||
'status' => $v_status,
|
||||
'web_templates' => $web_templates,
|
||||
'backend_templates' => $backend_templates,
|
||||
'proxy_templates' => $proxy_templates,
|
||||
'dns_templates' => $dns_templates,
|
||||
'shells' => $shells,
|
||||
'web_system' => $_SESSION['WEB_SYSTEM'],
|
||||
'web_backend' => $_SESSION['WEB_BACKEND'],
|
||||
'proxy_system' => $_SESSION['PROXY_SYSTEM'],
|
||||
'dns_system' => $_SESSION['DNS_SYSTEM']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
66
web/api/v1/edit/server/apache2/index.php
Normal file
66
web/api/v1/edit/server/apache2/index.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?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') {
|
||||
header("Location: /list/user");
|
||||
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." apache2 ".$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/apache2/apache2.conf';
|
||||
$v_service_name = strtoupper('apache2');
|
||||
|
||||
// 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/cron/index.php
Normal file
65
web/api/v1/edit/server/cron/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." cron ".$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/crontab';
|
||||
$v_service_name = strtoupper('cron');
|
||||
|
||||
// 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/crond/index.php
Normal file
65
web/api/v1/edit/server/crond/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." crond ".$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/crontab';
|
||||
$v_service_name = strtoupper('cron');
|
||||
|
||||
// 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/exim/index.php
Normal file
65
web/api/v1/edit/server/exim/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." exim ".$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/exim/exim.conf';
|
||||
$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']);
|
65
web/api/v1/edit/server/fail2ban/index.php
Normal file
65
web/api/v1/edit/server/fail2ban/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." fail2ban ".$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/fail2ban/jail.local';
|
||||
$v_service_name = strtoupper('fail2ban');
|
||||
|
||||
// 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']);
|
698
web/api/v1/edit/server/index.php
Normal file
698
web/api/v1/edit/server/index.php
Normal file
|
@ -0,0 +1,698 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
// 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 dns cluster hosts
|
||||
exec (VESTA_CMD."v-list-remote-dns-hosts json", $output, $return_var);
|
||||
$dns_cluster = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
foreach ($dns_cluster as $key => $value) {
|
||||
$v_dns_cluster = 'yes';
|
||||
}
|
||||
|
||||
// List Database hosts
|
||||
exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var);
|
||||
$db_hosts = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';}));
|
||||
$v_mysql = count($v_mysql_hosts) ? 'yes' : 'no';
|
||||
$v_pgsql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'pgsql';}));
|
||||
$v_pgsql = count($v_pgsql_hosts) ? 'yes' : 'no';
|
||||
unset($db_hosts);
|
||||
|
||||
// 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 = explode(",",$_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'];
|
||||
}
|
||||
}
|
||||
|
||||
// List ssl web domains
|
||||
exec (VESTA_CMD."v-search-ssl-certificates json", $output, $return_var);
|
||||
$v_ssl_domains = json_decode(implode('', $output), true);
|
||||
//$v_vesta_certificate
|
||||
unset($output);
|
||||
|
||||
// List ssl certificate info
|
||||
exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var);
|
||||
$v_sys_ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT'];
|
||||
$v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY'];
|
||||
$v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA'];
|
||||
$v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT'];
|
||||
$v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES'];
|
||||
$v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE'];
|
||||
$v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER'];
|
||||
$v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE'];
|
||||
$v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY'];
|
||||
$v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER'];
|
||||
|
||||
// List mail ssl certificate info
|
||||
if (!empty($_SESSION['VESTA_CERTIFICATE'])); {
|
||||
exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var);
|
||||
$v_mail_ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT'];
|
||||
$v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY'];
|
||||
$v_mail_ssl_ca = $v_mail_ssl_str['MAIL']['CA'];
|
||||
$v_mail_ssl_subject = $v_mail_ssl_str['MAIL']['SUBJECT'];
|
||||
$v_mail_ssl_aliases = $v_mail_ssl_str['MAIL']['ALIASES'];
|
||||
$v_mail_ssl_not_before = $v_mail_ssl_str['MAIL']['NOT_BEFORE'];
|
||||
$v_mail_ssl_not_after = $v_mail_ssl_str['MAIL']['NOT_AFTER'];
|
||||
$v_mail_ssl_signature = $v_mail_ssl_str['MAIL']['SIGNATURE'];
|
||||
$v_mail_ssl_pub_key = $v_mail_ssl_str['MAIL']['PUB_KEY'];
|
||||
$v_mail_ssl_issuer = $v_mail_ssl_str['MAIL']['ISSUER'];
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set firewall support
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_SESSION['FIREWALL_SYSTEM'] == 'iptables') $v_firewall = 'yes';
|
||||
if ($_SESSION['FIREWALL_SYSTEM'] != 'iptables') $v_firewall = 'no';
|
||||
if ((!empty($_POST['v_firewall'])) && ($v_firewall != $_POST['v_firewall'])) {
|
||||
if($_POST['v_firewall'] == 'yes') {
|
||||
exec (VESTA_CMD."v-add-sys-firewall", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $_SESSION['FIREWALL_SYSTEM'] = 'iptables';
|
||||
} else {
|
||||
exec (VESTA_CMD."v-delete-sys-firewall", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $_SESSION['FIREWALL_SYSTEM'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update mysql pasword
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if (!empty($_POST['v_mysql_password'])) {
|
||||
exec (VESTA_CMD."v-change-database-host-password mysql localhost root ".escapeshellarg($_POST['v_mysql_password']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_db_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Delete Mail Domain SSL certificate
|
||||
if ((!isset($_POST['v_mail_ssl_domain_checkbox'])) && (!empty($_SESSION['MAIL_CERTIFICATE'])) && (empty($_SESSION['error_msg']))) {
|
||||
unset($_SESSION['MAIL_CERTIFICATE']);
|
||||
exec (VESTA_CMD."v-delete-sys-mail-ssl", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Updating Mail Domain SSL certificate
|
||||
if ((isset($_POST['v_mail_ssl_domain_checkbox'])) && (isset($_POST['v_mail_ssl_domain'])) && (empty($_SESSION['error_msg']))) {
|
||||
if ((!empty($_POST['v_mail_ssl_domain'])) && ($_POST['v_mail_ssl_domain'] != $_SESSION['MAIL_CERTIFICATE'])) {
|
||||
$v_mail_ssl_str = explode(":", $_POST['v_mail_ssl_domain']);
|
||||
$v_mail_ssl_user = escapeshellarg($v_mail_ssl_str[0]);
|
||||
$v_mail_ssl_domain = escapeshellarg($v_mail_ssl_str[1]);
|
||||
exec (VESTA_CMD."v-add-sys-mail-ssl ".$v_mail_ssl_user." ".$v_mail_ssl_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unset($v_mail_ssl_str);
|
||||
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['MAIL_CERTIFICATE'] = $_POST['v_mail_ssl_domain'];
|
||||
|
||||
// List SSL certificate info
|
||||
exec (VESTA_CMD."v-list-sys-mail-ssl json", $output, $return_var);
|
||||
$v_mail_ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_mail_ssl_crt = $v_mail_ssl_str['MAIL']['CRT'];
|
||||
$v_mail_ssl_key = $v_mail_ssl_str['MAIL']['KEY'];
|
||||
$v_mail_ssl_ca = $v_mail_ssl_str['MAIL']['CA'];
|
||||
$v_mail_ssl_subject = $v_mail_ssl_str['MAIL']['SUBJECT'];
|
||||
$v_mail_ssl_aliases = $v_mail_ssl_str['MAIL']['ALIASES'];
|
||||
$v_mail_ssl_not_before = $v_mail_ssl_str['MAIL']['NOT_BEFORE'];
|
||||
$v_mail_ssl_not_after = $v_mail_ssl_str['MAIL']['NOT_AFTER'];
|
||||
$v_mail_ssl_signature = $v_mail_ssl_str['MAIL']['SIGNATURE'];
|
||||
$v_mail_ssl_pub_key = $v_mail_ssl_str['MAIL']['PUB_KEY'];
|
||||
$v_mail_ssl_issuer = $v_mail_ssl_str['MAIL']['ISSUER'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update webmail url
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_POST['v_mail_url'] != $_SESSION['MAIL_URL']) {
|
||||
exec (VESTA_CMD."v-change-sys-config-value MAIL_URL ".escapeshellarg($_POST['v_mail_url']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_mail_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Update phpMyAdmin url
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_POST['v_mysql_url'] != $_SESSION['DB_PMA_URL']) {
|
||||
exec (VESTA_CMD."v-change-sys-config-value DB_PMA_URL ".escapeshellarg($_POST['v_mysql_url']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_db_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Update phpPgAdmin url
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_POST['v_pgsql_url'] != $_SESSION['DB_PGA_URL']) {
|
||||
exec (VESTA_CMD."v-change-sys-config-value DB_PGA_URL ".escapeshellarg($_POST['v_pgsql_url']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_db_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Disable local backup
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if (($_POST['v_backup'] == 'no') && ($v_backup == 'yes' )) {
|
||||
exec (VESTA_CMD."v-delete-backup-host local", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup = 'no';
|
||||
$v_backup_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Enable local backups
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if (($_POST['v_backup'] == 'yes') && ($v_backup != 'yes' )) {
|
||||
exec (VESTA_CMD."v-add-backup-host local", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup = 'yes';
|
||||
$v_backup_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Change backup gzip level
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_POST['v_backup_gzip'] != $v_backup_gzip ) {
|
||||
exec (VESTA_CMD."v-change-sys-config-value BACKUP_GZIP ".escapeshellarg($_POST['v_backup_gzip']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_gzip = $_POST['v_backup_gzip'];
|
||||
$v_backup_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Change backup path
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ($_POST['v_backup_dir'] != $v_backup_dir ) {
|
||||
exec (VESTA_CMD."v-change-sys-config-value BACKUP ".escapeshellarg($_POST['v_backup_dir']), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_dir = $_POST['v_backup_dir'];
|
||||
$v_backup_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Add remote backup host
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ((!empty($_POST['v_backup_host'])) && (empty($v_backup_host))) {
|
||||
$v_backup_host = escapeshellarg($_POST['v_backup_host']);
|
||||
$v_backup_type = escapeshellarg($_POST['v_backup_type']);
|
||||
$v_backup_username = escapeshellarg($_POST['v_backup_username']);
|
||||
$v_backup_password = escapeshellarg($_POST['v_backup_password']);
|
||||
$v_backup_bpath = escapeshellarg($_POST['v_backup_bpath']);
|
||||
exec (VESTA_CMD."v-add-backup-host ".$v_backup_type." ".$v_backup_host ." ".$v_backup_username." ".$v_backup_password." ".$v_backup_bpath, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_host = $_POST['v_backup_host'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_type = $_POST['v_backup_type'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_username = $_POST['v_backup_username'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_password = $_POST['v_backup_password'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_bpath = $_POST['v_backup_bpath'];
|
||||
$v_backup_new = 'yes';
|
||||
$v_backup_adv = 'yes';
|
||||
$v_backup_remote_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Change remote backup host type
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ((!empty($_POST['v_backup_host'])) && ($_POST['v_backup_type'] != $v_backup_type)) {
|
||||
exec (VESTA_CMD."v-delete-backup-host ". $v_backup_type, $output, $return_var);
|
||||
unset($output);
|
||||
|
||||
$v_backup_host = escapeshellarg($_POST['v_backup_host']);
|
||||
$v_backup_type = escapeshellarg($_POST['v_backup_type']);
|
||||
$v_backup_username = escapeshellarg($_POST['v_backup_username']);
|
||||
$v_backup_password = escapeshellarg($_POST['v_backup_password']);
|
||||
$v_backup_bpath = escapeshellarg($_POST['v_backup_bpath']);
|
||||
exec (VESTA_CMD."v-add-backup-host ".$v_backup_type." ".$v_backup_host." ".$v_backup_username." ".$v_backup_password." ".$v_backup_bpath, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_host = $_POST['v_backup_host'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_type = $_POST['v_backup_type'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_username = $_POST['v_backup_username'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_password = $_POST['v_backup_password'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_bpath = $_POST['v_backup_bpath'];
|
||||
$v_backup_adv = 'yes';
|
||||
$v_backup_remote_adv = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Change remote backup host
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ((!empty($_POST['v_backup_host'])) && ($_POST['v_backup_type'] == $v_backup_type) && (!isset($v_backup_new))) {
|
||||
if (($_POST['v_backup_host'] != $v_backup_host) || ($_POST['v_backup_username'] != $v_backup_username) || ($_POST['v_backup_password'] != $v_backup_password) || ($_POST['v_backup_bpath'] != $v_backup_bpath)){
|
||||
$v_backup_host = escapeshellarg($_POST['v_backup_host']);
|
||||
$v_backup_type = escapeshellarg($_POST['v_backup_type']);
|
||||
$v_backup_username = escapeshellarg($_POST['v_backup_username']);
|
||||
$v_backup_password = escapeshellarg($_POST['v_backup_password']);
|
||||
$v_backup_bpath = escapeshellarg($_POST['v_backup_bpath']);
|
||||
exec (VESTA_CMD."v-add-backup-host ".$v_backup_type." ".$v_backup_host." ".$v_backup_username." ".$v_backup_password." ".$v_backup_bpath, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_host = $_POST['v_backup_host'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_type = $_POST['v_backup_type'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_username = $_POST['v_backup_username'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_password = $_POST['v_backup_password'];
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_bpath = $_POST['v_backup_bpath'];
|
||||
$v_backup_adv = 'yes';
|
||||
$v_backup_remote_adv = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete remote backup host
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ((empty($_POST['v_backup_host'])) && (!empty($v_backup_host))) {
|
||||
exec (VESTA_CMD."v-delete-backup-host ". $v_backup_type, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_host = '';
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_type = '';
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_username = '';
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_password = '';
|
||||
if (empty($_SESSION['error_msg'])) $v_backup_bpath = '';
|
||||
$v_backup_adv = '';
|
||||
$v_backup_remote_adv = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Delete WEB Domain SSL certificate
|
||||
if ((!isset($_POST['v_web_ssl_domain_checkbox'])) && (!empty($_SESSION['VESTA_CERTIFICATE'])) && (empty($_SESSION['error_msg']))) {
|
||||
unset($_SESSION['VESTA_CERTIFICATE']);
|
||||
exec (VESTA_CMD."v-delete-sys-vesta-ssl", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Updating WEB Domain SSL certificate
|
||||
if ((isset($_POST['v_web_ssl_domain_checkbox'])) && (isset($_POST['v_web_ssl_domain'])) && (empty($_SESSION['error_msg']))) {
|
||||
|
||||
if ((!empty($_POST['v_web_ssl_domain'])) && ($_POST['v_web_ssl_domain'] != $_SESSION['VESTA_CERTIFICATE'])) {
|
||||
$v_web_ssl_str = explode(":", $_POST['v_web_ssl_domain']);
|
||||
$v_web_ssl_user = escapeshellarg($v_web_ssl_str[0]);
|
||||
$v_web_ssl_domain = escapeshellarg($v_web_ssl_str[1]);
|
||||
exec (VESTA_CMD."v-add-sys-vesta-ssl ".$v_web_ssl_user." ".$v_web_ssl_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['VESTA_CERTIFICATE'] = $_POST['v_web_ssl_domain'];
|
||||
|
||||
// List SSL certificate info
|
||||
exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var);
|
||||
$v_sys_ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT'];
|
||||
$v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY'];
|
||||
$v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA'];
|
||||
$v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT'];
|
||||
$v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES'];
|
||||
$v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE'];
|
||||
$v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER'];
|
||||
$v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE'];
|
||||
$v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY'];
|
||||
$v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update SSL certificate
|
||||
if ((!empty($_POST['v_sys_ssl_crt'])) && (empty($_POST['v_web_ssl_domain'])) && (empty($_SESSION['error_msg']))) {
|
||||
if (($v_sys_ssl_crt != str_replace("\r\n", "\n", $_POST['v_sys_ssl_crt'])) || ($v_sys_ssl_key != str_replace("\r\n", "\n", $_POST['v_sys_ssl_key']))) {
|
||||
exec ('mktemp -d', $mktemp_output, $return_var);
|
||||
$tmpdir = $mktemp_output[0];
|
||||
|
||||
// Certificate
|
||||
if (!empty($_POST['v_sys_ssl_crt'])) {
|
||||
$fp = fopen($tmpdir."/certificate.crt", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_sys_ssl_crt']));
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Key
|
||||
if (!empty($_POST['v_sys_ssl_key'])) {
|
||||
$fp = fopen($tmpdir."/certificate.key", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_sys_ssl_key']));
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
exec (VESTA_CMD."v-change-sys-vesta-ssl ".$tmpdir, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
// List ssl certificate info
|
||||
exec (VESTA_CMD."v-list-sys-vesta-ssl json", $output, $return_var);
|
||||
$v_sys_ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_sys_ssl_crt = $v_sys_ssl_str['VESTA']['CRT'];
|
||||
$v_sys_ssl_key = $v_sys_ssl_str['VESTA']['KEY'];
|
||||
$v_sys_ssl_ca = $v_sys_ssl_str['VESTA']['CA'];
|
||||
$v_sys_ssl_subject = $v_sys_ssl_str['VESTA']['SUBJECT'];
|
||||
$v_sys_ssl_aliases = $v_sys_ssl_str['VESTA']['ALIASES'];
|
||||
$v_sys_ssl_not_before = $v_sys_ssl_str['VESTA']['NOT_BEFORE'];
|
||||
$v_sys_ssl_not_after = $v_sys_ssl_str['VESTA']['NOT_AFTER'];
|
||||
$v_sys_ssl_signature = $v_sys_ssl_str['VESTA']['SIGNATURE'];
|
||||
$v_sys_ssl_pub_key = $v_sys_ssl_str['VESTA']['PUB_KEY'];
|
||||
$v_sys_ssl_issuer = $v_sys_ssl_str['VESTA']['ISSUER'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Flush field values on success
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
|
||||
// activating sftp licence
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_SESSION['SFTPJAIL_KEY'] != $_POST['v_sftp_licence'] && $_POST['v_sftp'] == 'yes'){
|
||||
$module = 'sftpjail';
|
||||
$licence_key = escapeshellarg($_POST['v_sftp_licence']);
|
||||
exec (VESTA_CMD."v-activate-vesta-license ".$module." ".$licence_key, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Licence Activated');
|
||||
$_SESSION['SFTPJAIL_KEY'] = $_POST['v_sftp_licence'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cancel sftp licence
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_POST['v_sftp'] == 'cancel' && $_SESSION['SFTPJAIL_KEY']){
|
||||
$module = 'sftpjail';
|
||||
$licence_key = escapeshellarg($_SESSION['SFTPJAIL_KEY']);
|
||||
exec (VESTA_CMD."v-deactivate-vesta-license ".$module." ".$licence_key, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Licence Deactivated');
|
||||
unset($_SESSION['SFTPJAIL_KEY']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// activating filemanager licence
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_SESSION['FILEMANAGER_KEY'] != $_POST['v_filemanager_licence'] && $_POST['v_filemanager'] == 'yes'){
|
||||
$module = 'filemanager';
|
||||
$licence_key = escapeshellarg($_POST['v_filemanager_licence']);
|
||||
exec (VESTA_CMD."v-activate-vesta-license ".$module." ".$licence_key, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Licence Activated');
|
||||
$_SESSION['FILEMANAGER_KEY'] = $_POST['v_filemanager_licence'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cancel filemanager licence
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_POST['v_filemanager'] == 'cancel' && $_SESSION['FILEMANAGER_KEY']){
|
||||
$module = 'filemanager';
|
||||
$licence_key = escapeshellarg($_SESSION['FILEMANAGER_KEY']);
|
||||
exec (VESTA_CMD."v-deactivate-vesta-license ".$module." ".$licence_key, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Licence Deactivated');
|
||||
unset($_SESSION['FILEMANAGER_KEY']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// activating softaculous
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_SESSION['SOFTACULOUS'] != $_POST['v_softaculous'] && $_POST['v_softaculous'] == 'yes'){
|
||||
exec (VESTA_CMD."v-add-vesta-softaculous WEB", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Softaculous Activated');
|
||||
$_SESSION['SOFTACULOUS'] = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// disable softaculous
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if($_SESSION['SOFTACULOUS'] != $_POST['v_softaculous'] && $_POST['v_softaculous'] == 'no'){
|
||||
exec (VESTA_CMD."v-delete-vesta-softaculous", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Softaculous Disabled');
|
||||
$_SESSION['SOFTACULOUS'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check system configuration
|
||||
exec (VESTA_CMD . "v-list-sys-config json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
$sys_arr = $data['config'];
|
||||
foreach ($sys_arr as $key => $value) {
|
||||
$_SESSION[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'edit_server');
|
||||
|
||||
$result = array(
|
||||
'hostname' => $v_hostname,
|
||||
'timezones' => $v_timezones,
|
||||
'timezone' => $v_timezone,
|
||||
'languages' => $languages,
|
||||
'backup_adv' => $v_backup_adv,
|
||||
'backup_remote_adv' => $v_backup_remote_adv,
|
||||
'language' => $_SESSION['LANGUAGE'],
|
||||
'proxy_system' => $_SESSION['PROXY_SYSTEM'],
|
||||
'mail_system' => $_SESSION['MAIL_SYSTEM'],
|
||||
'antivirus_system' => $_SESSION['ANTIVIRUS_SYSTEM'],
|
||||
'antispam_system' => $_SESSION['ANTISPAM_SYSTEM'],
|
||||
'mail_url' => $_SESSION['MAIL_URL'],
|
||||
'pgsql_url' => $_SESSION['DB_PGA_URL'],
|
||||
'mail_certificate' => $_SESSION['MAIL_CERTIFICATE'],
|
||||
'db_pma_url' => $_SESSION['DB_PMA_URL'],
|
||||
'dns_system' => $_SESSION['DNS_SYSTEM'],
|
||||
'web_system' => $_SESSION['WEB_SYSTEM'],
|
||||
'softaculous' => $_SESSION['SOFTACULOUS'],
|
||||
'firewall_system' => $_SESSION['FIREWALL_SYSTEM'],
|
||||
'web_backend' => $_SESSION['WEB_BACKEND'],
|
||||
'version' => $_SESSION['VERSION'],
|
||||
'http_host' => $_SERVER['HTTP_HOST'],
|
||||
'fm_key' => $_SESSION['FILEMANAGER_KEY'],
|
||||
'fm_license_key' => $_GET['filemanager_licence_key'],
|
||||
'disk_quota' => $_SESSION['DISK_QUOTA'],
|
||||
'web_backend_pool' => $_SESSION['WEB_BACKEND_POOL'],
|
||||
'sftpjail_key' => $_SESSION['SFTPJAIL_KEY'],
|
||||
'lead' => $_GET['lead'] == 'sftp',
|
||||
'licence_key' => $_GET['sftp_licence_key'] != '' ? $_GET['sftp_licence_key'] : $_SESSION['SFTPJAIL_KEY'],
|
||||
'fm_licence_key_option' => $_GET['filemanager_licence_key'] != '' ? $_GET['filemanager_licence_key'] : $_SESSION['FILEMANAGER_KEY'],
|
||||
'vesta_certificate' => $_SESSION['VESTA_CERTIFICATE'],
|
||||
'yes_no_options' => [ __('no'), __('yes') ],
|
||||
'dns_cluster_options' => [ __('no'), __('yes') ],
|
||||
'postgre_sql_options' => [ __('no'), __('yes') ],
|
||||
'mysql_support_options' => [ __('no'), __('yes') ],
|
||||
'dns_cluster' => $dns_cluster,
|
||||
'v_dns_cluster' => $v_dns_cluster,
|
||||
'db_hosts' => $db_hosts,
|
||||
'mysql_hosts' => $v_mysql_hosts,
|
||||
'mysql' => $mysql,
|
||||
'pgsql_hosts' => $v_pgsql_hosts,
|
||||
'pgsql' => $v_pgsql,
|
||||
'protocols' => [ __('ftp'), __('sftp') ],
|
||||
'backup_dir' => $v_backup_dir,
|
||||
'backup_gzip' => $v_backup_gzip,
|
||||
'backup_types' => $backup_types,
|
||||
'backup' => $v_backup,
|
||||
'remote_backup' => $v_remote_backup,
|
||||
'backup_host' => $v_backup_host,
|
||||
'backup_type' => $v_backup_type,
|
||||
'backup_username' => $v_backup_username,
|
||||
'backup_password' => $v_backup_password,
|
||||
'backup_port' => $v_backup_port,
|
||||
'backup_bpath' => $v_backup_bpath,
|
||||
'ssl_domains' => $v_ssl_domains,
|
||||
'sys_ssl_crt' => $v_sys_ssl_str['VESTA']['CRT'],
|
||||
'sys_ssl_key' => $v_sys_ssl_str['VESTA']['KEY'],
|
||||
'sys_ssl_ca' => $v_sys_ssl_str['VESTA']['CA'],
|
||||
'sys_ssl_subject' => $v_sys_ssl_str['VESTA']['SUBJECT'],
|
||||
'sys_ssl_aliases' => $v_sys_ssl_str['VESTA']['ALIASES'],
|
||||
'sys_ssl_not_before' => $v_sys_ssl_str['VESTA']['NOT_BEFORE'],
|
||||
'sys_ssl_not_after' => $v_sys_ssl_str['VESTA']['NOT_AFTER'],
|
||||
'sys_ssl_signature' => $v_sys_ssl_str['VESTA']['SIGNATURE'],
|
||||
'sys_ssl_pub_key' => $v_sys_ssl_str['VESTA']['PUB_KEY'],
|
||||
'sys_ssl_issuer' => $v_sys_ssl_str['VESTA']['ISSUER'],
|
||||
'mail_ssl_crt' => $v_mail_ssl_str['MAIL']['CRT'],
|
||||
'mail_ssl_key' => $v_mail_ssl_str['MAIL']['KEY'],
|
||||
'mail_ssl_ca' => $v_mail_ssl_str['MAIL']['CA'],
|
||||
'mail_ssl_subject' => $v_mail_ssl_str['MAIL']['SUBJECT'],
|
||||
'mail_ssl_aliases' => $v_mail_ssl_str['MAIL']['ALIASES'],
|
||||
'mail_ssl_not_before' => $v_mail_ssl_str['MAIL']['NOT_BEFORE'],
|
||||
'mail_ssl_not_after' => $v_mail_ssl_str['MAIL']['NOT_AFTER'],
|
||||
'mail_ssl_signature' => $v_mail_ssl_str['MAIL']['SIGNATURE'],
|
||||
'mail_ssl_pub_key' => $v_mail_ssl_str['MAIL']['PUB_KEY'],
|
||||
'mail_ssl_issuer' => $v_mail_ssl_str['MAIL']['ISSUER'],
|
||||
'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']);
|
16
web/api/v1/edit/server/iptables/index.php
Normal file
16
web/api/v1/edit/server/iptables/index.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
$result = array(
|
||||
'error' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg']
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
79
web/api/v1/edit/server/mariadb/index.php
Normal file
79
web/api/v1/edit/server/mariadb/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." mariadb ".$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('mariadb');
|
||||
|
||||
# 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']);
|
79
web/api/v1/edit/server/mysql/index.php
Normal file
79
web/api/v1/edit/server/mysql/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." mysql ".$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']);
|
82
web/api/v1/edit/server/php/index.php
Normal file
82
web/api/v1/edit/server/php/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']);
|
65
web/api/v1/edit/server/proftpd/index.php
Normal file
65
web/api/v1/edit/server/proftpd/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." proftpd ".$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-proftpd-config plain');
|
||||
$v_service_name = strtoupper('proftpd');
|
||||
|
||||
// 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/vsftpd/index.php
Normal file
65
web/api/v1/edit/server/vsftpd/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." vsftpd ".$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-vsftpd-config plain');
|
||||
$v_service_name = strtoupper('vsftpd');
|
||||
|
||||
// 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']);
|
218
web/api/v1/edit/user/index.php
Normal file
218
web/api/v1/edit/user/index.php
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
$TAB = 'USER';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
|
||||
// Check user argument
|
||||
if (empty($_GET['user'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=$_GET['user'];
|
||||
$v_username=$_GET['user'];
|
||||
} else {
|
||||
$user=$_SESSION['user'];
|
||||
$v_username=$_SESSION['user'];
|
||||
}
|
||||
|
||||
// List user
|
||||
exec (VESTA_CMD."v-list-user ".escapeshellarg($v_username)." json", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse user
|
||||
$v_password = "";
|
||||
$v_email = $data[$v_username]['CONTACT'];
|
||||
$v_package = $data[$v_username]['PACKAGE'];
|
||||
$v_language = $data[$v_username]['LANGUAGE'];
|
||||
$v_fname = $data[$v_username]['FNAME'];
|
||||
$v_lname = $data[$v_username]['LNAME'];
|
||||
$v_shell = $data[$v_username]['SHELL'];
|
||||
$v_ns = $data[$v_username]['NS'];
|
||||
$nameservers = explode(",", $v_ns);
|
||||
$v_ns1 = $nameservers[0];
|
||||
$v_ns2 = $nameservers[1];
|
||||
$v_ns3 = $nameservers[2];
|
||||
$v_ns4 = $nameservers[3];
|
||||
$v_ns5 = $nameservers[4];
|
||||
$v_ns6 = $nameservers[5];
|
||||
$v_ns7 = $nameservers[6];
|
||||
$v_ns8 = $nameservers[7];
|
||||
|
||||
$v_suspended = $data[$v_username]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
$v_time = $data[$v_username]['TIME'];
|
||||
$v_date = $data[$v_username]['DATE'];
|
||||
|
||||
// List packages
|
||||
exec (VESTA_CMD."v-list-user-packages json", $output, $return_var);
|
||||
$packages = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List languages
|
||||
exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var);
|
||||
$languages = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List shells
|
||||
exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var);
|
||||
$shells = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Are you admin?
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// Change password
|
||||
if ((!empty($_POST['v_password'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_password, "w");
|
||||
fwrite($fp, $_POST['v_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-user-password ".escapeshellarg($v_username)." ".$v_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($v_password);
|
||||
$v_password = escapeshellarg($_POST['v_password']);
|
||||
}
|
||||
|
||||
// Change package (admin only)
|
||||
if (($v_package != $_POST['v_package']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
|
||||
$v_package = escapeshellarg($_POST['v_package']);
|
||||
exec (VESTA_CMD."v-change-user-package ".escapeshellarg($v_username)." ".$v_package, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change language
|
||||
if (($v_language != $_POST['v_language']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_language = escapeshellarg($_POST['v_language']);
|
||||
exec (VESTA_CMD."v-change-user-language ".escapeshellarg($v_username)." ".$v_language, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
if ((empty($_GET['user'])) || ($_GET['user'] == $_SESSION['user'])) $_SESSION['language'] = $_POST['v_language'];
|
||||
}
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change shell (admin only)
|
||||
if (($v_shell != $_POST['v_shell']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
|
||||
$v_shell = escapeshellarg($_POST['v_shell']);
|
||||
exec (VESTA_CMD."v-change-user-shell ".escapeshellarg($v_username)." ".$v_shell, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Change contact email
|
||||
if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) {
|
||||
if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$_SESSION['error_msg'] = __('Please enter valid email address.');
|
||||
} else {
|
||||
$v_email = escapeshellarg($_POST['v_email']);
|
||||
exec (VESTA_CMD."v-change-user-contact ".escapeshellarg($v_username)." ".$v_email, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
|
||||
// Change full name
|
||||
if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_fname = escapeshellarg($_POST['v_fname']);
|
||||
$v_lname = escapeshellarg($_POST['v_lname']);
|
||||
exec (VESTA_CMD."v-change-user-name ".escapeshellarg($v_username)." ".$v_fname." ".$v_lname, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_fname = $_POST['v_fname'];
|
||||
$v_lname = $_POST['v_lname'];
|
||||
}
|
||||
|
||||
// Change NameServers
|
||||
if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) || ($v_ns5 != $_POST['v_ns5'])
|
||||
|| ($v_ns6 != $_POST['v_ns6']) || ($v_ns7 != $_POST['v_ns7']) || ($v_ns8 != $_POST['v_ns8']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_ns1 = escapeshellarg($_POST['v_ns1']);
|
||||
$v_ns2 = escapeshellarg($_POST['v_ns2']);
|
||||
$v_ns3 = escapeshellarg($_POST['v_ns3']);
|
||||
$v_ns4 = escapeshellarg($_POST['v_ns4']);
|
||||
$v_ns5 = escapeshellarg($_POST['v_ns5']);
|
||||
$v_ns6 = escapeshellarg($_POST['v_ns6']);
|
||||
$v_ns7 = escapeshellarg($_POST['v_ns7']);
|
||||
$v_ns8 = escapeshellarg($_POST['v_ns8']);
|
||||
$ns_cmd = VESTA_CMD."v-change-user-ns ".escapeshellarg($v_username)." ".$v_ns1." ".$v_ns2;
|
||||
if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3;
|
||||
if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4;
|
||||
if (!empty($_POST['v_ns5'])) $ns_cmd = $ns_cmd." ".$v_ns5;
|
||||
if (!empty($_POST['v_ns6'])) $ns_cmd = $ns_cmd." ".$v_ns6;
|
||||
if (!empty($_POST['v_ns7'])) $ns_cmd = $ns_cmd." ".$v_ns7;
|
||||
if (!empty($_POST['v_ns8'])) $ns_cmd = $ns_cmd." ".$v_ns8;
|
||||
exec ($ns_cmd, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
$v_ns1 = str_replace("'","", $v_ns1);
|
||||
$v_ns2 = str_replace("'","", $v_ns2);
|
||||
$v_ns3 = str_replace("'","", $v_ns3);
|
||||
$v_ns4 = str_replace("'","", $v_ns4);
|
||||
$v_ns5 = str_replace("'","", $v_ns5);
|
||||
$v_ns6 = str_replace("'","", $v_ns6);
|
||||
$v_ns7 = str_replace("'","", $v_ns7);
|
||||
$v_ns8 = str_replace("'","", $v_ns8);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$_SESSION['ok_msg'] = __('Changes has been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'password' => '',
|
||||
'email' => $data[$v_username]['CONTACT'],
|
||||
'package' => $data[$v_username]['PACKAGE'],
|
||||
'language' => $data[$v_username]['LANGUAGE'],
|
||||
'fname' => $data[$v_username]['FNAME'],
|
||||
'lname' => $data[$v_username]['LNAME'],
|
||||
'shell' => $data[$v_username]['SHELL'],
|
||||
'nameservers' => $nameservers,
|
||||
'ns1' => $nameservers[0],
|
||||
'ns2' => $nameservers[1],
|
||||
'ns3' => $nameservers[2],
|
||||
'ns4' => $nameservers[3],
|
||||
'ns5' => $nameservers[4],
|
||||
'ns6' => $nameservers[5],
|
||||
'ns7' => $nameservers[6],
|
||||
'ns8' => $nameservers[7],
|
||||
'suspended' => $data[$v_username]['SUSPENDED'],
|
||||
'status' => $v_status,
|
||||
'time' => $data[$v_username]['TIME'],
|
||||
'date' => $data[$v_username]['DATE'],
|
||||
'error_msg' => $_SESSION['error_msg'],
|
||||
'ok_msg' => $_SESSION['ok_msg'],
|
||||
'packages' => $packages,
|
||||
'languages' => $languages,
|
||||
'shells' => $shells
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
// Flush session messages
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
810
web/api/v1/edit/web/index.php
Normal file
810
web/api/v1/edit/web/index.php
Normal file
|
@ -0,0 +1,810 @@
|
|||
<?php
|
||||
|
||||
header('Access-Control-Allow-Origin : http://localhost:3000');
|
||||
header('Access-Control-Allow-Credentials : true');
|
||||
header('Access-Control-Allow-Methods : GET, POST, OPTIONS');
|
||||
header("Access-Control-Allow-Headers : Origin, Content-Type, Accept");
|
||||
|
||||
error_reporting(NULL);
|
||||
ob_start();
|
||||
unset($_SESSION['error_msg']);
|
||||
$TAB = 'WEB';
|
||||
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Check domain argument
|
||||
if (empty($_GET['domain'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Edit as someone else?
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
||||
$user=escapeshellarg($_GET['user']);
|
||||
}
|
||||
|
||||
// List domain
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
exec (VESTA_CMD."v-list-web-domain ".$user." ".$v_domain." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Parse domain
|
||||
$v_username = $user;
|
||||
$v_domain = $_GET['domain'];
|
||||
$v_ip = $data[$v_domain]['IP'];
|
||||
$v_template = $data[$v_domain]['TPL'];
|
||||
$v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']);
|
||||
$valiases = explode(",", $data[$v_domain]['ALIAS']);
|
||||
$v_tpl = $data[$v_domain]['IP'];
|
||||
$v_cgi = $data[$v_domain]['CGI'];
|
||||
$v_elog = $data[$v_domain]['ELOG'];
|
||||
$v_ssl = $data[$v_domain]['SSL'];
|
||||
if (!empty($v_ssl)) {
|
||||
exec (VESTA_CMD."v-list-web-domain-ssl ".$user." ".escapeshellarg($v_domain)." json", $output, $return_var);
|
||||
$ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_ssl_crt = $ssl_str[$v_domain]['CRT'];
|
||||
$v_ssl_key = $ssl_str[$v_domain]['KEY'];
|
||||
$v_ssl_ca = $ssl_str[$v_domain]['CA'];
|
||||
$v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
|
||||
$v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
|
||||
$v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
|
||||
$v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
|
||||
$v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
|
||||
$v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
|
||||
$v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
|
||||
}
|
||||
$v_letsencrypt = $data[$v_domain]['LETSENCRYPT'];
|
||||
if (empty($v_letsencrypt)) $v_letsencrypt = 'no';
|
||||
$v_ssl_home = $data[$v_domain]['SSL_HOME'];
|
||||
$v_backend_template = $data[$v_domain]['BACKEND'];
|
||||
$v_proxy = $data[$v_domain]['PROXY'];
|
||||
$v_proxy_template = $data[$v_domain]['PROXY'];
|
||||
$v_proxy_ext = str_replace(',', ', ', $data[$v_domain]['PROXY_EXT']);
|
||||
$v_stats = $data[$v_domain]['STATS'];
|
||||
$v_stats_user = $data[$v_domain]['STATS_USER'];
|
||||
if (!empty($v_stats_user)) $v_stats_password = "";
|
||||
$v_ftp_user = $data[$v_domain]['FTP_USER'];
|
||||
$v_ftp_path = $data[$v_domain]['FTP_PATH'];
|
||||
if (!empty($v_ftp_user)) $v_ftp_password = "";
|
||||
$v_ftp_user_prepath = $data[$v_domain]['DOCUMENT_ROOT'];
|
||||
$v_ftp_user_prepath = str_replace('/public_html', '', $v_ftp_user_prepath, $occurance = 1);
|
||||
$v_ftp_email = $panel[$user]['CONTACT'];
|
||||
$v_suspended = $data[$v_domain]['SUSPENDED'];
|
||||
if ( $v_suspended == 'yes' ) {
|
||||
$v_status = 'suspended';
|
||||
} else {
|
||||
$v_status = 'active';
|
||||
}
|
||||
$v_time = $data[$v_domain]['TIME'];
|
||||
$v_date = $data[$v_domain]['DATE'];
|
||||
|
||||
// List ip addresses
|
||||
exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
|
||||
$ips = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List web templates
|
||||
exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
|
||||
$templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// List backend templates
|
||||
if (!empty($_SESSION['WEB_BACKEND'])) {
|
||||
exec (VESTA_CMD."v-list-web-templates-backend json", $output, $return_var);
|
||||
$backend_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// List proxy templates
|
||||
if (!empty($_SESSION['PROXY_SYSTEM'])) {
|
||||
exec (VESTA_CMD."v-list-web-templates-proxy json", $output, $return_var);
|
||||
$proxy_templates = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// List web stat engines
|
||||
exec (VESTA_CMD."v-list-web-stats json", $output, $return_var);
|
||||
$stats = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST['save'])) {
|
||||
$v_domain = escapeshellarg($_POST['v_domain']);
|
||||
|
||||
// Check token
|
||||
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
|
||||
header('location: /login/');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Change web domain IP
|
||||
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Chane dns domain IP
|
||||
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var);
|
||||
unset($output);
|
||||
if ($return_var == 0 ) {
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Change dns ip for each alias
|
||||
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
|
||||
foreach($valiases as $v_alias ){
|
||||
$v_alias = escapeshellarg($v_alias);
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_alias." json", $output, $return_var);
|
||||
unset($output);
|
||||
if ($return_var == 0 ) {
|
||||
$v_ip = escapeshellarg($_POST['v_ip']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_alias." ".$v_ip, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change template (admin only)
|
||||
if (($v_template != $_POST['v_template']) && ( $_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
|
||||
$v_template = escapeshellarg($_POST['v_template']);
|
||||
exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_web = 'yes';
|
||||
}
|
||||
|
||||
// Change aliases
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$waliases = preg_replace("/\n/", " ", $_POST['v_aliases']);
|
||||
$waliases = preg_replace("/,/", " ", $waliases);
|
||||
$waliases = preg_replace('/\s+/', ' ',$waliases);
|
||||
$waliases = trim($waliases);
|
||||
$aliases = explode(" ", $waliases);
|
||||
$v_aliases = str_replace(' ', "\n", $waliases);
|
||||
$result = array_diff($valiases, $aliases);
|
||||
foreach ($result as $alias) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
$v_template = escapeshellarg($_POST['v_template']);
|
||||
$alias = escapeshellarg($alias);
|
||||
exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." ".$alias." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
unset($output);
|
||||
if ($return_var == 0) {
|
||||
exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." ".$alias." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array_diff($aliases, $valiases);
|
||||
foreach ($result as $alias) {
|
||||
if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
$v_template = escapeshellarg($_POST['v_template']);
|
||||
$alias = escapeshellarg($alias);
|
||||
exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." ".$alias." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
unset($output);
|
||||
if ($return_var == 0) {
|
||||
exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$alias." ".$v_ip." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change backend template
|
||||
if ((!empty($_SESSION['WEB_BACKEND'])) && ( $v_backend_template != $_POST['v_backend_template']) && ( $_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
|
||||
$v_backend_template = $_POST['v_backend_template'];
|
||||
exec (VESTA_CMD."v-change-web-domain-backend-tpl ".$v_username." ".$v_domain." ".escapeshellarg($v_backend_template), $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Delete proxy support
|
||||
if ((!empty($_SESSION['PROXY_SYSTEM'])) && (!empty($v_proxy)) && (empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-web-domain-proxy ".$v_username." ".$v_domain." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unset($v_proxy);
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
|
||||
// Change proxy template / Update extension list (admin only)
|
||||
if ((!empty($_SESSION['PROXY_SYSTEM'])) && (!empty($v_proxy)) && (!empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg'])) && ($_SESSION['user'] == 'admin')) {
|
||||
$ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']);
|
||||
$ext = preg_replace("/,/", " ", $ext);
|
||||
$ext = preg_replace('/\s+/', ' ',$ext);
|
||||
$ext = trim($ext);
|
||||
$ext = str_replace(' ', ", ", $ext);
|
||||
if (( $v_proxy_template != $_POST['v_proxy_template']) || ($v_proxy_ext != $ext)) {
|
||||
$ext = str_replace(', ', ",", $ext);
|
||||
if (!empty($_POST['v_proxy_template'])) $v_proxy_template = $_POST['v_proxy_template'];
|
||||
exec (VESTA_CMD."v-change-web-domain-proxy-tpl ".$v_username." ".$v_domain." ".escapeshellarg($v_proxy_template)." ".escapeshellarg($ext)." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_proxy_ext = str_replace(',', ', ', $ext);
|
||||
unset($output);
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Add proxy support
|
||||
if ((!empty($_SESSION['PROXY_SYSTEM'])) && (empty($v_proxy)) && (!empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_proxy_template = $_POST['v_proxy_template'];
|
||||
if (!empty($_POST['v_proxy_ext'])) {
|
||||
$ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']);
|
||||
$ext = preg_replace("/,/", " ", $ext);
|
||||
$ext = preg_replace('/\s+/', ' ',$ext);
|
||||
$ext = trim($ext);
|
||||
$ext = str_replace(' ', ",", $ext);
|
||||
$v_proxy_ext = str_replace(',', ', ', $ext);
|
||||
}
|
||||
exec (VESTA_CMD."v-add-web-domain-proxy ".$v_username." ".$v_domain." ".escapeshellarg($v_proxy_template)." ".escapeshellarg($ext)." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
|
||||
// Change document root for ssl domain
|
||||
if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
||||
if ( $v_ssl_home != $_POST['v_ssl_home'] ) {
|
||||
$v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
||||
exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
$v_ssl_home = $_POST['v_ssl_home'];
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
|
||||
// Change SSL certificate
|
||||
if (( $v_letsencrypt == 'no' ) && (empty($_POST['v_letsencrypt'])) && ( $v_ssl == 'yes' ) && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
||||
if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) {
|
||||
exec ('mktemp -d', $mktemp_output, $return_var);
|
||||
$tmpdir = $mktemp_output[0];
|
||||
|
||||
// Certificate
|
||||
if (!empty($_POST['v_ssl_crt'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Key
|
||||
if (!empty($_POST['v_ssl_key'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// CA
|
||||
if (!empty($_POST['v_ssl_ca'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
|
||||
exec (VESTA_CMD."v-list-web-domain-ssl ".$user." ".$v_domain." json", $output, $return_var);
|
||||
$ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_ssl_crt = $ssl_str[$v_domain]['CRT'];
|
||||
$v_ssl_key = $ssl_str[$v_domain]['KEY'];
|
||||
$v_ssl_ca = $ssl_str[$v_domain]['CA'];
|
||||
$v_ssl_subject = $ssl_str[$v_domain]['SUBJECT'];
|
||||
$v_ssl_aliases = $ssl_str[$v_domain]['ALIASES'];
|
||||
$v_ssl_not_before = $ssl_str[$v_domain]['NOT_BEFORE'];
|
||||
$v_ssl_not_after = $ssl_str[$v_domain]['NOT_AFTER'];
|
||||
$v_ssl_signature = $ssl_str[$v_domain]['SIGNATURE'];
|
||||
$v_ssl_pub_key = $ssl_str[$v_domain]['PUB_KEY'];
|
||||
$v_ssl_issuer = $ssl_str[$v_domain]['ISSUER'];
|
||||
|
||||
// Cleanup certificate tempfiles
|
||||
if (!empty($_POST['v_ssl_crt'])) unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
||||
if (!empty($_POST['v_ssl_key'])) unlink($tmpdir."/".$_POST['v_domain'].".key");
|
||||
if (!empty($_POST['v_ssl_ca'])) unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
||||
rmdir($tmpdir);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete Lets Encrypt support
|
||||
if (( $v_letsencrypt == 'yes' ) && (empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-letsencrypt-domain ".$user." ".$v_domain." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_ssl_crt = '';
|
||||
$v_ssl_key = '';
|
||||
$v_ssl_ca = '';
|
||||
$v_letsencrypt = 'no';
|
||||
$v_letsencrypt_deleted = 'yes';
|
||||
$v_ssl = 'no';
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
|
||||
// Delete SSL certificate
|
||||
if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_ssl_crt = '';
|
||||
$v_ssl_key = '';
|
||||
$v_ssl_ca = '';
|
||||
$v_ssl = 'no';
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
|
||||
// Add Lets Encrypt support
|
||||
if ((!empty($_POST['v_ssl'])) && ( $v_letsencrypt == 'no' ) && (!empty($_POST['v_letsencrypt'])) && empty($_SESSION['error_msg'])) {
|
||||
$l_aliases = str_replace("\n", ',', $v_aliases);
|
||||
exec (VESTA_CMD."v-add-letsencrypt-domain ".$user." ".$v_domain." ".escapeshellarg($l_aliases)." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_letsencrypt = 'yes';
|
||||
$v_ssl = 'yes';
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
}
|
||||
|
||||
// Add SSL certificate
|
||||
if (( $v_ssl == 'no' ) && (!empty($_POST['v_ssl'])) && (empty($v_letsencrypt_deleted)) && (empty($_SESSION['error_msg']))) {
|
||||
if (empty($_POST['v_ssl_crt'])) $errors[] = 'ssl certificate';
|
||||
if (empty($_POST['v_ssl_key'])) $errors[] = 'ssl key';
|
||||
if (empty($_POST['v_ssl_home'])) $errors[] = 'ssl home';
|
||||
$v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
} else {
|
||||
exec ('mktemp -d', $mktemp_output, $return_var);
|
||||
$tmpdir = $mktemp_output[0];
|
||||
|
||||
// Certificate
|
||||
if (!empty($_POST['v_ssl_crt'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Key
|
||||
if (!empty($_POST['v_ssl_key'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// CA
|
||||
if (!empty($_POST['v_ssl_ca'])) {
|
||||
$fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
|
||||
fclose($fp);
|
||||
}
|
||||
exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." no", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_ssl = 'yes';
|
||||
$restart_web = 'yes';
|
||||
$restart_proxy = 'yes';
|
||||
|
||||
exec (VESTA_CMD."v-list-web-domain-ssl ".$user." ".$v_domain." json", $output, $return_var);
|
||||
$ssl_str = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
$v_ssl_crt = $ssl_str[$_POST['v_domain']]['CRT'];
|
||||
$v_ssl_key = $ssl_str[$_POST['v_domain']]['KEY'];
|
||||
$v_ssl_ca = $ssl_str[$_POST['v_domain']]['CA'];
|
||||
$v_ssl_subject = $ssl_str[$_POST['v_domain']]['SUBJECT'];
|
||||
$v_ssl_aliases = $ssl_str[$_POST['v_domain']]['ALIASES'];
|
||||
$v_ssl_not_before = $ssl_str[$_POST['v_domain']]['NOT_BEFORE'];
|
||||
$v_ssl_not_after = $ssl_str[$_POST['v_domain']]['NOT_AFTER'];
|
||||
$v_ssl_signature = $ssl_str[$_POST['v_domain']]['SIGNATURE'];
|
||||
$v_ssl_pub_key = $ssl_str[$_POST['v_domain']]['PUB_KEY'];
|
||||
$v_ssl_issuer = $ssl_str[$_POST['v_domain']]['ISSUER'];
|
||||
|
||||
// Cleanup certificate tempfiles
|
||||
if (!empty($_POST['v_ssl_crt'])) unlink($tmpdir."/".$_POST['v_domain'].".crt");
|
||||
if (!empty($_POST['v_ssl_key'])) unlink($tmpdir."/".$_POST['v_domain'].".key");
|
||||
if (!empty($_POST['v_ssl_ca'])) unlink($tmpdir."/".$_POST['v_domain'].".ca");
|
||||
rmdir($tmpdir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Delete web stats
|
||||
if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_stats = '';
|
||||
}
|
||||
|
||||
// Change web stats engine
|
||||
if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) {
|
||||
$v_stats = escapeshellarg($_POST['v_stats']);
|
||||
exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Add web stats
|
||||
if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) {
|
||||
$v_stats = escapeshellarg($_POST['v_stats']);
|
||||
exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Delete web stats authorization
|
||||
if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_stats_user = '';
|
||||
$v_stats_password = '';
|
||||
}
|
||||
|
||||
// Change web stats user or password
|
||||
if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) {
|
||||
if (empty($_POST['v_stats_user'])) $errors[] = __('stats username');
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
} else {
|
||||
$v_stats_user = escapeshellarg($_POST['v_stats_user']);
|
||||
$v_stats_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_stats_password, "w");
|
||||
fwrite($fp, $_POST['v_stats_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($v_stats_password);
|
||||
$v_stats_password = escapeshellarg($_POST['v_stats_password']);
|
||||
}
|
||||
}
|
||||
|
||||
// Add web stats authorization
|
||||
if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) {
|
||||
if (empty($_POST['v_stats_user'])) $errors[] = __('stats user');
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
}
|
||||
if (($v_stats_user != $_POST['v_stats_user']) || (!empty($_POST['v_stats_password'])) && (empty($_SESSION['error_msg']))) {
|
||||
$v_stats_user = escapeshellarg($_POST['v_stats_user']);
|
||||
$v_stats_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_stats_password, "w");
|
||||
fwrite($fp, $_POST['v_stats_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
unlink($v_stats_password);
|
||||
$v_stats_password = escapeshellarg($_POST['v_stats_password']);
|
||||
}
|
||||
}
|
||||
|
||||
// Update ftp account
|
||||
if (!empty($_POST['v_ftp_user'])) {
|
||||
$v_ftp_users_updated = array();
|
||||
foreach ($_POST['v_ftp_user'] as $i => $v_ftp_user_data) {
|
||||
if (empty($v_ftp_user_data['v_ftp_user'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$v_ftp_user_data['v_ftp_user'] = preg_replace("/^".$user."_/i", "", $v_ftp_user_data['v_ftp_user']);
|
||||
if ($v_ftp_user_data['is_new'] == 1 && !empty($_POST['v_ftp'])) {
|
||||
if ((!empty($v_ftp_user_data['v_ftp_email'])) && (!filter_var($v_ftp_user_data['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = __('Please enter valid email address.');
|
||||
if (empty($v_ftp_user_data['v_ftp_user'])) $errors[] = 'ftp user';
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
}
|
||||
|
||||
// Add ftp account
|
||||
$v_ftp_username = $v_ftp_user_data['v_ftp_user'];
|
||||
$v_ftp_username_full = $user . '_' . $v_ftp_user_data['v_ftp_user'];
|
||||
$v_ftp_user = escapeshellarg($v_ftp_username);
|
||||
$v_ftp_path = escapeshellarg(trim($v_ftp_user_data['v_ftp_path']));
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
$v_ftp_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_ftp_password, "w");
|
||||
fwrite($fp, $v_ftp_user_data['v_ftp_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password . " " . $v_ftp_path, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
if ((!empty($v_ftp_user_data['v_ftp_email'])) && (empty($_SESSION['error_msg']))) {
|
||||
$to = $v_ftp_user_data['v_ftp_email'];
|
||||
$subject = __("FTP login credentials");
|
||||
$hostname = exec('hostname');
|
||||
$from = __('MAIL_FROM',$hostname);
|
||||
$mailtext = __('FTP_ACCOUNT_READY',$_GET['domain'],$user,$v_ftp_username,$v_ftp_user_data['v_ftp_password']);
|
||||
send_email($to, $subject, $mailtext, $from);
|
||||
unset($v_ftp_email);
|
||||
}
|
||||
unset($output);
|
||||
unlink($v_ftp_password);
|
||||
$v_ftp_password = escapeshellarg($v_ftp_user_data['v_ftp_password']);
|
||||
}
|
||||
|
||||
if ($return_var == 0) {
|
||||
$v_ftp_password = "";
|
||||
$v_ftp_user_data['is_new'] = 0;
|
||||
}
|
||||
else {
|
||||
$v_ftp_user_data['is_new'] = 1;
|
||||
}
|
||||
|
||||
$v_ftp_users_updated[] = array(
|
||||
'is_new' => empty($_SESSION['error_msg']) ? 0 : 1,
|
||||
'v_ftp_user' => $v_ftp_username_full,
|
||||
'v_ftp_password' => $v_ftp_password,
|
||||
'v_ftp_path' => $v_ftp_user_data['v_ftp_path'],
|
||||
'v_ftp_email' => $v_ftp_user_data['v_ftp_email'],
|
||||
'v_ftp_pre_path' => $v_ftp_user_prepath
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Delete FTP account
|
||||
if ($v_ftp_user_data['delete'] == 1) {
|
||||
$v_ftp_username = $user . '_' . $v_ftp_user_data['v_ftp_user'];
|
||||
exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_username, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($_POST['v_ftp'])) {
|
||||
if (empty($v_ftp_user_data['v_ftp_user'])) $errors[] = __('ftp user');
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
}
|
||||
|
||||
// Change FTP account path
|
||||
$v_ftp_username_for_emailing = $v_ftp_user_data['v_ftp_user'];
|
||||
$v_ftp_username = $user . '_' . $v_ftp_user_data['v_ftp_user']; //preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']);
|
||||
$v_ftp_username = escapeshellarg($v_ftp_username);
|
||||
$v_ftp_path = escapeshellarg(trim($v_ftp_user_data['v_ftp_path']));
|
||||
if(escapeshellarg(trim($v_ftp_user_data['v_ftp_path_prev'])) != $v_ftp_path) {
|
||||
exec (VESTA_CMD."v-change-web-domain-ftp-path ".$v_username." ".$v_domain." ".$v_ftp_username." ".$v_ftp_path, $output, $return_var);
|
||||
}
|
||||
|
||||
// Change FTP account password
|
||||
if (!empty($v_ftp_user_data['v_ftp_password'])) {
|
||||
$v_ftp_password = tempnam("/tmp","vst");
|
||||
$fp = fopen($v_ftp_password, "w");
|
||||
fwrite($fp, $v_ftp_user_data['v_ftp_password']."\n");
|
||||
fclose($fp);
|
||||
exec (VESTA_CMD."v-change-web-domain-ftp-password ".$v_username." ".$v_domain." ".$v_ftp_username." ".$v_ftp_password, $output, $return_var);
|
||||
unlink($v_ftp_password);
|
||||
|
||||
$to = $v_ftp_user_data['v_ftp_email'];
|
||||
$subject = __("FTP login credentials");
|
||||
$hostname = exec('hostname');
|
||||
$from = __('MAIL_FROM',$hostname);
|
||||
$mailtext = __('FTP_ACCOUNT_READY',$_GET['domain'],$user,$v_ftp_username_for_emailing,$v_ftp_user_data['v_ftp_password']);
|
||||
send_email($to, $subject, $mailtext, $from);
|
||||
unset($v_ftp_email);
|
||||
}
|
||||
check_return_code($return_var, $output);
|
||||
unset($output);
|
||||
|
||||
$v_ftp_users_updated[] = array(
|
||||
'is_new' => 0,
|
||||
'v_ftp_user' => $v_ftp_username,
|
||||
'v_ftp_password' => $v_ftp_user_data['v_ftp_password'],
|
||||
'v_ftp_path' => $v_ftp_user_data['v_ftp_path'],
|
||||
'v_ftp_email' => $v_ftp_user_data['v_ftp_email'],
|
||||
'v_ftp_pre_path' => $v_ftp_user_prepath
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restart web server
|
||||
if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-restart-web", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Restart proxy server
|
||||
if ((!empty($_SESSION['PROXY_SYSTEM'])) && !empty($restart_proxy) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-restart-proxy", $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
// Restart dns server
|
||||
if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-restart-dns", $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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$v_ftp_users_raw = explode(':', $v_ftp_user);
|
||||
$v_ftp_users_paths_raw = explode(':', $data[$v_domain]['FTP_PATH']);
|
||||
$v_ftp_users = array();
|
||||
foreach ($v_ftp_users_raw as $v_ftp_user_index => $v_ftp_user_val) {
|
||||
if (empty($v_ftp_user_val)) {
|
||||
continue;
|
||||
}
|
||||
$v_ftp_users[] = array(
|
||||
'is_new' => 0,
|
||||
'v_ftp_user' => $v_ftp_user_val,
|
||||
'v_ftp_password' => $v_ftp_password,
|
||||
'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''),
|
||||
'v_ftp_email' => $v_ftp_email,
|
||||
'v_ftp_pre_path' => $v_ftp_user_prepath
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($v_ftp_users)) {
|
||||
$v_ftp_user = null;
|
||||
$v_ftp_users[] = array(
|
||||
'is_new' => 1,
|
||||
'v_ftp_user' => '',
|
||||
'v_ftp_password' => '',
|
||||
'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''),
|
||||
'v_ftp_email' => '',
|
||||
'v_ftp_pre_path' => $v_ftp_user_prepath
|
||||
);
|
||||
}
|
||||
|
||||
// set default pre path for newly created users
|
||||
$v_ftp_pre_path_new_user = $v_ftp_user_prepath;
|
||||
if (isset($v_ftp_users_updated)) {
|
||||
$v_ftp_users = $v_ftp_users_updated;
|
||||
if (empty($v_ftp_users_updated)) {
|
||||
$v_ftp_user = null;
|
||||
$v_ftp_users[] = array(
|
||||
'is_new' => 1,
|
||||
'v_ftp_user' => '',
|
||||
'v_ftp_password' => '',
|
||||
'v_ftp_path' => (isset($v_ftp_users_paths_raw[$v_ftp_user_index]) ? $v_ftp_users_paths_raw[$v_ftp_user_index] : ''),
|
||||
'v_ftp_email' => '',
|
||||
'v_ftp_pre_path' => $v_ftp_user_prepath
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'username' => $v_username,
|
||||
'domain' => $v_domain,
|
||||
'ip' => $v_ip,
|
||||
'template' => $v_template,
|
||||
'aliases' => $v_aliases,
|
||||
'valiases' => $valiases,
|
||||
'tpl' => $v_tpl,
|
||||
'elog' => $$v_elog,
|
||||
'ssl' => $v_ssl,
|
||||
'cgi' => $v_cgi,
|
||||
'ssl_crt' => $v_ssl_crt,
|
||||
'ssl_key' => $v_ssl_key,
|
||||
'ssl_ca' => $v_ssl_ca,
|
||||
'ssl_subject' => $v_ssl_subject,
|
||||
'ssl_aliases' => $v_ssl_aliases,
|
||||
'ssl_not_before' => $v_ssl_not_before,
|
||||
'ssl_not_after' => $v_ssl_not_after,
|
||||
'ssl_signature' => $v_ssl_signature,
|
||||
'ssl_pub_key' => $v_ssl_pub_key,
|
||||
'ssl_issuer' => $v_ssl_issuer,
|
||||
'letsencrypt' => $v_letsencrypt,
|
||||
'ssl_home' => $v_ssl_home,
|
||||
'backend_template' => $v_backend_template,
|
||||
'proxy' => $v_proxy,
|
||||
'proxy_template' => $v_proxy_template,
|
||||
'proxy_ext' => $v_proxy_ext,
|
||||
'v_stats' => $v_stats,
|
||||
'stats_user' => $v_stats_user,
|
||||
'ftp_user' => $v_ftp_user,
|
||||
'ftp_path' => $v_ftp_path,
|
||||
'ftp_password' => $v_ftp_password,
|
||||
'ftp_user_prepath' => $v_ftp_user_prepath,
|
||||
'ftp_email' => $v_ftp_email,
|
||||
'suspended' => $v_suspended,
|
||||
'status' => $v_status,
|
||||
'time' => $v_time,
|
||||
'date' => $v_date,
|
||||
'ips' => $ips,
|
||||
'prefixI18N' => __('Prefix will be automaticaly added to username',$user."_"),
|
||||
'ftp_users' => $v_ftp_users,
|
||||
'templates' => $templates,
|
||||
'backend_templates' => $backend_templates,
|
||||
'proxy_templates' => $proxy_templates,
|
||||
'stats' => $stats,
|
||||
'proxy_system' => $_SESSION['PROXY_SYSTEM'],
|
||||
'web_backend' => $_SESSION['WEB_BACKEND'],
|
||||
'web_system' => $_SESSION['WEB_SYSTEM'],
|
||||
'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