diff --git a/web/api/v1/add/cron/autoupdate/index.php b/web/api/v1/add/cron/autoupdate/index.php
new file mode 100644
index 000000000..843dc71a0
--- /dev/null
+++ b/web/api/v1/add/cron/autoupdate/index.php
@@ -0,0 +1,27 @@
+ $message,
+ 'error' => $error,
+);
+
+print json_encode($result);
diff --git a/web/api/v1/add/cron/index.php b/web/api/v1/add/cron/index.php
new file mode 100644
index 000000000..f9407df92
--- /dev/null
+++ b/web/api/v1/add/cron/index.php
@@ -0,0 +1,72 @@
+ $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_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']);
+
+ // Add cron job
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('CRON_CREATED_OK');
+ unset($v_min);
+ unset($v_hour);
+ unset($v_day);
+ unset($v_month);
+ unset($v_wday);
+ unset($v_cmd);
+ unset($output);
+ }
+}
+
+$result = array(
+ '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']);
diff --git a/web/api/v1/add/cron/reports/index.php b/web/api/v1/add/cron/reports/index.php
new file mode 100644
index 000000000..b4ada7cad
--- /dev/null
+++ b/web/api/v1/add/cron/reports/index.php
@@ -0,0 +1,25 @@
+ $message,
+ 'error' => $error
+);
+
+print json_encode($result);
diff --git a/web/api/v1/add/db/index.php b/web/api/v1/add/db/index.php
new file mode 100644
index 000000000..e633d6b97
--- /dev/null
+++ b/web/api/v1/add/db/index.php
@@ -0,0 +1,143 @@
+ $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
+ }
+
+ // Validate email
+ if ((!empty($_POST['v_db_email'])) && (empty($_SESSION['error_msg']))) {
+ if (!filter_var($_POST['v_db_email'], FILTER_VALIDATE_EMAIL)) {
+ $_SESSION['error_msg'] = __('Please enter valid email address.');
+ }
+ }
+
+ // Check password length
+ if (empty($_SESSION['error_msg'])) {
+ $pw_len = strlen($_POST['v_password']);
+ if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg);
+ }
+
+ // Protect input
+ $v_database = escapeshellarg($_POST['v_database']);
+ $v_dbuser = escapeshellarg($_POST['v_dbuser']);
+ $v_type = $_POST['v_type'];
+ $v_charset = $_POST['v_charset'];
+ $v_host = $_POST['v_host'];
+ $v_db_email = $_POST['v_db_email'];
+
+ // Add database
+ if (empty($_SESSION['error_msg'])) {
+ $v_type = escapeshellarg($_POST['v_type']);
+ $v_charset = escapeshellarg($_POST['v_charset']);
+ $v_host = escapeshellarg($_POST['v_host']);
+ $v_password = tempnam("/tmp","vst");
+ $fp = fopen($v_password, "w");
+ fwrite($fp, $_POST['v_password']."\n");
+ fclose($fp);
+ exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." ".$v_host." ".$v_charset, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ unlink($v_password);
+ $v_password = escapeshellarg($_POST['v_password']);
+ $v_type = $_POST['v_type'];
+ $v_host = $_POST['v_host'];
+ $v_charset = $_POST['v_charset'];
+ }
+
+ // Get database manager url
+ if (empty($_SESSION['error_msg'])) {
+ list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"] . ":");
+ if ($_POST['v_host'] != 'localhost' ) $http_host = $_POST['v_host'];
+ if ($_POST['v_type'] == 'mysql') $db_admin = "phpMyAdmin";
+ if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/";
+ if (($_POST['v_type'] == 'mysql') && (!empty($_SESSION['DB_PMA_URL']))) $db_admin_link = $_SESSION['DB_PMA_URL'];
+ if ($_POST['v_type'] == 'pgsql') $db_admin = "phpPgAdmin";
+ if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/";
+ if (($_POST['v_type'] == 'pgsql') && (!empty($_SESSION['DB_PGA_URL']))) $db_admin_link = $_SESSION['DB_PGA_URL'];
+ }
+
+ // Email login credentials
+ if ((!empty($v_db_email)) && (empty($_SESSION['error_msg']))) {
+ $to = $v_db_email;
+ $subject = __("Database Credentials");
+ $hostname = exec('hostname');
+ $from = __('MAIL_FROM',$hostname);
+ $mailtext = __('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link);
+ send_email($to, $subject, $mailtext, $from);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',htmlentities($user)."_".htmlentities($_POST['v_database']),htmlentities($user)."_".htmlentities($_POST['v_database']));
+ $_SESSION['ok_msg'] .= " / " . __('open %s',$db_admin) . "";
+ unset($v_database);
+ unset($v_dbuser);
+ unset($v_password);
+ unset($v_type);
+ unset($v_charset);
+ }
+}
+
+// Get user email
+$v_db_email = $panel[$user]['CONTACT'];
+
+// List avaiable database types
+$db_types = explode(',', $_SESSION['DB_SYSTEM']);
+
+// List available database servers
+exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var);
+$db_hosts_tmp1 = json_decode(implode('', $output), true);
+$db_hosts_tmp2 = array_map(function($host){return $host['HOST'];}, $db_hosts_tmp1);
+$db_hosts = array_values(array_unique($db_hosts_tmp2));
+unset($output);
+unset($db_hosts_tmp1);
+unset($db_hosts_tmp2);
+
+$prefixI18N = __('Prefix will be automaticaly added to database name and database user', "".$_SESSION['user']."_");
+$maxCharLength = __('maximum characters length, including prefix', 16);
+
+$result = array(
+ 'dbHosts' => $db_hosts,
+ 'dbTypes' => $db_types,
+ 'user' => $_SESSION['user'],
+ 'prefixI18N' => $prefixI18N,
+ 'maxCharLength' => $maxCharLength,
+ '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']);
diff --git a/web/api/v1/add/dns/index.php b/web/api/v1/add/dns/index.php
new file mode 100644
index 000000000..bb39939bc
--- /dev/null
+++ b/web/api/v1/add/dns/index.php
@@ -0,0 +1,188 @@
+ $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_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
+ $v_domain = escapeshellarg($v_domain);
+ $v_domain = strtolower($v_domain);
+ $v_ip = escapeshellarg($_POST['v_ip']);
+ $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']);
+
+ // Add dns domain
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4." ".$v_ns5." ".$v_ns6." ".$v_ns7." ".$v_ns8." no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+
+ // Set expiriation date
+ if (empty($_SESSION['error_msg'])) {
+ if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) {
+ $v_exp = escapeshellarg($_POST['v_exp']);
+ exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp." no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+ }
+
+ // Set ttl
+ if (empty($_SESSION['error_msg'])) {
+ if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400') && (empty($_SESSION['error_msg']))) {
+ $v_ttl = escapeshellarg($_POST['v_ttl']);
+ exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl." no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+ }
+
+ // Restart dns server
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-restart-dns", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ unset($v_domain);
+ }
+}
+
+
+// Check POST request for dns record
+if (!empty($_POST['ok_rec'])) {
+
+ // Check token
+ if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
+ header('location: /login/');
+ exit();
+ }
+
+ // Check empty fields
+ if (empty($_POST['v_domain'])) $errors[] = 'domain';
+ if (empty($_POST['v_rec'])) $errors[] = 'record';
+ if (empty($_POST['v_type'])) $errors[] = 'type';
+ if (empty($_POST['v_val'])) $errors[] = 'value';
+ 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_domain = escapeshellarg($_POST['v_domain']);
+ $v_rec = escapeshellarg($_POST['v_rec']);
+ $v_type = escapeshellarg($_POST['v_type']);
+ $v_val = escapeshellarg($_POST['v_val']);
+ $v_priority = escapeshellarg($_POST['v_priority']);
+
+ // Add dns record
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ $v_type = $_POST['v_type'];
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST[v_rec]),htmlentities($_POST[v_domain]));
+ unset($v_domain);
+ unset($v_rec);
+ unset($v_val);
+ unset($v_priority);
+ }
+}
+
+
+$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);
+
+
+if (empty($_GET['domain'])) {
+ // Display body for dns domain
+
+ if (empty($v_ttl)) $v_ttl = 14400;
+ if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year'));
+ if (empty($v_ns1)) {
+ exec (VESTA_CMD."v-list-user-ns ".$user." json", $output, $return_var);
+ $nameservers = json_decode(implode('', $output), true);
+ $v_ns1 = str_replace("'", "", $nameservers[0]);
+ $v_ns2 = str_replace("'", "", $nameservers[1]);
+ $v_ns3 = str_replace("'", "", $nameservers[2]);
+ $v_ns4 = str_replace("'", "", $nameservers[3]);
+ $v_ns5 = str_replace("'", "", $nameservers[4]);
+ $v_ns6 = str_replace("'", "", $nameservers[5]);
+ $v_ns7 = str_replace("'", "", $nameservers[6]);
+ $v_ns8 = str_replace("'", "", $nameservers[7]);
+ unset($output);
+ }
+
+ // render_page($user, $TAB, 'add_dns');
+} else {
+ // Display body for dns record
+
+ $v_domain = $_GET['domain'];
+ // render_page($user, $TAB, 'add_dns_rec');
+}
+
+$result = array(
+ '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']);
+
diff --git a/web/api/v1/add/favorite/index.php b/web/api/v1/add/favorite/index.php
new file mode 100644
index 000000000..94d48dadd
--- /dev/null
+++ b/web/api/v1/add/favorite/index.php
@@ -0,0 +1,22 @@
+
+
+error_reporting(NULL);
+session_start();
+
+
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Check token
+ // if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
+ // exit();
+ // }
+
+ // Protect input
+ $v_section = escapeshellarg($_REQUEST['v_section']);
+ $v_unit_id = escapeshellarg($_REQUEST['v_unit_id']);
+
+ $_SESSION['favourites'][strtoupper($_REQUEST['v_section'])][$_REQUEST['v_unit_id']] = 1;
+
+ exec (VESTA_CMD."v-add-user-favourites ".$_SESSION['user']." ".$v_section." ".$v_unit_id, $output, $return_var);
+// check_return_code($return_var,$output);
+?>
\ No newline at end of file
diff --git a/web/api/v1/add/firewall/banlist/index.php b/web/api/v1/add/firewall/banlist/index.php
new file mode 100644
index 000000000..e60b8066c
--- /dev/null
+++ b/web/api/v1/add/firewall/banlist/index.php
@@ -0,0 +1,68 @@
+ $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_chain = escapeshellarg($_POST['v_chain']);
+ $v_ip = escapeshellarg($_POST['v_ip']);
+
+ // Add firewall ban
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-firewall-ban ".$v_ip." ".$v_chain, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('BANLIST_CREATED_OK');
+ unset($v_ip);
+ }
+}
+
+$result = array(
+ 'ip' => $v_ip,
+ 'chain' => $v_chain,
+ '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']);
diff --git a/web/api/v1/add/firewall/index.php b/web/api/v1/add/firewall/index.php
new file mode 100644
index 000000000..0f6e69e27
--- /dev/null
+++ b/web/api/v1/add/firewall/index.php
@@ -0,0 +1,77 @@
+ $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_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']);
+
+ // Add firewall rule
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-firewall-rule ".$v_action." ".$v_ip." ".$v_port." ".$v_protocol." ".$v_comment, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('RULE_CREATED_OK');
+ unset($v_port);
+ unset($v_ip);
+ unset($v_comment);
+ }
+}
+
+// Render
+// render_page($user, $TAB, 'add_firewall');
+$result = array(
+ 'ok_msg' => $_SESSION['ok_msg'],
+ 'error_msg' => $_SESSION['error_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
\ No newline at end of file
diff --git a/web/api/v1/add/ip/index.php b/web/api/v1/add/ip/index.php
new file mode 100644
index 000000000..39a2959af
--- /dev/null
+++ b/web/api/v1/add/ip/index.php
@@ -0,0 +1,97 @@
+ $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_ip = escapeshellarg($_POST['v_ip']);
+ $v_netmask = escapeshellarg($_POST['v_netmask']);
+ $v_name = escapeshellarg($_POST['v_name']);
+ $v_nat = escapeshellarg($_POST['v_nat']);
+ $v_interface = escapeshellarg($_POST['v_interface']);
+ $v_owner = escapeshellarg($_POST['v_owner']);
+ $v_shared = $_POST['v_shared'];
+
+ // Check shared checkmark
+ if ($v_shared == 'on') {
+ $ip_status = 'shared';
+ } else {
+ $ip_status = 'dedicated';
+ $v_dedicated = 'yes';
+
+ }
+
+ // Add IP
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." ".$ip_status." ".$v_name." ".$v_nat, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ $v_owner = $_POST['v_owner'];
+ $v_interface = $_POST['v_interface'];
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('IP_CREATED_OK',htmlentities($_POST['v_ip']),htmlentities($_POST['v_ip']));
+ unset($v_ip);
+ unset($v_netmask);
+ unset($v_name);
+ unset($v_nat);
+ }
+}
+
+// List network interfaces
+exec (VESTA_CMD."v-list-sys-interfaces json", $output, $return_var);
+$interfaces = json_decode(implode('', $output), true);
+unset($output);
+
+// List users
+exec (VESTA_CMD."v-list-sys-users json", $output, $return_var);
+$users = json_decode(implode('', $output), true);
+unset($output);
+
+$result = array(
+ 'interfaces' => $interfaces,
+ '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']);
diff --git a/web/api/v1/add/mail/index.php b/web/api/v1/add/mail/index.php
new file mode 100644
index 000000000..8f5899587
--- /dev/null
+++ b/web/api/v1/add/mail/index.php
@@ -0,0 +1,219 @@
+ $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
+ }
+
+ // Check antispam option
+ if (!empty($_POST['v_antispam'])) {
+ $v_antispam = 'yes';
+ } else {
+ $v_antispam = 'no';
+ }
+
+ // Check antivirus option
+ if (!empty($_POST['v_antivirus'])) {
+ $v_antivirus = 'yes';
+ } else {
+ $v_antivirus = 'no';
+ }
+
+ // Check dkim option
+ if (!empty($_POST['v_dkim'])) {
+ $v_dkim = 'yes';
+ } else {
+ $v_dkim = 'no';
+ }
+
+ // Set domain name to lowercase and remove www prefix
+ $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
+ $v_domain = escapeshellarg($v_domain);
+ $v_domain = strtolower($v_domain);
+
+ // Add mail domain
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain." ".$v_antispam." ".$v_antivirus." ".$v_dkim, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('MAIL_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
+ unset($v_domain);
+ }
+}
+
+
+// Check POST request for mail account
+if (!empty($_POST['ok_acc'])) {
+
+ // Check token
+ if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
+ exit();
+ }
+
+ // Check empty fields
+ if (empty($_POST['v_domain'])) $errors[] = __('domain');
+ if (empty($_POST['v_account'])) $errors[] = __('account');
+ if (empty($_POST['v_password'])) $errors[] = __('password');
+ 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);
+ }
+
+ // 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.');
+ }
+ }
+
+ // Protect input
+ $v_domain = escapeshellarg($_POST['v_domain']);
+ $v_domain = strtolower($v_domain);
+ $v_account = escapeshellarg($_POST['v_account']);
+ $v_quota = escapeshellarg($_POST['v_quota']);
+ $v_send_email = $_POST['v_send_email'];
+ $v_credentials = $_POST['v_credentials'];
+ $v_aliases = $_POST['v_aliases'];
+ $v_fwd = $_POST['v_fwd'];
+ if (empty($_POST['v_quota'])) $v_quota = 0;
+ if ((!empty($_POST['v_quota'])) || (!empty($_POST['v_aliases'])) || (!empty($_POST['v_fwd'])) ) $v_adv = 'yes';
+
+ // Add Mail Account
+ if (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-add-mail-account ".$user." ".$v_domain." ".$v_account." ".$v_password." ".$v_quota, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ unlink($v_password);
+ $v_password = escapeshellarg($_POST['v_password']);
+ }
+
+ // Add Aliases
+ if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) {
+ $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']);
+ $valiases = preg_replace("/,/", " ", $valiases);
+ $valiases = preg_replace('/\s+/', ' ',$valiases);
+ $valiases = trim($valiases);
+ $aliases = explode(" ", $valiases);
+ foreach ($aliases as $alias) {
+ $alias = escapeshellarg($alias);
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-mail-account-alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+ }
+ }
+
+ // Add Forwarders
+ if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) {
+ $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
+ $vfwd = preg_replace("/,/", " ", $vfwd);
+ $vfwd = preg_replace('/\s+/', ' ',$vfwd);
+ $vfwd = trim($vfwd);
+ $fwd = explode(" ", $vfwd);
+ foreach ($fwd as $forward) {
+ $forward = escapeshellarg($forward);
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+ }
+ }
+
+ // Add fwd_only flag
+ if ((!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-add-mail-account-fwd-only ".$user." ".$v_domain." ".$v_account, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Get webmail url
+ if (empty($_SESSION['error_msg'])) {
+ list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
+ $webmail = "http://".$http_host."/webmail/";
+ if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL'];
+ }
+
+ // 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);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]));
+ $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
+ unset($v_account);
+ unset($v_password);
+ unset($v_password);
+ unset($v_aliases);
+ unset($v_fwd);
+ unset($v_quota);
+ }
+}
+
+// Render page
+if (empty($_GET['domain'])) {
+ // Display body for mail domain
+
+ // render_page($user, $TAB, 'add_mail');
+} else {
+ // Display body for mail account
+
+ $v_domain = $_GET['domain'];
+ // render_page($user, $TAB, 'add_mail_acc');
+}
+
+$result = array(
+ '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']);
\ No newline at end of file
diff --git a/web/api/v1/add/package/index.php b/web/api/v1/add/package/index.php
new file mode 100644
index 000000000..055d0e9c1
--- /dev/null
+++ b/web/api/v1/add/package/index.php
@@ -0,0 +1,224 @@
+ $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']);
+ $v_backend_template = escapeshellarg($_POST['v_backend_template']);
+ $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 temporary dir
+ if (empty($_SESSION['error_msg'])) {
+ exec ('mktemp -d', $output, $return_var);
+ $tmpdir = $output[0];
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Create package file
+ if (empty($_SESSION['error_msg'])) {
+ $pkg = "WEB_TEMPLATE=".$v_web_template."\n";
+ if (!empty($_SESSION['WEB_BACKEND'])) {
+ $pkg .= "BACKEND_TEMPLATE=".$v_backend_template."\n";
+ }
+ if (!empty($_SESSION['PROXY_SYSTEM'])) {
+ $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);
+ }
+
+ // Add new package
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Remove tmpdir
+ exec ('rm -rf '.$tmpdir, $output, $return_var);
+ unset($output);
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('PACKAGE_CREATED_OK',htmlentities($_POST['v_package']),htmlentities($_POST['v_package']));
+ unset($v_package);
+ }
+
+}
+
+
+// List web temmplates
+exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
+$web_templates = json_decode(implode('', $output), true);
+unset($output);
+
+// List web templates for backend
+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 web templates for proxy
+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 system shells
+exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var);
+$shells = json_decode(implode('', $output), true);
+unset($output);
+
+// Set default values
+if (empty($v_web_template)) $v_web_template = 'default';
+if (empty($v_backend_template)) $v_backend_template = 'default';
+if (empty($v_proxy_template)) $v_proxy_template = 'default';
+if (empty($v_dns_template)) $v_dns_template = 'default';
+if (empty($v_shell)) $v_shell = 'nologin';
+if (empty($v_web_domains)) $v_web_domains = "'1'";
+if (empty($v_web_aliases)) $v_web_aliases = "'1'";
+if (empty($v_dns_domains)) $v_dns_domains = "'1'";
+if (empty($v_dns_records)) $v_dns_records = "'1'";
+if (empty($v_mail_domains)) $v_mail_domains = "'1'";
+if (empty($v_mail_accounts)) $v_mail_accounts = "'1'";
+if (empty($v_databases)) $v_databases = "'1'";
+if (empty($v_cron_jobs)) $v_cron_jobs = "'1'";
+if (empty($v_backups)) $v_backups = "'1'";
+if (empty($v_disk_quota)) $v_disk_quota = "'1000'";
+if (empty($v_bandwidth)) $v_bandwidth = "'1000'";
+if (empty($v_ns1)) $v_ns1 = 'ns1.example.ltd';
+if (empty($v_ns2)) $v_ns2 = 'ns2.example.ltd';
+
+// Render page
+// render_page($user, $TAB, 'add_package');
+
+$result = array(
+ 'web_system' => $_SESSION['WEB_SYSTEM'],
+ 'web_templates' => $web_templates,
+ 'web_backend' => $_SESSION['WEB_BACKEND'],
+ 'backend_templates' => $backend_templates,
+ 'proxy_system' => $_SESSION['PROXY_SYSTEM'],
+ 'proxy_templates' => $proxy_templates,
+ 'dns_system' => $_SESSION['DNS_SYSTEM'],
+ 'dns_templates' => $dns_templates,
+ 'ssh_access' => $shells,
+ 'ok_msg' => $_SESSION['ok_msg'],
+ 'error_msg' => $_SESSION['error_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
\ No newline at end of file
diff --git a/web/api/v1/add/user/index.php b/web/api/v1/add/user/index.php
new file mode 100644
index 000000000..5057b774a
--- /dev/null
+++ b/web/api/v1/add/user/index.php
@@ -0,0 +1,131 @@
+ $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
+ }
+
+ // Validate email
+ if ((empty($_SESSION['error_msg'])) && (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL))) {
+ $_SESSION['error_msg'] = __('Please enter valid email address.');
+ }
+
+ // Check password length
+ if (empty($_SESSION['error_msg'])) {
+ $pw_len = strlen($_POST['v_password']);
+ if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg);
+ }
+
+ // Protect input
+ $v_username = escapeshellarg($_POST['v_username']);
+ $v_email = escapeshellarg($_POST['v_email']);
+ $v_package = escapeshellarg($_POST['v_package']);
+ $v_language = escapeshellarg($_POST['v_language']);
+ $v_fname = escapeshellarg($_POST['v_fname']);
+ $v_lname = escapeshellarg($_POST['v_lname']);
+ $v_notify = $_POST['v_notify'];
+
+
+ // Add user
+ if (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-add-user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ unlink($v_password);
+ $v_password = escapeshellarg($_POST['v_password']);
+ }
+
+ // Set language
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-change-user-language ".$v_username." ".$v_language, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Send email to the new user
+ if ((empty($_SESSION['error_msg'])) && (!empty($v_notify))) {
+ $to = $_POST['v_notify'];
+ $subject = _translate($_POST['v_language'],"Welcome to Vesta Control Panel");
+ $hostname = exec('hostname');
+ unset($output);
+ $from = _translate($_POST['v_language'],'MAIL_FROM',$hostname);
+ if (!empty($_POST['v_fname'])) {
+ $mailtext = _translate($_POST['v_language'],'GREETINGS_GORDON_FREEMAN',$_POST['v_fname'],$_POST['v_lname']);
+ } else {
+ $mailtext = _translate($_POST['v_language'],'GREETINGS');
+ }
+ $mailtext .= _translate($_POST['v_language'],'ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']);
+ send_email($to, $subject, $mailtext, $from);
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('USER_CREATED_OK',htmlentities($_POST['v_username']),htmlentities($_POST['v_username']));
+ $_SESSION['ok_msg'] .= " / " . __('login as') ." ".htmlentities($_POST['v_username']). "";
+ unset($v_username);
+ unset($v_password);
+ unset($v_email);
+ unset($v_fname);
+ unset($v_lname);
+ unset($v_notify);
+ }
+}
+
+
+// List hosting packages
+exec (VESTA_CMD."v-list-user-packages json", $output, $return_var);
+check_error($return_var);
+$data = 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);
+
+$result = array(
+ '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']);
\ No newline at end of file
diff --git a/web/api/v1/add/web/index.php b/web/api/v1/add/web/index.php
new file mode 100644
index 000000000..182d1081e
--- /dev/null
+++ b/web/api/v1/add/web/index.php
@@ -0,0 +1,371 @@
+ $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
+ }
+
+ // Check stats password length
+ if ((!empty($v_stats)) && (empty($_SESSION['error_msg']))) {
+ if (!empty($_POST['v_stats_user'])) {
+ $pw_len = strlen($_POST['v_stats_password']);
+ if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg);
+ }
+ }
+
+ // Set domain to lowercase and remove www prefix
+ $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']);
+ $v_domain = escapeshellarg($v_domain);
+ $v_domain = strtolower($v_domain);
+
+ // Define domain ip address
+ $v_ip = escapeshellarg($_POST['v_ip']);
+
+ // Using public IP instead of internal IP when creating DNS
+ // Gets public IP from 'v-list-user-ips' command (that reads /vesta/data/ips/ip), precisely from 'NAT' field
+ $v_public_ip = $v_ip;
+ $v_clean_ip = $_POST['v_ip']; // clean_ip = IP without quotas
+ exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
+ $ips = json_decode(implode('', $output), true);
+ unset($output);
+ if (isset($ips[$v_clean_ip]) && isset($ips[$v_clean_ip]['NAT']) && trim($ips[$v_clean_ip]['NAT'])!='') {
+ $v_public_ip = trim($ips[$v_clean_ip]['NAT']);
+ $v_public_ip = escapeshellarg($v_public_ip);
+ }
+
+ // Define domain aliases
+ $v_aliases = $_POST['v_aliases'];
+ $aliases = preg_replace("/\n/", ",", $v_aliases);
+ $aliases = preg_replace("/\r/", ",", $aliases);
+ $aliases = preg_replace("/\t/", ",", $aliases);
+ $aliases = preg_replace("/ /", ",", $aliases);
+ $aliases_arr = explode(",", $aliases);
+ $aliases_arr = array_unique($aliases_arr);
+ $aliases_arr = array_filter($aliases_arr);
+ $aliases = implode(",",$aliases_arr);
+ $aliases = escapeshellarg($aliases);
+ if (empty($_POST['v_aliases'])) $aliases = 'none';
+
+ // Define proxy extensions
+ $v_proxy_ext = $_POST['v_proxy_ext'];
+ $proxy_ext = preg_replace("/\n/", ",", $v_proxy_ext);
+ $proxy_ext = preg_replace("/\r/", ",", $proxy_ext);
+ $proxy_ext = preg_replace("/\t/", ",", $proxy_ext);
+ $proxy_ext = preg_replace("/ /", ",", $proxy_ext);
+ $proxy_ext_arr = explode(",", $proxy_ext);
+ $proxy_ext_arr = array_unique($proxy_ext_arr);
+ $proxy_ext_arr = array_filter($proxy_ext_arr);
+ $proxy_ext = implode(",",$proxy_ext_arr);
+ $proxy_ext = escapeshellarg($proxy_ext);
+
+ // Define other options
+ $v_elog = $_POST['v_elog'];
+ $v_ssl = $_POST['v_ssl'];
+ $v_ssl_crt = $_POST['v_ssl_crt'];
+ $v_ssl_key = $_POST['v_ssl_key'];
+ $v_ssl_ca = $_POST['v_ssl_ca'];
+ $v_ssl_home = $data[$v_domain]['SSL_HOME'];
+ $v_letsencrypt = $_POST['v_letsencrypt'];
+ $v_stats = escapeshellarg($_POST['v_stats']);
+ $v_stats_user = $data[$v_domain]['STATS_USER'];
+ $v_stats_password = $data[$v_domain]['STATS_PASSWORD'];
+ $v_ftp = $_POST['v_ftp'];
+ $v_ftp_user = $_POST['v_ftp_user'];
+ $v_ftp_password = $_POST['v_ftp_password'];
+ $v_ftp_email = $_POST['v_ftp_email'];
+ if (!empty($v_domain)) $v_ftp_user_prepath .= $v_domain;
+
+ // Set advanced option checkmark
+ if (!empty($_POST['v_proxy'])) $v_adv = 'yes';
+ if (!empty($_POST['v_ftp'])) $v_adv = 'yes';
+ if ($_POST['v_proxy_ext'] != $v_proxy_ext) $v_adv = 'yes';
+ if ((!empty($_POST['v_aliases'])) && ($_POST['v_aliases'] != 'www.'.$_POST['v_domain'])) $v_adv = 'yes';
+ if ((!empty($_POST['v_ssl'])) || (!empty($_POST['v_elog']))) $v_adv = 'yes';
+ if ((!empty($_POST['v_ssl_crt'])) || (!empty($_POST['v_ssl_key']))) $v_adv = 'yes';
+ if ((!empty($_POST['v_ssl_ca'])) || ($_POST['v_stats'] != 'none')) $v_adv = 'yes';
+ if ((!empty($_POST['v_letsencrypt']))) $v_adv = 'yes';
+
+ // Check advanced features
+ if (empty($_POST['v_dns'])) $v_dns = 'off';
+ if (empty($_POST['v_mail'])) $v_mail = 'off';
+ if (empty($_POST['v_proxy'])) $v_proxy = 'off';
+
+ // Add web domain
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-web-domain ".$user." ".$v_domain." ".$v_ip." no ".$aliases." ".$proxy_ext, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ $domain_added = empty($_SESSION['error_msg']);
+ }
+
+ // Add DNS domain
+ if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_public_ip." '' '' '' '' '' '' '' '' no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Add DNS for domain aliases
+ if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
+ foreach ($aliases_arr as $alias) {
+ if ($alias != "www.".$_POST['v_domain']) {
+ $alias = escapeshellarg($alias);
+ exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$alias." ".$v_ip." no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+ }
+ }
+
+ // Add mail domain
+ if (($_POST['v_mail'] == 'on') && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Delete proxy support
+ if ((!empty($_SESSION['PROXY_SYSTEM'])) && ($_POST['v_proxy'] == 'off') && (empty($_SESSION['error_msg']))) {
+ $ext = escapeshellarg($ext);
+ exec (VESTA_CMD."v-delete-web-domain-proxy ".$user." ".$v_domain." no", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Add Lets Encrypt support
+ if ((!empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-schedule-letsencrypt-domain ".$user." ".$v_domain, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ } else {
+ // Add SSL certificates only if Lets Encrypt is off
+ if ((!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
+ exec ('mktemp -d', $output, $return_var);
+ $tmpdir = $output[0];
+ unset($output);
+
+ // Save 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);
+ }
+
+ // Save private 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);
+ }
+
+ // Save CA bundle
+ 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);
+ }
+
+ $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
+ 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);
+ }
+ }
+
+ // Add web stats
+ if ((!empty($_POST['v_stats'])) && ($_POST['v_stats'] != 'none' ) && (empty($_SESSION['error_msg']))) {
+ $v_stats = escapeshellarg($_POST['v_stats']);
+ exec (VESTA_CMD."v-add-web-domain-stats ".$user." ".$v_domain." ".$v_stats, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Add web stats password
+ if ((!empty($_POST['v_stats_user'])) && (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 ".$user." ".$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']);
+ }
+
+ // Restart DNS server
+ if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-restart-dns", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Restart web server
+ if (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'])) && ($_POST['v_proxy'] == 'on') && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-restart-proxy", $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ }
+
+ // Add FTP
+ if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
+ $v_ftp_users_updated = array();
+ foreach ($_POST['v_ftp_user'] as $i => $v_ftp_user_data) {
+ if ($v_ftp_user_data['is_new'] == 1) {
+ 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($v_ftp_user_data['v_ftp_password'])) $errors[] = 'ftp user password';
+ 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);
+ }
+
+ // Validate email
+ 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.');
+ }
+
+ // Check ftp password length
+ if ((!empty($v_ftp_user_data['v_ftp']))) {
+ if (!empty($v_ftp_user_data['v_ftp_user'])) {
+ $pw_len = strlen($v_ftp_user_data['v_ftp_password']);
+ if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg);
+ }
+ }
+
+ $v_ftp_user_data['v_ftp_user'] = preg_replace("/^".$user."_/i", "", $v_ftp_user_data['v_ftp_user']);
+ $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_user_data['v_ftp_user']);
+ if ($domain_added) {
+ $v_ftp_path = escapeshellarg(trim($v_ftp_user_data['v_ftp_path']));
+ $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 ".$user." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password . " " . $v_ftp_path, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+ unlink($v_ftp_password);
+ 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");
+ $from = __('MAIL_FROM',$_POST['v_domain']);
+ $mailtext = __('FTP_ACCOUNT_READY',$_POST['v_domain'],$user,$v_ftp_user_data['v_ftp_user'],$v_ftp_user_data['v_ftp_password']);
+ send_email($to, $subject, $mailtext, $from);
+ unset($v_ftp_email);
+ }
+ } else {
+ $return_var = -1;
+ }
+
+ if ($return_var == 0) {
+ $v_ftp_password = "••••••••";
+ $v_ftp_user_data['is_new'] = 0;
+ } else {
+ $v_ftp_user_data['is_new'] = 1;
+ }
+
+ $v_ftp_username = preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']);
+ $v_ftp_users_updated[] = array(
+ 'is_new' => $v_ftp_user_data['is_new'],
+ 'v_ftp_user' => $return_var == 0 ? $v_ftp_username_full : $v_ftp_username,
+ '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;
+ }
+ }
+
+ if (!empty($_SESSION['error_msg']) && $domain_added) {
+ $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ $_SESSION['flash_error_msg'] = $_SESSION['error_msg'];
+ $url = '/edit/web/?domain='.strtolower(preg_replace("/^www\./i", "", $_POST['v_domain']));
+ header('Location: ' . $url);
+ exit;
+ }
+ }
+
+ // Flush field values on success
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
+ unset($v_domain);
+ unset($v_aliases);
+ unset($v_ssl);
+ unset($v_ssl_crt);
+ unset($v_ssl_key);
+ unset($v_ssl_ca);
+ unset($v_stats_user);
+ unset($v_stats_password);
+ unset($v_ftp);
+ }
+}
+
+// Define user variables
+$v_ftp_user_prepath = $panel[$user]['HOME'] . "/web";
+$v_ftp_email = $panel[$user]['CONTACT'];
+
+// 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 stat engines
+exec (VESTA_CMD."v-list-web-stats json", $output, $return_var);
+$stats = json_decode(implode('', $output), true);
+unset($output);
+
+$result = array(
+ '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']);
\ No newline at end of file
diff --git a/web/api/v1/bulk/backup/exclusions/index.php b/web/api/v1/bulk/backup/exclusions/index.php
new file mode 100644
index 000000000..ccef8de5f
--- /dev/null
+++ b/web/api/v1/bulk/backup/exclusions/index.php
@@ -0,0 +1,31 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/backup/index.php b/web/api/v1/bulk/backup/index.php
new file mode 100644
index 000000000..aa7f1f6c5
--- /dev/null
+++ b/web/api/v1/bulk/backup/index.php
@@ -0,0 +1,35 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/cron/index.php b/web/api/v1/bulk/cron/index.php
new file mode 100644
index 000000000..5fd80765d
--- /dev/null
+++ b/web/api/v1/bulk/cron/index.php
@@ -0,0 +1,77 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/db/index.php b/web/api/v1/bulk/db/index.php
new file mode 100644
index 000000000..a0fa65fa0
--- /dev/null
+++ b/web/api/v1/bulk/db/index.php
@@ -0,0 +1,48 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/dns/index.php b/web/api/v1/bulk/dns/index.php
new file mode 100644
index 000000000..4340e9222
--- /dev/null
+++ b/web/api/v1/bulk/dns/index.php
@@ -0,0 +1,86 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/firewall/banlist/index.php b/web/api/v1/bulk/firewall/banlist/index.php
new file mode 100644
index 000000000..51e2f1ad5
--- /dev/null
+++ b/web/api/v1/bulk/firewall/banlist/index.php
@@ -0,0 +1,44 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/firewall/index.php b/web/api/v1/bulk/firewall/index.php
new file mode 100644
index 000000000..99acda51f
--- /dev/null
+++ b/web/api/v1/bulk/firewall/index.php
@@ -0,0 +1,49 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/ip/index.php b/web/api/v1/bulk/ip/index.php
new file mode 100644
index 000000000..3f252256b
--- /dev/null
+++ b/web/api/v1/bulk/ip/index.php
@@ -0,0 +1,43 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/mail/index.php b/web/api/v1/bulk/mail/index.php
new file mode 100644
index 000000000..590422b71
--- /dev/null
+++ b/web/api/v1/bulk/mail/index.php
@@ -0,0 +1,82 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/package/index.php b/web/api/v1/bulk/package/index.php
new file mode 100644
index 000000000..69f402d1f
--- /dev/null
+++ b/web/api/v1/bulk/package/index.php
@@ -0,0 +1,42 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/restore/index.php b/web/api/v1/bulk/restore/index.php
new file mode 100644
index 000000000..453f2e87d
--- /dev/null
+++ b/web/api/v1/bulk/restore/index.php
@@ -0,0 +1,56 @@
+', $output);
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['error_msg'] = __('Error: vesta did not return any output.');
+ }
+ if ($return_var == 4) {
+ $_SESSION['error_msg'] = __('RESTORE_EXISTS');
+ }
+ }
+}
+
+header('Content-Type: application/json');
+$result = array(
+ 'error' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/service/index.php b/web/api/v1/bulk/service/index.php
new file mode 100644
index 000000000..e100482d6
--- /dev/null
+++ b/web/api/v1/bulk/service/index.php
@@ -0,0 +1,49 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/user/index.php b/web/api/v1/bulk/user/index.php
new file mode 100644
index 000000000..213a84f88
--- /dev/null
+++ b/web/api/v1/bulk/user/index.php
@@ -0,0 +1,69 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/vesta/index.php b/web/api/v1/bulk/vesta/index.php
new file mode 100644
index 000000000..63b273384
--- /dev/null
+++ b/web/api/v1/bulk/vesta/index.php
@@ -0,0 +1,38 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/bulk/web/index.php b/web/api/v1/bulk/web/index.php
new file mode 100644
index 000000000..71e906364
--- /dev/null
+++ b/web/api/v1/bulk/web/index.php
@@ -0,0 +1,55 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/backup/exclusion/index.php b/web/api/v1/delete/backup/exclusion/index.php
new file mode 100644
index 000000000..dd2c3e879
--- /dev/null
+++ b/web/api/v1/delete/backup/exclusion/index.php
@@ -0,0 +1,28 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/backup/index.php b/web/api/v1/delete/backup/index.php
new file mode 100644
index 000000000..9d8bc9728
--- /dev/null
+++ b/web/api/v1/delete/backup/index.php
@@ -0,0 +1,34 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/cron/autoupdate/index.php b/web/api/v1/delete/cron/autoupdate/index.php
new file mode 100644
index 000000000..f26de9987
--- /dev/null
+++ b/web/api/v1/delete/cron/autoupdate/index.php
@@ -0,0 +1,28 @@
+ $message,
+ 'error' => $error
+);
+
+print json_encode($result);
diff --git a/web/api/v1/delete/cron/index.php b/web/api/v1/delete/cron/index.php
new file mode 100644
index 000000000..a0d700df2
--- /dev/null
+++ b/web/api/v1/delete/cron/index.php
@@ -0,0 +1,34 @@
+
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/cron/reports/index.php b/web/api/v1/delete/cron/reports/index.php
new file mode 100644
index 000000000..7ab5db428
--- /dev/null
+++ b/web/api/v1/delete/cron/reports/index.php
@@ -0,0 +1,26 @@
+ $message,
+ 'error' => $error,
+);
+
+print json_encode($result);
diff --git a/web/api/v1/delete/db/index.php b/web/api/v1/delete/db/index.php
new file mode 100644
index 000000000..ae5eeada7
--- /dev/null
+++ b/web/api/v1/delete/db/index.php
@@ -0,0 +1,33 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/dns/index.php b/web/api/v1/delete/dns/index.php
new file mode 100644
index 000000000..9078999ad
--- /dev/null
+++ b/web/api/v1/delete/dns/index.php
@@ -0,0 +1,45 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/favorite/index.php b/web/api/v1/delete/favorite/index.php
new file mode 100644
index 000000000..9f471b9bd
--- /dev/null
+++ b/web/api/v1/delete/favorite/index.php
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/web/api/v1/delete/firewall/banlist/index.php b/web/api/v1/delete/firewall/banlist/index.php
new file mode 100644
index 000000000..e58cea61a
--- /dev/null
+++ b/web/api/v1/delete/firewall/banlist/index.php
@@ -0,0 +1,36 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/firewall/index.php b/web/api/v1/delete/firewall/index.php
new file mode 100644
index 000000000..c90fa7461
--- /dev/null
+++ b/web/api/v1/delete/firewall/index.php
@@ -0,0 +1,35 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/ip/index.php b/web/api/v1/delete/ip/index.php
new file mode 100644
index 000000000..6c4ab74a3
--- /dev/null
+++ b/web/api/v1/delete/ip/index.php
@@ -0,0 +1,31 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/mail/index.php b/web/api/v1/delete/mail/index.php
new file mode 100644
index 000000000..2f6f2f82a
--- /dev/null
+++ b/web/api/v1/delete/mail/index.php
@@ -0,0 +1,45 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/notification/index.php b/web/api/v1/delete/notification/index.php
new file mode 100644
index 000000000..5aedaa5d0
--- /dev/null
+++ b/web/api/v1/delete/notification/index.php
@@ -0,0 +1,28 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/user/index.php b/web/api/v1/delete/user/index.php
new file mode 100644
index 000000000..a85982ef4
--- /dev/null
+++ b/web/api/v1/delete/user/index.php
@@ -0,0 +1,31 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/delete/web/index.php b/web/api/v1/delete/web/index.php
new file mode 100644
index 000000000..46a4aea83
--- /dev/null
+++ b/web/api/v1/delete/web/index.php
@@ -0,0 +1,34 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+ );
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/download/backup/index.php b/web/api/v1/download/backup/index.php
new file mode 100644
index 000000000..068467148
--- /dev/null
+++ b/web/api/v1/download/backup/index.php
@@ -0,0 +1,26 @@
+
diff --git a/web/api/v1/edit/backup/exclusions/index.php b/web/api/v1/edit/backup/exclusions/index.php
new file mode 100644
index 000000000..13bd32c97
--- /dev/null
+++ b/web/api/v1/edit/backup/exclusions/index.php
@@ -0,0 +1,143 @@
+ $value) {
+ if (!empty($value)){
+ $v_web .= $key . ":" . $value. "\n";
+ } else {
+ $v_web .= $key . "\n";
+ }
+}
+
+// Parse dns
+foreach ($data['DNS'] as $key => $value) {
+ if (!empty($value)){
+ $v_dns .= $key . ":" . $value. "\n";
+ } else {
+ $v_dns .= $key . "\n";
+ }
+}
+
+// Parse mail
+foreach ($data['MAIL'] as $key => $value) {
+ if (!empty($value)){
+ $v_mail .= $key . ":" . $value. "\n";
+ } else {
+ $v_mail .= $key . "\n";
+ }
+}
+
+// Parse databases
+foreach ($data['DB'] as $key => $value) {
+ if (!empty($value)){
+ $v_db .= $key . ":" . $value. "\n";
+ } else {
+ $v_db .= $key . "\n";
+ }
+}
+
+// Parse user directories
+foreach ($data['USER'] as $key => $value) {
+ if (!empty($value)){
+ $v_userdir .= $key . ":" . $value. "\n";
+ } else {
+ $v_userdir .= $key . "\n";
+ }
+}
+
+// Check POST request
+if (!empty($_POST['save'])) {
+
+ // Check token
+ if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
+ exit();
+ }
+
+ $v_web = $_POST['v_web'];
+ $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']);
+ $v_web_tmp = rtrim($v_web_tmp, ",");
+ $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp);
+
+ $v_dns = $_POST['v_dns'];
+ $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']);
+ $v_dns_tmp = rtrim($v_dns_tmp, ",");
+ $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp);
+
+ $v_mail = $_POST['v_mail'];
+ $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']);
+ $v_mail_tmp = rtrim($v_mail_tmp, ",");
+ $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp);
+
+ $v_db = $_POST['v_db'];
+ $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']);
+ $v_db_tmp = rtrim($v_db_tmp, ",");
+ $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp);
+
+ $v_cron = $_POST['v_cron'];
+ $v_cron_tmp = str_replace("\r\n", ",", $_POST['v_cron']);
+ $v_cron_tmp = rtrim($v_cron_tmp, ",");
+ $v_cron_tmp = "CRON=" . escapeshellarg($v_cron_tmp);
+
+ $v_userdir = $_POST['v_userdir'];
+ $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']);
+ $v_userdir_tmp = rtrim($v_userdir_tmp, ",");
+ $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp);
+
+ // Create temporary exeption list on a filesystem
+ exec ('mktemp', $mktemp_output, $return_var);
+ $tmp = $mktemp_output[0];
+ $fp = fopen($tmp, 'w');
+ fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n");
+ fclose($fp);
+ unset($mktemp_output);
+
+ // Save changes
+ exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var);
+ check_return_code($return_var,$output);
+ unset($output);
+
+ // Set success message
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = __("Changes has been saved.");
+ }
+}
+
+
+// Render page
+// render_page($user, $TAB, 'edit_backup_exclusions');
+
+$result = array(
+ 'web' => $v_web,
+ 'dns' => $v_dns,
+ 'mail' => $v_mail,
+ 'db' => $v_db,
+ 'userdir' => $v_userdir,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/edit/cron/index.php b/web/api/v1/edit/cron/index.php
new file mode 100644
index 000000000..697c04922
--- /dev/null
+++ b/web/api/v1/edit/cron/index.php
@@ -0,0 +1,102 @@
+ $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']);
diff --git a/web/api/v1/edit/db/index.php b/web/api/v1/edit/db/index.php
new file mode 100644
index 000000000..7aaced147
--- /dev/null
+++ b/web/api/v1/edit/db/index.php
@@ -0,0 +1,109 @@
+ $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']);
diff --git a/web/api/v1/edit/dns/index.php b/web/api/v1/edit/dns/index.php
new file mode 100644
index 000000000..74aae592c
--- /dev/null
+++ b/web/api/v1/edit/dns/index.php
@@ -0,0 +1,225 @@
+ $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']);
diff --git a/web/api/v1/edit/file/index.php b/web/api/v1/edit/file/index.php
new file mode 100644
index 000000000..9f08e497d
--- /dev/null
+++ b/web/api/v1/edit/file/index.php
@@ -0,0 +1,51 @@
+ $error,
+ 'content' => $content
+);
+
+echo json_encode($result);
diff --git a/web/api/v1/edit/firewall/index.php b/web/api/v1/edit/firewall/index.php
new file mode 100644
index 000000000..37c9e9cc3
--- /dev/null
+++ b/web/api/v1/edit/firewall/index.php
@@ -0,0 +1,103 @@
+ $_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']);
diff --git a/web/api/v1/edit/ip/index.php b/web/api/v1/edit/ip/index.php
new file mode 100644
index 000000000..006e89767
--- /dev/null
+++ b/web/api/v1/edit/ip/index.php
@@ -0,0 +1,124 @@
+ $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']);
diff --git a/web/api/v1/edit/mail/index.php b/web/api/v1/edit/mail/index.php
new file mode 100644
index 000000000..47de71b33
--- /dev/null
+++ b/web/api/v1/edit/mail/index.php
@@ -0,0 +1,372 @@
+ $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']);
diff --git a/web/api/v1/edit/package/index.php b/web/api/v1/edit/package/index.php
new file mode 100644
index 000000000..c16ef4bdb
--- /dev/null
+++ b/web/api/v1/edit/package/index.php
@@ -0,0 +1,270 @@
+ $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']);
diff --git a/web/api/v1/edit/server/apache2/index.php b/web/api/v1/edit/server/apache2/index.php
new file mode 100644
index 000000000..e23a31f57
--- /dev/null
+++ b/web/api/v1/edit/server/apache2/index.php
@@ -0,0 +1,66 @@
+ $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']);
diff --git a/web/api/v1/edit/server/bind9/index.php b/web/api/v1/edit/server/bind9/index.php
new file mode 100644
index 000000000..4fff011db
--- /dev/null
+++ b/web/api/v1/edit/server/bind9/index.php
@@ -0,0 +1,82 @@
+ $v_options_path,
+ 'config_path' => $v_config_path,
+ 'service_name' => $v_service_name,
+ 'options' => $v_options,
+ 'config' => $v_config,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/edit/server/clamd/index.php b/web/api/v1/edit/server/clamd/index.php
new file mode 100644
index 000000000..fef8c95b3
--- /dev/null
+++ b/web/api/v1/edit/server/clamd/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/cron/index.php b/web/api/v1/edit/server/cron/index.php
new file mode 100644
index 000000000..02f5a6c64
--- /dev/null
+++ b/web/api/v1/edit/server/cron/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/crond/index.php b/web/api/v1/edit/server/crond/index.php
new file mode 100644
index 000000000..9ef8f54dc
--- /dev/null
+++ b/web/api/v1/edit/server/crond/index.php
@@ -0,0 +1,65 @@
+ $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']);
diff --git a/web/api/v1/edit/server/dovecot/index.php b/web/api/v1/edit/server/dovecot/index.php
new file mode 100644
index 000000000..198bd28a2
--- /dev/null
+++ b/web/api/v1/edit/server/dovecot/index.php
@@ -0,0 +1,206 @@
+ $v_config_path,
+ 'config_path1' => $v_config_path1,
+ 'config_path2' => $v_config_path2,
+ 'config_path3' => $v_config_path3,
+ 'config_path4' => $v_config_path4,
+ 'config_path5' => $v_config_path5,
+ 'config_path6' => $v_config_path6,
+ 'config_path7' => $v_config_path7,
+ 'config_path8' => $v_config_path8,
+ 'service_name' => $v_service_name,
+ 'config' => $config,
+ 'config1' => $config1,
+ 'config2' => $config2,
+ 'config3' => $config3,
+ 'config4' => $config4,
+ 'config5' => $config5,
+ 'config6' => $config6,
+ 'config7' => $config7,
+ 'config8' => $config8,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/edit/server/exim/index.php b/web/api/v1/edit/server/exim/index.php
new file mode 100644
index 000000000..aa267feac
--- /dev/null
+++ b/web/api/v1/edit/server/exim/index.php
@@ -0,0 +1,65 @@
+ $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']);
diff --git a/web/api/v1/edit/server/exim4/index.php b/web/api/v1/edit/server/exim4/index.php
new file mode 100644
index 000000000..84b2bd50e
--- /dev/null
+++ b/web/api/v1/edit/server/exim4/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/fail2ban/index.php b/web/api/v1/edit/server/fail2ban/index.php
new file mode 100644
index 000000000..fa7cf38c4
--- /dev/null
+++ b/web/api/v1/edit/server/fail2ban/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/httpd/index.php b/web/api/v1/edit/server/httpd/index.php
new file mode 100644
index 000000000..8af419d2d
--- /dev/null
+++ b/web/api/v1/edit/server/httpd/index.php
@@ -0,0 +1,64 @@
+ '/etc/httpd/conf/httpd.conf',
+ 'service_name' => $v_service_name,
+ 'config' => $v_config,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/index.php b/web/api/v1/edit/server/index.php
new file mode 100644
index 000000000..d52595256
--- /dev/null
+++ b/web/api/v1/edit/server/index.php
@@ -0,0 +1,698 @@
+ $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']);
diff --git a/web/api/v1/edit/server/iptables/index.php b/web/api/v1/edit/server/iptables/index.php
new file mode 100644
index 000000000..ff3875f4d
--- /dev/null
+++ b/web/api/v1/edit/server/iptables/index.php
@@ -0,0 +1,16 @@
+ $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/mariadb/index.php b/web/api/v1/edit/server/mariadb/index.php
new file mode 100644
index 000000000..2766d14f1
--- /dev/null
+++ b/web/api/v1/edit/server/mariadb/index.php
@@ -0,0 +1,79 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/mysql/index.php b/web/api/v1/edit/server/mysql/index.php
new file mode 100644
index 000000000..bbf15b682
--- /dev/null
+++ b/web/api/v1/edit/server/mysql/index.php
@@ -0,0 +1,79 @@
+ $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']);
diff --git a/web/api/v1/edit/server/mysqld/index.php b/web/api/v1/edit/server/mysqld/index.php
new file mode 100644
index 000000000..c63cb81ac
--- /dev/null
+++ b/web/api/v1/edit/server/mysqld/index.php
@@ -0,0 +1,79 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/named/index.php b/web/api/v1/edit/server/named/index.php
new file mode 100644
index 000000000..aa7d2ed88
--- /dev/null
+++ b/web/api/v1/edit/server/named/index.php
@@ -0,0 +1,65 @@
+ $v_service_name,
+ 'config_path' => $v_config_path,
+ 'config' => $v_config,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/nginx/index.php b/web/api/v1/edit/server/nginx/index.php
new file mode 100644
index 000000000..2989975e9
--- /dev/null
+++ b/web/api/v1/edit/server/nginx/index.php
@@ -0,0 +1,89 @@
+ $data['CONFIG']['worker_processes'],
+ 'worker_connections' => $data['CONFIG']['worker_connections'],
+ 'send_timeout' => $data['CONFIG']['send_timeout'],
+ 'proxy_connect_timeout' => $data['CONFIG']['proxy_connect_timeout'],
+ 'proxy_send_timeout' => $data['CONFIG']['proxy_send_timeout'],
+ 'proxy_read_timeout' => $data['CONFIG']['proxy_read_timeout'],
+ 'client_max_body_size' => $data['CONFIG']['client_max_body_size'],
+ 'gzip' => $data['CONFIG']['gzip'],
+ 'gzip_comp_level' => $data['CONFIG']['gzip_comp_level'],
+ 'charset' => $data['CONFIG']['charset'],
+ 'config_path' => $data['CONFIG']['config_path'],
+ 'service_name' => strtoupper('nginx'),
+ 'config' => $v_config,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/edit/server/php-fpm/index.php b/web/api/v1/edit/server/php-fpm/index.php
new file mode 100644
index 000000000..066c13bfe
--- /dev/null
+++ b/web/api/v1/edit/server/php-fpm/index.php
@@ -0,0 +1,82 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/php/index.php b/web/api/v1/edit/server/php/index.php
new file mode 100644
index 000000000..4ad60e1bb
--- /dev/null
+++ b/web/api/v1/edit/server/php/index.php
@@ -0,0 +1,82 @@
+ $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']);
diff --git a/web/api/v1/edit/server/php5-fpm/index.php b/web/api/v1/edit/server/php5-fpm/index.php
new file mode 100644
index 000000000..066c13bfe
--- /dev/null
+++ b/web/api/v1/edit/server/php5-fpm/index.php
@@ -0,0 +1,82 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/postgresql/index.php b/web/api/v1/edit/server/postgresql/index.php
new file mode 100644
index 000000000..c030cfb66
--- /dev/null
+++ b/web/api/v1/edit/server/postgresql/index.php
@@ -0,0 +1,87 @@
+ $v_options_path,
+ 'config_path' => $v_config_path,
+ 'service_name' => $v_service_name,
+ 'options' => $v_options,
+ 'config' => $v_config,
+ 'error_msg' => $_SESSION['error_msg'],
+ 'ok_msg' => $_SESSION['ok_msg']
+);
+
+echo json_encode($result);
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
diff --git a/web/api/v1/edit/server/proftpd/index.php b/web/api/v1/edit/server/proftpd/index.php
new file mode 100644
index 000000000..2f7c4d1e1
--- /dev/null
+++ b/web/api/v1/edit/server/proftpd/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/spamassassin/index.php b/web/api/v1/edit/server/spamassassin/index.php
new file mode 100644
index 000000000..ef12e5a73
--- /dev/null
+++ b/web/api/v1/edit/server/spamassassin/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/spamd/index.php b/web/api/v1/edit/server/spamd/index.php
new file mode 100644
index 000000000..accfd9a6f
--- /dev/null
+++ b/web/api/v1/edit/server/spamd/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/server/vsftpd/index.php b/web/api/v1/edit/server/vsftpd/index.php
new file mode 100644
index 000000000..83b10b703
--- /dev/null
+++ b/web/api/v1/edit/server/vsftpd/index.php
@@ -0,0 +1,65 @@
+ $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']);
\ No newline at end of file
diff --git a/web/api/v1/edit/user/index.php b/web/api/v1/edit/user/index.php
new file mode 100644
index 000000000..d2bf2733f
--- /dev/null
+++ b/web/api/v1/edit/user/index.php
@@ -0,0 +1,218 @@
+ '',
+ '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']);
diff --git a/web/api/v1/edit/web/index.php b/web/api/v1/edit/web/index.php
new file mode 100644
index 000000000..eb880edf6
--- /dev/null
+++ b/web/api/v1/edit/web/index.php
@@ -0,0 +1,810 @@
+ $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']);
diff --git a/web/api/v1/index.php b/web/api/v1/index.php
new file mode 100644
index 000000000..80f72b99e
--- /dev/null
+++ b/web/api/v1/index.php
@@ -0,0 +1,125 @@
+ 0 ) {
+ echo 'Error: authentication failed';
+ exit;
+ }
+ } else {
+ $key = '/usr/local/vesta/data/keys/' . basename($_POST['hash']);
+ if (file_exists($key) && is_file($key)) {
+ exec(VESTA_CMD ."v-check-api-key ".escapeshellarg($key)." ".$v_ip, $output, $return_var);
+ unset($output);
+
+ // Check API answer
+ if ( $return_var > 0 ) {
+ echo 'Error: authentication failed';
+ exit;
+ }
+ } else {
+ $return_var = 1;
+ }
+ }
+
+ if ( $return_var > 0 ) {
+ echo 'Error: authentication failed';
+ exit;
+ }
+
+ // Prepare arguments
+ if (isset($_POST['cmd'])) $cmd = escapeshellarg($_POST['cmd']);
+ if (isset($_POST['arg1'])) $arg1 = escapeshellarg($_POST['arg1']);
+ if (isset($_POST['arg2'])) $arg2 = escapeshellarg($_POST['arg2']);
+ if (isset($_POST['arg3'])) $arg3 = escapeshellarg($_POST['arg3']);
+ if (isset($_POST['arg4'])) $arg4 = escapeshellarg($_POST['arg4']);
+ if (isset($_POST['arg5'])) $arg5 = escapeshellarg($_POST['arg5']);
+ if (isset($_POST['arg6'])) $arg6 = escapeshellarg($_POST['arg6']);
+ if (isset($_POST['arg7'])) $arg7 = escapeshellarg($_POST['arg7']);
+ if (isset($_POST['arg8'])) $arg8 = escapeshellarg($_POST['arg8']);
+ if (isset($_POST['arg9'])) $arg9 = escapeshellarg($_POST['arg9']);
+
+ // Build query
+ $cmdquery = VESTA_CMD.$cmd." ";
+ if(!empty($arg1)){
+ $cmdquery = $cmdquery.$arg1." "; }
+ if(!empty($arg2)){
+ $cmdquery = $cmdquery.$arg2." "; }
+ if(!empty($arg3)){
+ $cmdquery = $cmdquery.$arg3." "; }
+ if(!empty($arg4)){
+ $cmdquery = $cmdquery.$arg4." "; }
+ if(!empty($arg5)){
+ $cmdquery = $cmdquery.$arg5." "; }
+ if(!empty($arg6)){
+ $cmdquery = $cmdquery.$arg6." "; }
+ if(!empty($arg7)){
+ $cmdquery = $cmdquery.$arg7." "; }
+ if(!empty($arg8)){
+ $cmdquery = $cmdquery.$arg8." "; }
+ if(!empty($arg9)){
+ $cmdquery = $cmdquery.$arg9; }
+
+ // Check command
+ if ($cmd == "'v-make-tmp-file'") {
+ // Used in DNS Cluster
+ $fp = fopen($_POST['arg2'], 'w');
+ fwrite($fp, $_POST['arg1']."\n");
+ fclose($fp);
+ $return_var = 0;
+ } else {
+ // Run normal cmd query
+ exec ($cmdquery, $output, $return_var);
+ }
+
+ if ((!empty($_POST['returncode'])) && ($_POST['returncode'] == 'yes')) {
+ echo $return_var;
+ } else {
+ if (($return_var == 0) && (empty($output))) {
+ echo "OK";
+ } else {
+ echo implode("\n",$output)."\n";
+ }
+ }
+}
diff --git a/web/api/v1/languages.php b/web/api/v1/languages.php
new file mode 100644
index 000000000..8332fc217
--- /dev/null
+++ b/web/api/v1/languages.php
@@ -0,0 +1,15 @@
+ $data);
+
+echo json_encode($result);
diff --git a/web/api/v1/list/backup/index.php b/web/api/v1/list/backup/index.php
new file mode 100644
index 000000000..54e515202
--- /dev/null
+++ b/web/api/v1/list/backup/index.php
@@ -0,0 +1,77 @@
+ $value) {
+ ++$i;
+ $web = __('no');
+ $dns = __('no');
+ $mail = __('no');
+ $db = __('no');
+ $cron = __('no');
+ $udir = __('no');
+
+ if (!empty($data[$key]['WEB'])) $web = __('yes');
+ if (!empty($data[$key]['DNS'])) $dns = __('yes');
+ if (!empty($data[$key]['MAIL'])) $mail = __('yes');
+ if (!empty($data[$key]['DB'])) $db = __('yes');
+ if (!empty($data[$key]['CRON'])) $cron = __('yes');
+ if (!empty($data[$key]['UDIR'])) $udir = __('yes');
+
+ $data[$key]['delete_conf'] = __('DELETE_BACKUP_CONFIRMATION', $key);
+
+ if (empty($_GET['backup'])){
+ if ( $i == 1) {
+ $total_amount = __('1 archive');
+ } else {
+ $total_amount = __('%s archives',$i);
+ }
+ } else {
+ $webAr = explode(',',$data[$backup]['WEB']);
+ $dnsAr = explode(',',$data[$backup]['DNS']);
+ $mailAr = explode(',',$data[$backup]['MAIL']);
+ $dbAr = explode(',',$data[$backup]['DB']);
+ $cronAr = explode(',',$data[$backup]['CRON']);
+ $udirAr = explode(',',$data[$backup]['UDIR']);
+
+ $totalLength = count($webAr) + count($dnsAr) + count($mailAr) + count($dbAr) + count($cronAr) + count($udirAr);
+
+ $total_amount = __('%s items', $totalLength);
+ }
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->backup_fav = $_SESSION['favourites']['BACKUP'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/cron/index.php b/web/api/v1/list/cron/index.php
new file mode 100644
index 000000000..8502aaff4
--- /dev/null
+++ b/web/api/v1/list/cron/index.php
@@ -0,0 +1,59 @@
+ $value) {
+ ++$i;
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = __('UNSUSPEND_CRON_CONFIRMATION', $key);
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend';
+ $data[$key]['suspend_conf'] = __('SUSPEND_CRON_CONFIRMATION', $key);
+ }
+
+ $data[$key]['delete_conf'] = __('DELETE_CRON_CONFIRMATION', $key);
+
+ if ( $i == 1) {
+ $total_amount = __('1 cron job');
+ } else {
+ $total_amount = __('%s cron jobs', $i);
+ }
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->cron_reports = $panel[$user]['CRON_REPORTS'];
+$object->cron_fav = $_SESSION['favourites']['CRON'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/db/index.php b/web/api/v1/list/db/index.php
new file mode 100644
index 000000000..f9e327a2c
--- /dev/null
+++ b/web/api/v1/list/db/index.php
@@ -0,0 +1,79 @@
+ $value) {
+ ++$i;
+
+ if ( $i == 1) {
+ $total_amount = __('1 database');
+ } else {
+ $total_amount = __('%s databases',$i);
+ }
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = __('UNSUSPEND_DATABASE_CONFIRMATION', $key);
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend';
+ $data[$key]['suspend_conf'] = __('SUSPEND_DATABASE_CONFIRMATION', $key);
+ }
+
+ if ($data[$key]['TYPE'] == 'mysql'){
+ $mysql = 1;
+
+ $db_myadmin_link = "http://".$http_host."/phpmyadmin/";
+ if (!empty($_SESSION['DB_PMA_URL']))
+ $db_myadmin_link = $_SESSION['DB_PMA_URL'];
+ }
+ if ($data[$key]['TYPE'] == 'pgsql'){
+ $pgsql = 1;
+ $db_pgadmin_link = "http://".$http_host."/phppgadmin/";
+ if (!empty($_SESSION['DB_PGA_URL']))
+ $db_pgadmin_link = $_SESSION['DB_PGA_URL'];
+ }
+
+ if ($data[$key]['HOST'] != 'localhost' ) $http_host = $data[$key]['HOST'];
+ if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin";
+ if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/";
+ if (($data[$key]['TYPE'] == 'mysql') && (!empty($_SESSION['DB_PMA_URL']))) $db_admin_link = $_SESSION['DB_PMA_URL'];
+ if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin";
+ if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/";
+ if (($data[$key]['TYPE'] == 'pgsql') && (!empty($_SESSION['DB_PGA_URL']))) $db_admin_link = $_SESSION['DB_PGA_URL'];
+
+ $data[$key]['delete_conf'] = __('DELETE_DATABASE_CONFIRMATION', $key);
+}
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->db_admin = $db_admin;
+$object->db_admin_link = $db_admin_link;
+$object->totalAmount = $total_amount;
+$object->databases = $databases;
+$object->dbFav = $_SESSION['favourites']['DB'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/directory/index.php b/web/api/v1/list/directory/index.php
new file mode 100644
index 000000000..12919b140
--- /dev/null
+++ b/web/api/v1/list/directory/index.php
@@ -0,0 +1,35 @@
+ 0 ) {
+ header("Location: /error/");
+ exit;
+ }
+ $panel = json_decode(implode('', $output), true);
+}
+
+$path_a = !empty($_REQUEST['dir_a']) ? htmlentities($_REQUEST['dir_a']) : '';
+$path_b = !empty($_REQUEST['dir_b']) ? htmlentities($_REQUEST['dir_b']) : '';
+$GLOBAL_JS = '';
+$GLOBAL_JS .= '';
+$GLOBAL_JS .= '';
+
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/file_manager/main.php');
\ No newline at end of file
diff --git a/web/api/v1/list/directory/preview/index.php b/web/api/v1/list/directory/preview/index.php
new file mode 100644
index 000000000..737e19db3
--- /dev/null
+++ b/web/api/v1/list/directory/preview/index.php
@@ -0,0 +1,35 @@
+ 0 ) {
+ header("Location: /error/");
+ exit;
+ }
+ $panel = json_decode(implode('', $output), true);
+}
+
+$path_a = !empty($_REQUEST['dir_a']) ? $_REQUEST['dir_a'] : '';
+$path_b = !empty($_REQUEST['dir_b']) ? $_REQUEST['dir_b'] : '';
+$GLOBAL_JS = '';
+$GLOBAL_JS .= '';
+$GLOBAL_JS .= '';
+
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/file_manager/main.php');
\ No newline at end of file
diff --git a/web/api/v1/list/dns/index.php b/web/api/v1/list/dns/index.php
new file mode 100644
index 000000000..766258aab
--- /dev/null
+++ b/web/api/v1/list/dns/index.php
@@ -0,0 +1,72 @@
+ $value) {
+ ++$i;
+
+ if ( $i == 1) {
+ $total_amount = __('1 domain');
+ } else {
+ $total_amount = __('%s domains', $i);
+ }
+
+ if (!empty($_GET['domain'])){
+ if ( $i == 1) {
+ $total_amount = __('1 record');
+ } else {
+ $total_amount = __('%s records',$i);
+ }
+
+ $data[$key]['delete_conf'] = __('DELETE_RECORD_CONFIRMATION', $data[$key]['RECORD']);
+ } else {
+ $data[$key]['delete_conf'] = __('DELETE_DOMAIN_CONFIRMATION', $key);
+ }
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = !empty($_GET['domain']) ? __('UNSUSPEND_RECORD_CONFIRMATION', $data[$key]['RECORD']) : __('UNSUSPEND_DOMAIN_CONFIRMATION', $key);
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend';
+ $data[$key]['suspend_conf'] = !empty($_GET['domain']) ? __('SUSPEND_RECORD_CONFIRMATION', $data[$key]['RECORD']) : __('SUSPEND_DOMAIN_CONFIRMATION', $key);
+ }
+
+ $data[$key]['RECORDS_I18N'] = __('list records', $data[$key]['RECORDS']);
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->dnsFav = $_SESSION['favourites']['DNS'];
+$object->dnsRecordsFav = $_SESSION['favourites']['DNS_REC'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/favorites/index.php b/web/api/v1/list/favorites/index.php
new file mode 100644
index 000000000..0ddc4c0b0
--- /dev/null
+++ b/web/api/v1/list/favorites/index.php
@@ -0,0 +1,24 @@
+ Favorites:
';
+
+ // Data
+ exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);
+
+
+// print_r(implode('', $output));
+// $json = '{ "Favourites": { "USER": "", "WEB": "bulletfarm.com", "DNS": "", "MAIL": "", "DB": "", "CRON": "", "BACKUP": "", "IP": "", "PACKAGE": "", "FIREWALL": ""}}';
+// $data = json_decode($json, true);
+
+
+ $data = json_decode(implode('', $output).'}', true);
+ $data = array_reverse($data,true);
+
+ print_r($data);
+// $data = array_reverse($data,true);
+
+// $data = json_decode(implode('', $output), true);
+
+?>
\ No newline at end of file
diff --git a/web/api/v1/list/firewall/banlist/index.php b/web/api/v1/list/firewall/banlist/index.php
new file mode 100644
index 000000000..54136bb21
--- /dev/null
+++ b/web/api/v1/list/firewall/banlist/index.php
@@ -0,0 +1,56 @@
+ $value) {
+ ++$i;
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = 'UNSUSPEND_RULE_CONFIRMATION' ;
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend' ;
+ $data[$key]['suspend_conf'] = 'SUSPEND_RULE_CONFIRMATION' ;
+ }
+
+ $data[$key]['delete_url'] = '/delete/firewall/banlist/?ip='.$data[$key]['ip'].'&chain='.$data[$key]['CHAIN'].'&token='.$_SESSION['token'];
+ $data[$key]['delete_confirmation'] = __('DELETE_IP_CONFIRMATION',$key);
+
+ if ( $i == 1) {
+ $total_amount = __('1 rule');
+ } else {
+ $total_amount = __('%s rules',$i);
+ }
+}
+
+if ($i == 0) {
+ $total_amount = __('There are no currently banned IP');
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$result = array(
+ 'data' => $data,
+ 'total_amount' => $total_amount
+);
+
+echo json_encode($result);
diff --git a/web/api/v1/list/firewall/index.php b/web/api/v1/list/firewall/index.php
new file mode 100644
index 000000000..35d6ecbdf
--- /dev/null
+++ b/web/api/v1/list/firewall/index.php
@@ -0,0 +1,58 @@
+ $value) {
+ ++$i;
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = __('UNSUSPEND_RULE_CONFIRMATION', $key);
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend';
+ $data[$key]['suspend_conf'] = __('SUSPEND_RULE_CONFIRMATION', $key);
+ }
+
+ $data[$key]['delete_conf'] = __('DELETE_RULE_CONFIRMATION', $key);
+
+ if ( $i == 1) {
+ $total_amount = __('1 rule');
+ } else {
+ $total_amount = __('%s rules', $i);
+ }
+}
+
+// Render page
+// render_page($user, $TAB, 'list_firewall');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->firewallExtension = !empty($_SESSION['FIREWALL_EXTENSION']);
+$object->firewallFav = $_SESSION['favourites']['FIREWALL'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/index.php b/web/api/v1/list/index.php
new file mode 100644
index 000000000..b0d34a3f8
--- /dev/null
+++ b/web/api/v1/list/index.php
@@ -0,0 +1,8 @@
+
diff --git a/web/api/v1/list/ip/index.php b/web/api/v1/list/ip/index.php
new file mode 100644
index 000000000..899e57e5b
--- /dev/null
+++ b/web/api/v1/list/ip/index.php
@@ -0,0 +1,47 @@
+ $value) {
+ ++$i;
+ if ( $i == 1) {
+ $total_amount = __('1 IP address');
+ } else {
+ $total_amount = __('%s IP addresses',$i);
+ }
+
+ $data[$key]['delete_conf'] = __('DELETE_IP_CONFIRMATION', $key);
+}
+
+// Render page
+// render_page($user, $TAB, 'list_ip');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->ipFav = $_SESSION['favourites']['IP'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/log/index.php b/web/api/v1/list/log/index.php
new file mode 100644
index 000000000..4eb96b0fd
--- /dev/null
+++ b/web/api/v1/list/log/index.php
@@ -0,0 +1,36 @@
+ $value) {
+ ++$i;
+
+ if ( $i == 1) {
+ $total_amount = __('one log record');
+ } else {
+ $total_amount = __('%s log records',$i);
+ }
+}
+
+// Render page
+// render_page($user, $TAB, 'list_log');
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/mail/index.php b/web/api/v1/list/mail/index.php
new file mode 100644
index 000000000..8d6c59126
--- /dev/null
+++ b/web/api/v1/list/mail/index.php
@@ -0,0 +1,78 @@
+
+error_reporting(NULL);
+$TAB = 'MAIL';
+header("Content-Type: application/json");
+
+// Main include
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Data & Render page
+if (empty($_GET['domain'])){
+ exec (VESTA_CMD."v-list-mail-domains $user json", $output, $return_var);
+ $data = json_decode(implode('', $output), true);
+ $data = array_reverse($data, true);
+ unset($output);
+
+ $favorites = $_SESSION['favourites']['MAIL'];
+
+ // render_page($user, $TAB, 'list_mail');
+} else {
+ exec (VESTA_CMD."v-list-mail-accounts ".$user." ".escapeshellarg($_GET['domain'])." json", $output, $return_var);
+ $data = json_decode(implode('', $output), true);
+ $data = array_reverse($data, true);
+ unset($output);
+
+ $favorites = $_SESSION['favourites']['MAIL_ACC'];
+
+ // render_page($user, $TAB, 'list_mail_acc');
+}
+
+$uname_arr=posix_uname();
+$hostname=$uname_arr['nodename'];
+
+top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
+
+foreach ($data as $key => $value) {
+ ++$i;
+
+ list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
+ $webmail = "/webmail/";
+ if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL'];
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $data[$key]['status'] = 'suspended';
+ $data[$key]['suspend_action'] = 'unsuspend' ;
+ $data[$key]['suspend_conf'] = __('UNSUSPEND_DOMAIN_CONFIRMATION', $key);
+ } else {
+ $data[$key]['status'] = 'active';
+ $data[$key]['suspend_action'] = 'suspend';
+ $data[$key]['suspend_conf'] = __('SUSPEND_DOMAIN_CONFIRMATION', $key);
+ }
+
+ if (empty($data[$key]['CATCHALL'])) {
+ $data[$key]['CATCHALL'] = '/dev/null';
+ }
+
+ if (empty($_GET['domain'])){
+ $total_amount = $i === 1 ? __('1 domain') : __('%s domains', $i);
+ } else {
+ $total_amount = $i === 1 ? __('1 mail account') : __('%s mail account', $i);
+ }
+
+ $data[$key]['list_accounts_button'] = __('list accounts', $data[$key]['ACCOUNTS']);
+ $data[$key]['delete_conf'] = __('DELETE_DOMAIN_CONFIRMATION', $key);
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->webmail = $webmail;
+$object->hostname = $hostname;
+$object->totalAmount = $total_amount;
+$object->mailFav = $favorites;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/notifications/index.php b/web/api/v1/list/notifications/index.php
new file mode 100644
index 000000000..1190c5ce6
--- /dev/null
+++ b/web/api/v1/list/notifications/index.php
@@ -0,0 +1,25 @@
+ $note){
+ $note['ID'] = $key;
+ $notifications[$key] = $note;
+}
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$result = array(
+ 'result' => empty($notifications) ? [] : $notifications
+);
+
+echo json_encode($result);
diff --git a/web/api/v1/list/package/index.php b/web/api/v1/list/package/index.php
new file mode 100644
index 000000000..2fe581232
--- /dev/null
+++ b/web/api/v1/list/package/index.php
@@ -0,0 +1,45 @@
+ $value) {
+ ++$i;
+ if ( $i == 1) {
+ $total_amount = __('1 package');
+ } else {
+ $total_amount = __('%s packages',$i);
+ }
+
+ $data[$key]['delete_conf'] = __('DELETE_PACKAGE_CONFIRMATION', $key);
+}
+
+// Render page
+// render_page($user, $TAB, 'list_packages');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->totalAmount = $total_amount;
+$object->packagesFav = $_SESSION['favourites']['PACKAGE'];
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/rrd/image.php b/web/api/v1/list/rrd/image.php
new file mode 100644
index 000000000..600b11134
--- /dev/null
+++ b/web/api/v1/list/rrd/image.php
@@ -0,0 +1,13 @@
+
diff --git a/web/api/v1/list/rrd/index.php b/web/api/v1/list/rrd/index.php
new file mode 100644
index 000000000..2ba6b4dc5
--- /dev/null
+++ b/web/api/v1/list/rrd/index.php
@@ -0,0 +1,32 @@
+data = $data;
+$object->user = $user;
+$object->panel = $panel;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/server/index.php b/web/api/v1/list/server/index.php
new file mode 100644
index 000000000..47363fcae
--- /dev/null
+++ b/web/api/v1/list/server/index.php
@@ -0,0 +1,113 @@
+ $value) {
+ if ($data[$key]['STATE'] == 'running') {
+ $data[$key]['action_url'] = '/stop/service/?srv='.$key;
+ } else {
+ $data[$key]['action_url'] = '/start/service/?srv='.$key;
+ }
+
+ $data[$key]['SYSTEM'] = __($data[$key]['SYSTEM']);
+ $data[$key]['RTIME'] = humanize_time($data[$key]['RTIME']);
+
+ $cpu = $data[$key]['CPU'] / 10;
+ $data[$key]['CPU'] = number_format($cpu, 1);
+ if ($cpu == '0.0') $data[$key]['CPU'] = 0;
+}
+
+foreach ($sys as $key => $value) {
+ $sys[$key]['UPTIME'] = humanize_time($sys[$key]['UPTIME']);
+}
+
+// Render page
+// render_page($user, $TAB, 'list_services');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->sys = $sys;
+$object->service_log = $service_log;
+$object->panel = $panel;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/stats/index.php b/web/api/v1/list/stats/index.php
new file mode 100644
index 000000000..9053d9227
--- /dev/null
+++ b/web/api/v1/list/stats/index.php
@@ -0,0 +1,58 @@
+ $value) {
+ ++$i;
+
+ if ( $i == 1) {
+ $total_amount = __('1 month');
+ } else {
+ $total_amount = __('%s months',$i);
+ }
+}
+
+// Render page
+// render_page($user, $TAB, 'list_stats');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+$object = (object)[];
+$object->data = $data;
+$object->user = $user;
+$object->panel = $panel;
+$object->users = $users;
+$object->totalAmount = $total_amount;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/updates/index.php b/web/api/v1/list/updates/index.php
new file mode 100644
index 000000000..7a4c7bdc3
--- /dev/null
+++ b/web/api/v1/list/updates/index.php
@@ -0,0 +1,36 @@
+data = $data;
+$object->user = $user;
+$object->autoUpdate = $autoupdate;
+$object->panel = $panel;
+
+print json_encode($object);
\ No newline at end of file
diff --git a/web/api/v1/list/user/index.php b/web/api/v1/list/user/index.php
new file mode 100644
index 000000000..eb202cd80
--- /dev/null
+++ b/web/api/v1/list/user/index.php
@@ -0,0 +1,56 @@
+ $value) {
+ ++$i;
+ if ( $i == 1) {
+ $total_amount = __('1 account');
+ } else {
+ $total_amount = __('%s accounts', $i);
+ }
+
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $spnd_action = 'unsuspend' ;
+ $spnd_confirmation = 'UNSUSPEND_USER_CONFIRMATION';
+ $data[$key]['spnd_action'] = __($spnd_action);
+ $data[$key]['spnd_conf'] = __($spnd_confirmation, $key);
+ } else {
+ $spnd_action = 'suspend' ;
+ $spnd_confirmation = 'SUSPEND_USER_CONFIRMATION';
+ $data[$key]['spnd_action'] = __($spnd_action);
+ $data[$key]['spnd_conf'] = __($spnd_confirmation, $key);
+ }
+
+ $data[$key]['isChecked'] = false;
+ $data[$key]['delete_conf'] = __('DELETE_USER_CONFIRMATION', $key);
+}
+
+$result = array(
+ 'data' => $data,
+ 'user' => $user,
+ 'panel' => $panel,
+ 'token' => $_SESSION['token'],
+ 'totalAmount' => $total_amount,
+ 'userFav' => $_SESSION['favourites']['USER'],
+);
+
+echo json_encode($result);
diff --git a/web/api/v1/list/web-log/index.php b/web/api/v1/list/web-log/index.php
new file mode 100644
index 000000000..4f6823636
--- /dev/null
+++ b/web/api/v1/list/web-log/index.php
@@ -0,0 +1,29 @@
+ $data
+ )
+);
+
+// if ($return_var == 0 ) {
+// foreach($output as $file) {
+// echo htmlentities($file) . "\n";
+// }
+// }
+// echo " \n