Merge branch 'master' of github.com:serghey-rodin/vesta

This commit is contained in:
Serghey Rodin 2015-04-16 23:06:26 +03:00
commit ebe8173af1
15 changed files with 141 additions and 46 deletions

View file

@ -45,7 +45,7 @@ for ip in $ip_list; do
# Calculate usage # Calculate usage
ip_usage=$(grep -H $ip $VESTA/data/users/*/web.conf) ip_usage=$(grep -H $ip $VESTA/data/users/*/web.conf)
web_domains=$(echo "$ip_usage"| wc -l) web_domains=$(echo "$ip_usage" | sed '/^$/d' | wc -l)
sys_users=$(echo "$ip_usage" | cut -f7 -d/ | sort -u |\ sys_users=$(echo "$ip_usage" | cut -f7 -d/ | sort -u |\
tr '\n' ',' | sed "s/,$//g") tr '\n' ',' | sed "s/,$//g")

View file

@ -108,7 +108,7 @@ acl_check_rcpt:
require message = relay not permitted require message = relay not permitted
domains = +local_domains : +relay_to_domains domains = +local_domains : +relay_to_domains
deny message = smtp auth requried deny message = smtp auth required
sender_domains = +local_domains sender_domains = +local_domains
!authenticated = * !authenticated = *

View file

@ -43,6 +43,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
// Enable ssh access // Enable ssh access
if(($answer == 'OK') && ($params["configoption2"] == 'on')) { if(($answer == 'OK') && ($params["configoption2"] == 'on')) {
$postvars = array( $postvars = array(
@ -62,6 +64,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
// Add domain // Add domain
@ -84,6 +88,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
} }
@ -92,8 +98,8 @@ function vesta_CreateAccount($params) {
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_TerminateAccount($params) { function vesta_TerminateAccount($params) {
@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) {
} }
return $result; return $result;
} }
function vesta_SuspendAccount($params) { function vesta_SuspendAccount($params) {
@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_UnsuspendAccount($params) { function vesta_UnsuspendAccount($params) {
@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_ChangePassword($params) { function vesta_ChangePassword($params) {
@ -227,13 +240,15 @@ function vesta_ChangePassword($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result; return $result;
} }
function vesta_ChangePackage($params) { function vesta_ChangePackage($params) {
@ -263,13 +278,15 @@ function vesta_ChangePackage($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_ClientArea($params) { function vesta_ClientArea($params) {

View file

@ -108,7 +108,7 @@ acl_check_rcpt:
require message = relay not permitted require message = relay not permitted
domains = +local_domains : +relay_to_domains domains = +local_domains : +relay_to_domains
deny message = smtp auth requried deny message = smtp auth required
sender_domains = +local_domains sender_domains = +local_domains
!authenticated = * !authenticated = *

View file

@ -43,6 +43,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
// Enable ssh access // Enable ssh access
if(($answer == 'OK') && ($params["configoption2"] == 'on')) { if(($answer == 'OK') && ($params["configoption2"] == 'on')) {
$postvars = array( $postvars = array(
@ -62,6 +64,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
// Add domain // Add domain
@ -84,6 +88,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
} }
@ -92,8 +98,8 @@ function vesta_CreateAccount($params) {
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_TerminateAccount($params) { function vesta_TerminateAccount($params) {
@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) {
} }
return $result; return $result;
} }
function vesta_SuspendAccount($params) { function vesta_SuspendAccount($params) {
@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_UnsuspendAccount($params) { function vesta_UnsuspendAccount($params) {
@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_ChangePassword($params) { function vesta_ChangePassword($params) {
@ -227,13 +240,15 @@ function vesta_ChangePassword($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result; return $result;
} }
function vesta_ChangePackage($params) { function vesta_ChangePackage($params) {
@ -263,13 +278,15 @@ function vesta_ChangePackage($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_ClientArea($params) { function vesta_ClientArea($params) {

View file

@ -108,7 +108,7 @@ acl_check_rcpt:
require message = relay not permitted require message = relay not permitted
domains = +local_domains : +relay_to_domains domains = +local_domains : +relay_to_domains
deny message = smtp auth requried deny message = smtp auth required
sender_domains = +local_domains sender_domains = +local_domains
!authenticated = * !authenticated = *

View file

@ -43,6 +43,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_UserAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
// Enable ssh access // Enable ssh access
if(($answer == 'OK') && ($params["configoption2"] == 'on')) { if(($answer == 'OK') && ($params["configoption2"] == 'on')) {
$postvars = array( $postvars = array(
@ -62,6 +64,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_EnableSSH','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
// Add domain // Add domain
@ -84,6 +88,8 @@ function vesta_CreateAccount($params) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl); $answer = curl_exec($curl);
logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
} }
} }
@ -92,8 +98,8 @@ function vesta_CreateAccount($params) {
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_TerminateAccount($params) { function vesta_TerminateAccount($params) {
@ -122,6 +128,8 @@ function vesta_TerminateAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','TerminateAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
@ -129,7 +137,6 @@ function vesta_TerminateAccount($params) {
} }
return $result; return $result;
} }
function vesta_SuspendAccount($params) { function vesta_SuspendAccount($params) {
@ -158,12 +165,15 @@ function vesta_SuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','SuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_UnsuspendAccount($params) { function vesta_UnsuspendAccount($params) {
@ -192,12 +202,15 @@ function vesta_UnsuspendAccount($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','UnsuspendAccount','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
} }
function vesta_ChangePassword($params) { function vesta_ChangePassword($params) {
@ -227,13 +240,15 @@ function vesta_ChangePassword($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePassword','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result; return $result;
} }
function vesta_ChangePackage($params) { function vesta_ChangePackage($params) {
@ -263,13 +278,15 @@ function vesta_ChangePackage($params) {
$answer = curl_exec($curl); $answer = curl_exec($curl);
} }
logModuleCall('vesta','ChangePackage','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
if($answer == 'OK') { if($answer == 'OK') {
$result = "success"; $result = "success";
} else { } else {
$result = $answer; $result = $answer;
} }
return $result;
return $result;
} }
function vesta_ClientArea($params) { function vesta_ClientArea($params) {

View file

@ -26,7 +26,7 @@ help() {
-f, --force Force installation -f, --force Force installation
-i, --disable-iptables Disable iptables support -i, --disable-iptables Disable iptables support
-b, --disable-fail2ban Disable fail2ban protection -b, --disable-fail2ban Disable fail2ban protection
-n, --noupdate Do not run yum update command -n, --noupdate Do not run apt-get upgrade command
-s, --hostname Set server hostname -s, --hostname Set server hostname
-e, --email Set email address -e, --email Set email address
-p, --password Set admin password instead of generating it -p, --password Set admin password instead of generating it
@ -78,7 +78,7 @@ while getopts "hfibdnqe:m:p:s:" Option; do
f) force='yes' ;; # Force install f) force='yes' ;; # Force install
i) disable_iptables='yes' ;; # Disable iptables i) disable_iptables='yes' ;; # Disable iptables
b) disable_fail2ban='yes' ;; # Disable fail2ban b) disable_fail2ban='yes' ;; # Disable fail2ban
n) noupdate='yes' ;; # Disable yum update n) noupdate='yes' ;; # Disable apt-get upgrade
s) servername=$OPTARG ;; # Server hostname s) servername=$OPTARG ;; # Server hostname
e) email=$OPTARG ;; # Set email e) email=$OPTARG ;; # Set email
p) vpass=$OPTARG ;; # Admin password p) vpass=$OPTARG ;; # Admin password
@ -126,11 +126,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" != 'yes' ]; then
exit 1 exit 1
fi fi
# Check admin user account # Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then
echo "Error: user admin exists" echo "Error: group admin exists"
echo echo
echo 'Please remove admin user account before proceeding.' echo 'Please remove admin group before proceeding.'
echo 'If you want to do it automatically run installer with -f option:' echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force" echo "Example: bash $0 --force"
exit 1 exit 1

View file

@ -124,11 +124,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" != 'yes' ]; then
exit 1 exit 1
fi fi
# Check admin user account # Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then
echo "Error: user admin exists" echo "Error: group admin exists"
echo echo
echo 'Please remove admin user account before proceeding.' echo 'Please remove admin group before proceeding.'
echo 'If you want to do it automatically run installer with -f option:' echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force" echo "Example: bash $0 --force"
exit 1 exit 1

View file

@ -25,7 +25,7 @@ help() {
-f, --force Force installation -f, --force Force installation
-i, --disable-iptables Disable iptables support -i, --disable-iptables Disable iptables support
-b, --disable-fail2ban Disable fail2ban protection -b, --disable-fail2ban Disable fail2ban protection
-n, --noupdate Do not run yum update command -n, --noupdate Do not run apt-get upgrade command
-s, --hostname Set server hostname -s, --hostname Set server hostname
-e, --email Set email address -e, --email Set email address
-p, --password Set admin password instead of generating it -p, --password Set admin password instead of generating it
@ -77,7 +77,7 @@ while getopts "hfibdnqe:m:p:s:" Option; do
f) force='yes' ;; # Force install f) force='yes' ;; # Force install
i) disable_iptables='yes' ;; # Disable iptables i) disable_iptables='yes' ;; # Disable iptables
b) disable_fail2ban='yes' ;; # Disable fail2ban b) disable_fail2ban='yes' ;; # Disable fail2ban
n) noupdate='yes' ;; # Disable yum update n) noupdate='yes' ;; # Disable apt-get upgrade
s) servername=$OPTARG ;; # Server hostname s) servername=$OPTARG ;; # Server hostname
e) email=$OPTARG ;; # Set email e) email=$OPTARG ;; # Set email
p) vpass=$OPTARG ;; # Admin password p) vpass=$OPTARG ;; # Admin password
@ -123,11 +123,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" != 'yes' ]; then
exit 1 exit 1
fi fi
# Check admin user account # Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" != 'yes' ]; then
echo "Error: user admin exists" echo "Error: group admin exists"
echo echo
echo 'Please remove admin user account before proceeding.' echo 'Please remove admin group before proceeding.'
echo 'If you want to do it automatically run installer with -f option:' echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force" echo "Example: bash $0 --force"
exit 1 exit 1

View file

@ -27,11 +27,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
exit 1 exit 1
fi fi
# Check admin user account # Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
echo "Error: group admin exists" echo "Error: group admin exists"
echo echo
echo 'Please remove admin user account before proceeding.' echo 'Please remove admin group before proceeding.'
echo 'If you want to do it automatically run installer with -f option:' echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force" echo "Example: bash $0 --force"
exit 1 exit 1

View file

@ -82,6 +82,9 @@ http {
root /usr/local/vesta/web; root /usr/local/vesta/web;
charset utf-8; charset utf-8;
// Fix error "The plain HTTP request was sent to HTTPS port"
error_page 497 https://$host:$server_port$request_uri;
ssl on; ssl on;
ssl_certificate /usr/local/vesta/ssl/certificate.crt; ssl_certificate /usr/local/vesta/ssl/certificate.crt;
ssl_certificate_key /usr/local/vesta/ssl/certificate.key; ssl_certificate_key /usr/local/vesta/ssl/certificate.key;

View file

@ -11,9 +11,14 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') { if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
var prev_value = $(elm).data('prev_value').trim(); var prev_value = $(elm).data('prev_value').trim();
$(elm).val(prev_value); $(elm).val(prev_value);
if (App.Helpers.isUnlimitedValue(prev_value)) {
$(elm).val('0');
}
} }
else { else {
$(elm).val('0'); if (App.Helpers.isUnlimitedValue($(elm).val())) {
$(elm).val('0');
}
} }
$(elm).attr('disabled', false); $(elm).attr('disabled', false);
$(source_elm).css('opacity', '0.5'); $(source_elm).css('opacity', '0.5');
@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
App.Listeners.PACKAGE.init = function() { App.Listeners.PACKAGE.init = function() {
$('.unlim-trigger').each(function(i, elm) { $('.unlim-trigger').each(function(i, elm) {
var ref = $(elm).prev('.vst-input'); var ref = $(elm).prev('.vst-input');
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) { if (App.Helpers.isUnlimitedValue($(ref).val())) {
$(ref).val('0');
App.Actions.PACKAGE.enable_unlimited(ref, elm); App.Actions.PACKAGE.enable_unlimited(ref, elm);
} }
else { else {
$(ref).data('prev_value', $(ref).val());
App.Actions.PACKAGE.disable_unlimited(ref, elm); App.Actions.PACKAGE.disable_unlimited(ref, elm);
} }
}); });
} }
App.Helpers.isUnlimitedValue = function(value) {
var value = value.trim();
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
return true;
}
return false;
}
// //
// Page entry point // Page entry point
// Trigger listeners // Trigger listeners

View file

@ -11,9 +11,14 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') { if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
var prev_value = $(elm).data('prev_value').trim(); var prev_value = $(elm).data('prev_value').trim();
$(elm).val(prev_value); $(elm).val(prev_value);
if (App.Helpers.isUnlimitedValue(prev_value)) {
$(elm).val('0');
}
} }
else { else {
$(elm).val('0'); if (App.Helpers.isUnlimitedValue($(elm).val())) {
$(elm).val('0');
}
} }
$(elm).attr('disabled', false); $(elm).attr('disabled', false);
$(source_elm).css('opacity', '0.5'); $(source_elm).css('opacity', '0.5');
@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
App.Listeners.PACKAGE.init = function() { App.Listeners.PACKAGE.init = function() {
$('.unlim-trigger').each(function(i, elm) { $('.unlim-trigger').each(function(i, elm) {
var ref = $(elm).prev('.vst-input'); var ref = $(elm).prev('.vst-input');
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) { if (App.Helpers.isUnlimitedValue($(ref).val())) {
$(ref).val('0');
App.Actions.PACKAGE.enable_unlimited(ref, elm); App.Actions.PACKAGE.enable_unlimited(ref, elm);
} }
else { else {
$(ref).data('prev_value', $(ref).val());
App.Actions.PACKAGE.disable_unlimited(ref, elm); App.Actions.PACKAGE.disable_unlimited(ref, elm);
} }
}); });
} }
App.Helpers.isUnlimitedValue = function(value) {
var value = value.trim();
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
return true;
}
return false;
}
// //
// Page entry point // Page entry point
// Trigger listeners // Trigger listeners

View file

@ -51,15 +51,28 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<select class="vst-list" name="v_chain"> <select class="vst-list" name="v_chain">
<option value="SSH" <?php if ((!empty($v_chain)) && ( $v_chain == "'SSH'" )) echo 'selected'?>><?php print __('SSH') ?></option> <?php
<option value="WEB" <?php if ((!empty($v_chain)) && ( $v_chain == "'WEB'" )) echo 'selected'?>><?php print __('WEB') ?></option> // chains list
<option value="FTP" <?php if ((!empty($v_chain)) && ( $v_chain == "'FTP'" )) echo 'selected'?>><?php print __('FTP') ?></option> $chains = array(
<option value="DNS" <?php if ((!empty($v_chain)) && ( $v_chain == "'DNS'" )) echo 'selected'?>><?php print __('DNS') ?></option> 'SSH',
<option value="MAIL" <?php if ((!empty($v_chain)) && ( $v_chain == "'MAIL'" )) echo 'selected'?>><?php print __('MAIL') ?></option> 'WEB',
<option value="DB" <?php if ((!empty($v_chain)) && ( $v_chain == "'DB'" )) echo 'selected'?>><?php print __('DB') ?></option> 'FTP',
<option value="VESTA" <?php if ((!empty($v_chain)) && ( $v_chain == "'VESTA'" )) echo 'selected'?>><?php print __('VESTA') ?></option> 'DNS',
</select> 'MAIL',
'DB',
'VESTA'
);
foreach($chains as $chain){
$selected = (!empty($v_chain)) && ( $v_chain == $chain) ? 'selected' : '';
?>
<option value="<?php echo $chain?>" <?php echo $selected ?>>
<?php print __($chain) ?>
</option>
<?php } ?>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>