optimized web domain adding (almost 2x faster

This commit is contained in:
Serghey Rodin 2015-09-07 16:42:32 +03:00
commit 2850492f55
10 changed files with 194 additions and 179 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add dns domain or dns record based on web domain alias restart
# options: USER DOMAIN
# info: add dns domain or dns record after web domain alias
# options: USER ALIAS IP [RESTART]
#
# The function adds dns domain or dns record based on web domain alias.
@ -11,13 +11,9 @@
# Argument defenition
user=$1
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4"
alias=$2
ip=$3
restart=$4
# Includes
source $VESTA/func/main.sh
@ -29,58 +25,54 @@ source $VESTA/conf/vesta.conf
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN ALIAS'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
check_args '3' "$#" 'USER ALIAS IP [RESTART]'
validate_format 'user' 'alias' 'ip'
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
if [ -e "$USER_DATA/dns/$alias.conf" ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Parsing domain values
get_domain_values 'web'
# Logging
log_event "$OK" "$EVENT"
# Check if it a simple domain
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
# Define additional vars
sub_domain=$(echo "$alias" |awk -F '.' '{print $1}')
top_domain=$(echo "$alias" |sed -e "s/^$sub_domain.//")
domain_lvl=$(echo "$alias" |grep -o "\." |wc -l)
# Adding second level domain
if [ "$domain_lvl" -eq 1 ] || [ "${#top_domain}" -le '6' ]; then
$BIN/v-add-dns-domain \
$user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
fi
else
# Check subdomain
sub=$(echo "$dom_alias" | cut -f1 -d . -s)
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
# Ignore short domains like co.uk, com.au and so on
if [ "${#dom}" -le '6' ]; then
$user $alias $ip '' '' '' '' '' $restart >> /dev/null
exit
fi
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
$BIN/v-add-dns-domain \
$user $dom $IP '' '' '' '' $restart > /dev/null
# Adding toplevel domain and then its sub
$BIN/v-add-dns-domain $user $top_domain $ip '' '' '' '' $restart >> /dev/null
if [ $? -eq 0 ]; then
$BIN/v-add-dns-record \
$user $dom "$sub" A $IP '' '' $restart
# Checking top-level domain
if [ ! -e "$USER_DATA/dns/$top_domain.conf" ]; then
exit
fi
# Checking subdomain record
if [ "$sub_domain" == '*' ]; then
check_record=$(grep -w "RECORD='\*'" $USER_DATA/dns/$top_domain.conf)
else
if [ "$sub" == '*' ]; then
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
else
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
check_record=$(grep -w "RECORD='$sub_domain'" $USER_DATA/dns/$top_domain.conf)
fi
if [ -z "$rec" ]; then
# Adding subdomain record
if [ -z "$check_record" ]; then
$BIN/v-add-dns-record \
$user $dom "$sub" A $IP '' '' $restart > /dev/null
fi
fi
$user $top_domain "$sub_domain" A $ip '' '' $restart >> /dev/null
fi
@ -88,6 +80,6 @@ fi
# Vesta #
#----------------------------------------------------------#
# No Logging
# No logging
exit

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add web domain
# options: USER DOMAIN IP [RESTART]
# options: USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]
#
# The function adds virtual host to a server. In cases when a template is
# undefined in the script, the template "default" will be used. The alias of
@ -20,9 +20,12 @@ domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
ip=$3; IP=$3
restart=$4
alises=$5
aliases=$5
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
extentions=${6-$default_extentions}
# Includes
source $VESTA/func/main.sh
@ -35,8 +38,8 @@ source $VESTA/conf/vesta.conf
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
validate_format 'user' 'domain' 'ip'
check_args '3' "$#" 'USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
validate_format 'user' 'domain' 'ip' 'extentions'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@ -46,41 +49,22 @@ is_ip_avalable
is_package_full 'WEB_DOMAINS'
template=$(get_user_value '$WEB_TEMPLATE')
is_web_template_valid
if [ ! -z "$aliases" ]; then
for domain_alias in $(echo "${aliases//,/ }"); do
is_domain_new 'web' "$domain_alias" 'alias'
done
fi
if [ ! -z "$PROXY_SYSTEM" ]; then
proxy=$(get_user_value '$PROXY_TEMPLATE')
is_proxy_template_valid $proxy
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Define real ip in case of NAT
IP=$ip
ip=$(get_real_ip $ip)
# Defining domain aliases
ip_name=$(get_ip_name)
ip_name_idn=$(idn -t --quiet -a "$ip_name")
domain_alias="www.$domain"
domain_alias_idn="www.$domain_idn"
if [ ! -z "$ip_name" ]; then
domain_alias_dash="${domain//./-}.$ip_name"
domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
aliases="$domain_alias,$domain_alias_dash"
aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
else
aliases="$domain_alias"
aliases_idn="$domain_alias_idn"
alias_string="ServerAlias $domain_alias_idn"
fi
# Defining vars for add_config function
group="$user"
email="info@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html"
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
# Checking backend
# Checking domain backend in case PHP-FPM is configured
if [ ! -z "$WEB_BACKEND" ]; then
is_web_backend_pool_valid
$BIN/v-add-web-domain-backend $user $domain
@ -89,8 +73,33 @@ if [ ! -z "$WEB_BACKEND" ]; then
exit $rc
fi
get_domain_backend_values
backend=$(get_user_value '$BACKEND_TEMPLATE')
fi
# Defining variables for add_config function
ip=$(get_real_ip $ip)
group="$user"
email="info@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html"
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
# Defining domain aliases
ip_name=$(get_ip_name)
if [ -z "$aliases" ]; then
if [ -z "$ip_name" ]; then
aliases="www.$domain"
else
aliases="www.$domain,${domain//./-}.$ip_name"
fi
else
if [ ! -z "$ip_name" ]; then
aliases="$aliases,${domain//./-}.$ip_name"
fi
fi
aliases_idn=$(idn -t --quiet -a $aliases)
alias_string="ServerAlias ${aliases_idn//,/ }"
# Adding web config
add_web_config
@ -166,6 +175,23 @@ if [ -z "$web_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
echo "include $conf;" >> $web_conf
fi
# Checking proxy system
if [ ! -z "$PROXY_SYSTEM" ]; then
PROXY_EXT="$extentions"
tpl_file="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
add_web_config
chown root:$user $conf
chmod 640 $conf
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
echo "include $conf;" >> $proxy_conf
fi
if [ -x $WEBTPL/$PROXY_SYSTEM/$template.sh ]; then
$WEBTPL/$PROXY_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
fi
fi
#----------------------------------------------------------#
# Vesta #
@ -177,10 +203,9 @@ increase_user_value "$user" '$U_WEB_DOMAINS'
increase_user_value "$user" '$U_WEB_ALIASES'
# Defining domain variables
BACKEND_TPL=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf |cut -f 2 -d \')
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5=''"
str="$str BACKEND='$BACKEND_TPL' PROXY='' PROXY_EXT='' STATS='' STATS_USER=''"
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$backend'"
str="$str PROXY='$proxy' PROXY_EXT='$extentions' STATS='' STATS_USER=''"
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
str="$str TIME='$TIME' DATE='$DATE'"
@ -193,6 +218,12 @@ if [ "$restart" != 'no' ]; then
if [ $? -ne 0 ]; then
exit $E_RESTART
fi
if [ ! -z "$PROXY_SYSTEM" ]; then
$BIN/v-restart-proxy
if [ $? -ne 0 ]; then
exit $E_RESTART
fi
fi
fi
# Logging

View file

@ -39,7 +39,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_domain_new 'web' "$dom_alias"
is_domain_new 'web' "$dom_alias" 'alias'
is_package_full 'WEB_ALIASES'

View file

@ -42,7 +42,7 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$PROXY'
if [ -z $template ]; then
template=$(get_user_value '$PROXY_TEMPLATE')
fi
is_proxy_template_valid
is_proxy_template_valid $template
#----------------------------------------------------------#

View file

@ -37,7 +37,7 @@ is_object_unsuspended 'user' 'USER' "$user"
case $type in
WEB) is_web_template_valid;
update_user_value "$user" '$WEB_TEMPLATE' "$template";;
PROXY) is_proxy_template_valid;
PROXY) is_proxy_template_valid $template;
update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
DNS) is_dns_template_valid;
update_user_value "$user" '$DNS_TEMPLATE' "$template";;

View file

@ -39,7 +39,7 @@ is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
is_proxy_template_valid
is_proxy_template_valid $template
#----------------------------------------------------------#

View file

@ -11,6 +11,7 @@ is_web_template_valid() {
# Proxy template check
is_proxy_template_valid() {
template=$1
t="$WEBTPL/$PROXY_SYSTEM/$template.tpl"
s="$WEBTPL/$PROXY_SYSTEM/$template.stpl"
if [ ! -e $t ] || [ ! -e $s ]; then
@ -84,20 +85,21 @@ is_dns_template_valid() {
is_domain_new() {
type="$1"
dom=${2-$domain}
object=${3-domain}
# Check web domain
if [ ! -z "$WEB_SYSTEM" ]; then
web=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
fi
if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$web" ]; then
web_user=$(echo "$web" |cut -f 7 -d /)
if [ "$web_user" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
@ -108,14 +110,14 @@ is_domain_new() {
dns=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
fi
if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$dns" ]; then
dns_user=$(echo "$dns" |cut -f 7 -d /)
if [ "$dns_user" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
@ -126,14 +128,14 @@ is_domain_new() {
mail=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
fi
if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$mail" ]; then
mail_user=$(echo "$mail" |cut -f 7 -d /)
if [ "$mail_user" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
@ -149,7 +151,7 @@ is_domain_new() {
c3=$(grep -H ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
c4=$(grep -H ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
@ -160,34 +162,34 @@ is_domain_new() {
fi
if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
echo "Error: domain $dom exist"
echo "Error: $object $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi

View file

@ -40,34 +40,39 @@ if (!empty($_POST['ok'])) {
}
}
// Default proxy extention list
$v_proxy_ext = 'jpeg, jpg, png, gif, bmp, ico, svg, tif, tiff, css, js, htm, html, ttf, ';
$v_proxy_ext .= 'otf, webp, woff, txt, csv, rtf, doc, docx, xls, xlsx, ppt, pptx, odf, ';
$v_proxy_ext .= 'odp, ods, odt, pdf, psd, ai, eot, eps, ps, zip, tar, tgz, gz, rar, ';
$v_proxy_ext .= 'bz2, 7z, aac, m4a, mp3, mp4, ogg, wav, wma, 3gp, avi, flv, m4v, mkv, ';
$v_proxy_ext .= 'mov, mp4, mpeg, mpg, wmv, exe, iso, dmg, swf';
// 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';
// Set domain name to lowercase and remove www prefix
// 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);
// Prepare domain values
// Define domain ip address
$v_ip = escapeshellarg($_POST['v_ip']);
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($v_domain)) $v_ftp_user_prepath .= $v_domain;
if (empty($_POST['v_dns'])) $v_dns = 'off';
if (empty($_POST['v_mail'])) $v_mail = 'off';
if (empty($_POST['v_proxy'])) $v_proxy = 'off';
// 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);
// Define proxy extentions
$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'];
@ -77,20 +82,29 @@ if (!empty($_POST['ok'])) {
$v_stats = escapeshellarg($_POST['v_stats']);
$v_stats_user = $data[$v_domain]['STATS_USER'];
$v_stats_password = $data[$v_domain]['STATS_PASSWORD'];
$v_proxy_ext = preg_replace("/\n/", " ", $_POST['v_proxy_ext']);
$v_proxy_ext = preg_replace("/,/", " ", $v_proxy_ext);
$v_proxy_ext = preg_replace('/\s+/', ' ',$v_proxy_ext);
$v_proxy_ext = trim($v_proxy_ext);
$v_proxy_ext = str_replace(' ', ", ", $v_proxy_ext);
$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';
// 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'", $output, $return_var);
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']);
@ -103,6 +117,18 @@ if (!empty($_POST['ok'])) {
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);
@ -110,47 +136,10 @@ if (!empty($_POST['ok'])) {
unset($output);
}
// Add domain 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) {
if ($alias == 'www.'.$_POST['v_domain']) {
$www_alias = 'yes';
} else {
$alias = escapeshellarg($alias);
if (empty($_SESSION['error_msg'])) {
exec (VESTA_CMD."v-add-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
}
}
}
// Delete www. alias if it wasn't found
if ((empty($www_alias)) && (empty($_SESSION['error_msg']))) {
$alias = preg_replace("/^www./i", "", $_POST['v_domain']);
$alias = 'www.'.$alias;
$alias = escapeshellarg($alias);
exec (VESTA_CMD."v-delete-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
// Add proxy support
if ((!empty($_SESSION['PROXY_SYSTEM'])) && ($_POST['v_proxy'] == 'on') && (empty($_SESSION['error_msg']))) {
$ext = str_replace(' ', '', $v_proxy_ext);
// Delete proxy support
if ((!empty($_SESSION['PROXY_SYSTEM'])) && ($_POST['v_proxy'] == 'off') && (empty($_SESSION['error_msg']))) {
$ext = escapeshellarg($ext);
exec (VESTA_CMD."v-add-web-domain-proxy ".$user." ".$v_domain." '' ".$ext." 'no'", $output, $return_var);
exec (VESTA_CMD."v-delete-web-domain-proxy ".$user." ".$v_domain." 'no'", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
@ -228,11 +217,11 @@ if (!empty($_POST['ok'])) {
}
// Restart backend server
if ((!empty($_SESSION['WEB_BACKEND'])) && (empty($_SESSION['error_msg']))) {
exec (VESTA_CMD."v-restart-web-backend", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
//if ((!empty($_SESSION['WEB_BACKEND'])) && (empty($_SESSION['error_msg']))) {
// exec (VESTA_CMD."v-restart-web-backend", $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']))) {

View file

@ -1977,9 +1977,11 @@ div.l-content > div.l-separator:nth-of-type(4) {
right: 3%;
}
/*
#vstobjects {
margin-top: -1px;
}
*/
#vstobjects .l-center {
padding-top: 20px;
@ -2745,4 +2747,3 @@ form#vstobjects.suspended {
text-align: right;
width: 140px;
}

View file

@ -195,7 +195,7 @@ if (!empty($_POST['save'])) {
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain, $output, $return_var);
unset($output);
if ($return_var == 0) {
exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$alias." ".$v_ip." no", $output, $return_var);
check_return_code($return_var,$output);
unset($output);
$restart_dns = 'yes';