diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias
index a3383ee3..f4889da6 100755
--- a/bin/v-add-dns-on-web-alias
+++ b/bin/v-add-dns-on-web-alias
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
#!/bin/bash
# info: add dns domain or dns record based on web domain alias restart
# options: USER DOMAIN
@@ -78,3 +79,92 @@ fi
# No Logging
exit
+=======
+#!/bin/bash
+# info: add dns domain or dns record based on web domain alias restart
+# options: USER DOMAIN
+#
+# The function adds dns domain or dns record based on web domain alias.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# 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"
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN ALIAS'
+validate_format 'user' 'domain'
+is_system_enabled "$WEB_SYSTEM"
+is_system_enabled "$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"
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+# Parsing domain values
+get_domain_values 'web'
+
+# 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
+ $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.//" )
+ if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
+ $BIN/v-add-dns-domain \
+ $user $dom $IP '' '' '' '' '' $restart > /dev/null
+
+ if [ $? -eq 0 ]; then
+ $BIN/v-add-dns-domain-record \
+ $user $dom "$sub" A $IP '' '' $restart
+ fi
+ else
+ if [ "$sub" == '*' ]; then
+ rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
+ else
+ rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
+ fi
+ if [ -z "$rec" ]; then
+ $BIN/v-add-dns-domain-record \
+ $user $dom "$sub" A $IP '' '' $restart > /dev/null
+ fi
+ fi
+fi
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# No Logging
+
+exit
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp
index e2d566a8..69c58673 100755
--- a/bin/v-add-web-domain-ftp
+++ b/bin/v-add-web-domain-ftp
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
#!/bin/bash
# info: add ftp account for web domain.
# options: USER DOMAIN FTP_USER FTP_PASSWORD
@@ -69,3 +70,82 @@ log_history "added ftp account $ftp_user for $domain"
log_event "$OK" "$EVENT"
exit
+=======
+#!/bin/bash
+# info: add ftp account for web domain.
+# options: USER DOMAIN FTP_USER FTP_PASSWORD
+#
+# The function creates addutional ftp account for web domain.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain_idn=$(idn -t --quiet -a "$domain")
+ftp_user=${1}_${3}
+ftp_password=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+
+# Hiding password
+A4='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
+validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
+is_system_enabled "$WEB_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"
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+get_domain_values 'web'
+check_ftp_user=$(grep "^$ftp_user:" /etc/passwd)
+if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then
+ echo "Error: ftp user $ftp_user already exists"
+ log_event "$E_EXISTS $EVENT"
+ exit $E_EXISTS
+fi
+
+if [ ! -z "$FTP_USER" ]; then
+ /usr/sbin/userdel $FTP_USER
+fi
+
+# Adding user
+/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \
+ -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
+echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null
+ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)"
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user"
+update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5"
+
+# Logging
+log_history "added ftp account $ftp_user for $domain"
+log_event "$OK" "$EVENT"
+
+exit
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains
index 1571305c..cb1a6630 100755
--- a/bin/v-rebuild-web-domains
+++ b/bin/v-rebuild-web-domains
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
#!/bin/bash
# info: rebuild dns domains
# options: USER [RESTART]
@@ -310,3 +311,317 @@ fi
log_event "$OK" "$EVENT"
exit
+=======
+#!/bin/bash
+# info: rebuild dns domains
+# options: USER [RESTART]
+#
+# The function rebuilds BIND configuration files for all dns domains.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+restart=$2
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+source $VESTA/func/ip.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'USER [RESTART]'
+validate_format 'user'
+is_system_enabled "$WEB_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+user_domains=0
+user_ssl=0
+user_aliases=0
+suspended_web=0
+
+# Clean up old config
+rm -f $HOMEDIR/$user/conf/tmp_*.conf
+
+# Defining config
+conf=$USER_DATA/web.conf
+fields='$DOMAIN'
+nohead=1
+
+# Starting loop
+for domain in $(shell_list) ; do
+
+ # Rebuilding directories
+ mkdir -p $HOMEDIR/$user/web/$domain \
+ $HOMEDIR/$user/web/$domain/public_html \
+ $HOMEDIR/$user/web/$domain/public_shtml \
+ $HOMEDIR/$user/web/$domain/document_errors \
+ $HOMEDIR/$user/web/$domain/cgi-bin \
+ $HOMEDIR/$user/web/$domain/private \
+ $HOMEDIR/$user/web/$domain/stats \
+ $HOMEDIR/$user/web/$domain/logs
+ if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then
+ ln -s /var/log/httpd/domains/$domain.error.log \
+ $HOMEDIR/$user/web/$domain/logs/$domain.log
+ fi
+ if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then
+ ln -s /var/log/httpd/domains/$domain.error.log \
+ $HOMEDIR/$user/web/$domain/logs/$domain.error.log
+ fi
+ if [ -e "$WEBTPL/skel/document_errors/" ]; then
+ cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/
+ fi
+
+ touch /var/log/httpd/domains/$domain.bytes \
+ /var/log/httpd/domains/$domain.log \
+ /var/log/httpd/domains/$domain.error.log
+
+ chmod 551 $HOMEDIR/$user/web/$domain
+ chmod 771 $HOMEDIR/$user/web/$domain/private
+ chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
+ chmod 771 $HOMEDIR/$user/web/$domain/public_html
+ chmod 771 $HOMEDIR/$user/web/$domain/public_shtml
+ chmod 771 $HOMEDIR/$user/web/$domain/document_errors
+ chmod 551 $HOMEDIR/$user/web/$domain/stats
+ chmod 551 $HOMEDIR/$user/web/$domain/logs
+ chmod 640 /var/log/httpd/domains/$domain.*
+
+ chown $user:$user $HOMEDIR/$user/web/$domain
+ chown $user:$user $HOMEDIR/$user/web/$domain/private
+ chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin
+ chown $user:$user $HOMEDIR/$user/web/$domain/public_html
+ chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml
+ chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors
+ chown root:$user /var/log/httpd/domains/$domain.*
+ chown root:apache $conf
+
+ # Parsing domain values
+ domain_idn=$(idn -t --quiet -a "$domain")
+ get_domain_values 'web'
+
+ # Preparing domain values for the template substitution
+ upd_web_domain_values
+
+ # Adding domain to the tmp_httpd.conf
+ tpl_file="$WEBTPL/apache_$TPL.tpl"
+ conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
+ add_web_config
+ chown root:apache $conf
+ chmod 640 $conf
+
+ # Running template trigger
+ if [ -x $WEBTPL/apache_$TPL.sh ]; then
+ $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot
+ fi
+
+ # Checking aliases
+ if [ ! -z "$ALIAS" ]; then
+ aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l)
+ user_aliases=$((user_aliases + aliases))
+ fi
+
+ # Checking stats
+ if [ ! -z "$STATS" ]; then
+ cat $WEBTPL/$STATS.tpl |\
+ sed -e "s/%ip%/$ip/g" \
+ -e "s/%web_port%/$WEB_PORT/g" \
+ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
+ -e "s/%proxy_port%/$PROXY_PORT/g" \
+ -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
+ -e "s/%domain_idn%/$domain_idn/g" \
+ -e "s/%domain%/$domain/g" \
+ -e "s/%user%/$user/g" \
+ -e "s/%home%/${HOMEDIR////\/}/g" \
+ -e "s/%alias%/${aliases//,/ }/g" \
+ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
+ > $HOMEDIR/$user/conf/web/$STATS.$domain.conf
+
+ if [ "$STATS" == 'awstats' ]; then
+ if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then
+ ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/
+ fi
+ fi
+
+ webstats="$BIN/v-update-web-domain-stat $user $domain"
+ check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe)
+ if [ -z "$check_webstats" ]; then
+ echo "$webstats" >> $VESTA/data/queue/webstats.pipe
+ fi
+
+ if [ ! -z "$STATS_USER" ]; then
+ # Definining statistic dir
+ stats_dir="$HOMEDIR/$user/web/$domain/stats"
+
+ # Adding htaccess file
+ echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess
+ echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess
+ echo "AuthType Basic" >> $stats_dir/.htaccess
+ echo "Require valid-user" >> $stats_dir/.htaccess
+
+ # Generating htaccess user and password
+ echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd
+ fi
+ fi
+
+ # Checking ssl
+ if [ "$SSL" = 'yes' ]; then
+ # Adding domain to the shttpd.conf
+ conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
+ tpl_file="$WEBTPL/apache_$TPL.stpl"
+ add_web_config
+ chown root:apache $conf
+ chmod 640 $conf
+
+ cp -f $USER_DATA/ssl/$domain.crt \
+ $HOMEDIR/$user/conf/web/ssl.$domain.crt
+ cp -f $USER_DATA/ssl/$domain.key \
+ $HOMEDIR/$user/conf/web/ssl.$domain.key
+ cp -f $USER_DATA/ssl/$domain.pem \
+ $HOMEDIR/$user/conf/web/ssl.$domain.pem
+ if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
+ cp -f $USER_DATA/ssl/$domain.ca \
+ $HOMEDIR/$user/conf/web/ssl.$domain.ca
+ fi
+
+ # Running template trigger
+ if [ -x $WEBTPL/apache_$TPL.sh ]; then
+ $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
+ fi
+
+ user_ssl=$((user_ssl + 1))
+ ssl_change='yes'
+ fi
+
+ # Checking nginx
+ if [ ! -z "$NGINX" ]; then
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+ conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
+ add_web_config
+ chown root:nginx $conf
+ chmod 640 $conf
+
+ if [ "$SSL" = 'yes' ]; then
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+ conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
+ add_web_config
+ chown root:nginx $conf
+ chmod 640 $conf
+ fi
+ ngix_change='yes'
+ fi
+ if [ "$SUSPENDED" = 'yes' ]; then
+ suspended_web=$((suspended_web + 1))
+ fi
+ user_domains=$((user_domains + 1))
+
+ # Checking ftp
+ if [ ! -z "$FTP_USER" ]; then
+ if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then
+ /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \
+ -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
+
+ shadow='/etc/shadow'
+ shdw=$(grep "^$FTP_USER:" $shadow)
+ shdw3=$(echo "$shdw" | cut -f3 -d :)
+ shdw4=$(echo "$shdw" | cut -f4 -d :)
+ shdw5=$(echo "$shdw" | cut -f5 -d :)
+ shdw6=$(echo "$shdw" | cut -f6 -d :)
+ shdw7=$(echo "$shdw" | cut -f7 -d :)
+ shdw8=$(echo "$shdw" | cut -f8 -d :)
+ shdw9=$(echo "$shdw" | cut -f9 -d :)
+ chmod u+w $shadow
+ sed -i "/^$FTP_USER:*/d" $shadow
+ shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6"
+ shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9"
+ echo "$shdw_str" >> $shadow
+ chmod u-w $shadow
+ fi
+ fi
+
+done
+
+# Renaming tmp config
+tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
+conf="$HOMEDIR/$user/conf/web/httpd.conf"
+if [ -e "$tmp_conf" ]; then
+ mv $tmp_conf $conf
+fi
+
+# Checking include in main httpd.conf
+main_conf='/etc/httpd/conf.d/vesta.conf'
+main_conf_check=$(grep "$conf" $main_conf )
+if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then
+ echo "Include $conf" >>$main_conf
+fi
+
+# Checking ssl
+if [ "$ssl_change" = 'yes' ]; then
+ tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
+ conf="$HOMEDIR/$user/conf/web/shttpd.conf"
+ mv $tmp_conf $conf
+
+ # Checking include in main httpd.conf
+ main_conf_check=$(grep "$conf" $main_conf )
+ if [ -z "$main_conf_check" ]; then
+ echo "Include $conf" >>$main_conf
+ fi
+fi
+
+# Checking nginx
+if [ "$ngix_change" = 'yes' ]; then
+ nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
+ tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
+ conf="$HOMEDIR/$user/conf/web/nginx.conf"
+ mv $tmp_conf $conf
+
+ nginx_conf_check=$(grep "$conf" $nginx_conf )
+ if [ -z "$nginx_conf_check" ]; then
+ echo "include $conf;" >>$nginx_conf
+ fi
+
+ # Checking ssl for nginx
+ if [ "$ssl_change" = 'yes' ]; then
+ tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
+ conf="$HOMEDIR/$user/conf/web/snginx.conf"
+ mv $tmp_conf $conf
+ nginx_conf_check=$(grep "$conf" $nginx_conf )
+ if [ -z "$nginx_conf_check" ]; then
+ echo "include $conf;" >>$nginx_conf
+ fi
+ fi
+fi
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Updating counters
+update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web"
+update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains"
+update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
+update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
+
+# Restart web server
+if [ "$restart" != 'no' ]; then
+ $BIN/v-restart-web "$EVENT"
+fi
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats
index 06604285..3410d858 100755
--- a/bin/v-update-user-stats
+++ b/bin/v-update-user-stats
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
#!/bin/bash
# info: update user statistics
# options: USER
@@ -167,3 +168,174 @@ fi
log_event "$OK" "$EVENT"
exit
+=======
+#!/bin/bash
+# info: update user statistics
+# options: USER
+#
+# Function logs user parameters into statistics database.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+
+# Importing system enviroment as we run this script
+# mostly by cron wich not read it by itself
+source /etc/profile
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '0' "$#" 'USER'
+if [ ! -z "$user" ]; then
+ validate_format 'user'
+ is_object_valid 'user' 'USER' "$user"
+fi
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+# Creating user_list
+if [ -z "$user" ]; then
+ user_list=$(ls $VESTA/data/users)
+else
+ user_list="$user"
+fi
+
+# Reset overal statistics
+TOTAL_IP_OWNED=0
+TOTAL_U_DISK=0
+TOTAL_U_DISK_DIRS=0
+TOTAL_U_DISK_WEB=0
+TOTAL_U_DISK_MAIL=0
+TOTAL_U_DISK_DB=0
+TOTAL_U_BANDWIDTH=0
+TOTAL_U_WEB_DOMAINS=0
+TOTAL_U_WEB_SSL=0
+TOTAL_U_WEB_ALIASES=0
+TOTAL_U_DNS_DOMAINS=0
+TOTAL_U_DNS_RECORDS=0
+TOTAL_U_MAIL_DOMAINS=0
+TOTAL_U_MAIL_DKIM=0
+TOTAL_U_MAIL_ACCOUNTS=0
+TOTAL_U_DATABASES=0
+TOTAL_U_CRON_JOBS=0
+TOTAL_U_BACKUPS=0
+
+# Updating user stats
+for user in $user_list; do
+ USER_DATA=$VESTA/data/users/$user
+ source $USER_DATA/user.conf
+ next_month=$(date +'%m/01/%y' -d '+ 1 month')
+ DATE=$(date -d "$next_month -1day" +%F)
+
+ # Compiling report string
+ s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'"
+ s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'"
+ s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'"
+ s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'"
+ s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'"
+ s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'"
+ s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'"
+ s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'"
+ s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'"
+ s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'"
+
+ # Updating user stats log
+ stats="$USER_DATA/stats.log"
+ if [ -e "$stats" ]; then
+ # Checking dublicates
+ check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :)
+ if [ -z "$check_month" ]; then
+ # Updating as there no dublicates
+ echo "$s" >> $stats
+ chmod 660 $stats
+ else
+ # Replacing string with new data
+ sed -i "$check_month s/.*/$s/" $stats
+ fi
+ else
+ # Creating stats log
+ echo "$s" >$stats
+ chmod 660 $stats
+ fi
+
+ # Increase overall counters
+ TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED))
+ TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK))
+ TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS))
+ TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB))
+ TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL))
+ TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB))
+ TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH))
+ TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS))
+ TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL))
+ TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES))
+ TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS))
+ TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS))
+ TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS))
+ TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM))
+ TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS))
+ TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES))
+ TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS))
+ TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS))
+
+done
+
+# Updating overall stats
+stats="$VESTA/data/users/admin/overall_stats.log"
+
+s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'"
+s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'"
+s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'"
+s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'"
+s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'"
+s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'"
+s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'"
+s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'"
+s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'"
+s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'"
+s="$s U_DATABASES='$TOTAL_U_DATABASES'"
+s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'"
+
+if [ -e "$stats" ]; then
+ # Checking dublicates
+ check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :)
+ if [ -z "$check_month" ]; then
+ # Updating as there no dublicates
+ echo "$s" >> $stats
+ chmod 660 $stats
+ else
+ # Replacing string with new data
+ sed -i "$check_month s/.*/$s/" $stats
+ fi
+else
+ # Creating stats log
+ echo "$s" >$stats
+ chmod 660 $stats
+fi
+
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/func/domain.sh b/func/domain.sh
index 3ac06476..738c3f6a 100644
--- a/func/domain.sh
+++ b/func/domain.sh
@@ -1,463 +1,541 @@
-# Web template check
-is_apache_template_valid() {
- t="$WEBTPL/apache_$template.tpl"
- s="$WEBTPL/apache_$template.stpl"
- if [ ! -e $t ] || [ ! -e $s ]; then
- template='default'
- t="$WEBTPL/apache_$template.tpl"
- s="$WEBTPL/apache_$template.stpl"
- if [ ! -e $t ] || [ ! -e $s ]; then
- echo "Error: template $template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
- fi
-}
-
-# Nginx template check
-is_nginx_template_valid() {
- t="$WEBTPL/nginx_$template.tpl"
- s="$WEBTPL/nginx_$template.stpl"
- if [ ! -e $t ] || [ ! -e $s ]; then
- template='default'
- t="$WEBTPL/nginx_$template.tpl"
- s="$WEBTPL/nginx_$template.stpl"
- if [ ! -e $t ] || [ ! -e $s ]; then
- echo "Error: nginx $template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
- fi
-}
-
-# DNS template check
-is_dns_template_valid() {
- tpl="$DNSTPL/$template.tpl"
- if [ ! -e $tpl ]; then
- template='default'
- tpl="$DNSTPL/$template.tpl"
- if [ ! -e $tpl ]; then
- echo "Error: template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
- fi
-}
-
-# Checking domain existance
-is_domain_new() {
- type="$1"
- dom=${2-$domain}
- web="$(grep -w $dom $VESTA/data/users/*/web.conf)"
- dns="$(grep DOMAIN='$dom' $VESTA/data/users/*/dns.conf)"
- mail="$(grep DOMAIN='$dom' $VESTA/data/users/*/mail.conf)"
-
- if [ -n "$web" ] || [ -n "$dns" ] || [ -n "$mail" ]; then
- if [ ! -z "$(grep -w $dom $USER_DATA/*.conf)" ]; then
- c1=$(grep "'$dom'" $USER_DATA/$type.conf)
- c2=$(grep "'$dom," $USER_DATA/$type.conf)
- c3=$(grep ",$dom," $USER_DATA/$type.conf)
- c4=$(grep ",$dom'" $USER_DATA/$type.conf)
-
- if [ -n "$c1" ] || [ -n "$c2" ] || [ -n "$c3" ] || [ -n "$c4" ]
- then
- echo "Error: domain $dom exist"
- log_event "$E_EXISTS" "$EVENT"
- exit $E_EXISTS
- fi
- else
- echo "Error: domain $dom exist"
- log_event "$E_EXISTS" "$EVENT"
- exit $E_EXISTS
- fi
- fi
-}
-
-# Checking mail account existance
-is_mail_new() {
- check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
- if [ ! -z "$check_acc" ]; then
- echo "Error: mail account $1 exist"
- log_event "$E_EXISTS" "$EVENT"
- exit
- fi
- check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
- check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
- if [ ! -z "$check_als" ]; then
- echo "Error: mail alias $1 exist"
- log_event "$E_EXISTS" "$EVENT"
- exit
- fi
-}
-
-# Update domain zone
-update_domain_zone() {
- conf="$HOMEDIR/$user/conf/dns/$domain.db"
- line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
- fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
- if [ -e $conf ]; then
- zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g")
- s_date=$(echo ${zn_serial:0:8})
- c_date=$(date +'%Y%m%d')
- if [ "$s_date" == "$c_date" ]; then
- cur_value=$(echo ${zn_serial:8} )
- new_value=$(expr $cur_value + 1 )
- len_value=$(expr length $new_value)
- if [ 1 -eq "$len_value" ]; then
- new_value='0'$new_value
- fi
- serial="$c_date""$new_value"
- else
- serial="$(date +'%Y%m%d01')"
- fi
- else
- serial="$(date +'%Y%m%d01')"
- fi
-
- eval $line
- SOA=$(idn --quiet -a -t "$SOA")
- echo "\$TTL $TTL
-@ IN SOA $SOA. root.$domain_idn. (
- $serial
- 7200
- 3600
- 1209600
- 180 )
-" > $conf
- while read line ; do
- IFS=$'\n'
- for key in $(echo $line|sed -e "s/' /'\n/g"); do
- eval ${key%%=*}="${key#*=}"
- done
-
- RECORD=$(idn --quiet -a -t "$RECORD")
- if [ "$SUSPENDED" != 'yes' ]; then
- eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
- fi
- done < $USER_DATA/dns/$domain.conf
-}
-
-# Get next DNS record ID
-get_next_dnsrecord(){
- if [ -z "$id" ]; then
- curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
- sort -n|tail -n1)
- id="$((curr_str +1))"
- fi
-}
-
-# Sort DNS records
-sort_dns_records() {
- conf="$USER_DATA/dns/$domain.conf"
- cat $conf |sort -n -k 2 -t \' >$conf.tmp
- mv -f $conf.tmp $conf
-}
-
-# Add web config
-add_web_config() {
- cat $tpl_file | \
- sed -e "s/%ip%/$ip/g" \
- -e "s/%web_port%/$WEB_PORT/g" \
- -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
- -e "s/%proxy_port%/$PROXY_PORT/g" \
- -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
- -e "s/%domain_idn%/$domain_idn/g" \
- -e "s/%domain%/$domain/g" \
- -e "s/%user%/$user/g" \
- -e "s/%group%/$group/g" \
- -e "s/%home%/${HOMEDIR////\/}/g" \
- -e "s/%docroot%/${docroot////\/}/g" \
- -e "s/%sdocroot%/${sdocroot////\/}/g" \
- -e "s/%email%/$email/g" \
- -e "s/%alias_string%/$alias_string/g" \
- -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
- -e "s/%alias%/${aliases//,/ }/g" \
- -e "s/%ssl_crt%/${ssl_crt////\/}/g" \
- -e "s/%ssl_key%/${ssl_key////\/}/g" \
- -e "s/%ssl_pem%/${ssl_pem////\/}/g" \
- -e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \
- -e "s/%ssl_ca%/${ssl_ca////\/}/g" \
- -e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \
- -e "s/%elog%/$elog/g" \
- -e "s/%cgi%/$cgi/g" \
- -e "s/%cgi_option%/$cgi_option/g" \
- >> $conf
-}
-
-# Get config top and bottom line numbers
-get_web_config_brds() {
- serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
- if [ -z "$serv_line" ]; then
- log_event "$E_PARSING" "$EVENT"
- return $E_PARSING
- fi
-
- last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
- bfr_line=$((serv_line - 1))
- aftr_line=$((last_line - serv_line - 1))
-
- str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
- top_line=$((str - serv_line + 1))
- bottom_line=$((top_line + last_line -1))
-
- multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
- if [ "$multi" -ge 2 ]; then
- bottom_line=$((bottom_line + multi -1))
- fi
-
-}
-
-# Change web config
-change_web_config() {
- get_web_config_brds || exit $?
- vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
- str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
- str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
- str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
-
- str_repl=$(echo "$str_repl" | sed \
- -e 's/\\/\\\\/g' \
- -e 's/&/\\&/g' \
- -e 's/\//\\\//g')
-
- if [ ! -z "$str" ]; then
- sed -i "$str_numb s/.*/$str_repl/" $conf
- fi
-}
-
-# Replace web config
-replace_web_config() {
- get_web_config_brds || exit $?
- clean_new=$(echo "$new" | sed \
- -e 's/\\/\\\\/g' \
- -e 's/&/\\&/g' \
- -e 's/\//\\\//g')
- clean_old=$(echo "$old" | sed \
- -e 's/\\/\\\\/g' \
- -e 's/&/\\&/g' \
- -e 's/\//\\\//g')
-
- sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
-}
-
-# Get domain variables
-get_domain_values() {
- for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
- eval $line
- done
-}
-
-# SSL certificate verification
-is_web_domain_cert_valid() {
- if [ ! -e "$ssl_dir/$domain.crt" ]; then
- echo "Error: $ssl_dir/$domain.crt not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
-
- if [ ! -e "$ssl_dir/$domain.key" ]; then
- echo "Error: $ssl_dir/$domain.key not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
-
- crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
- if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
- echo "Error: certificate is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-
- if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
- if [ ! -e "$ssl_dir/$domain.ca" ]; then
- echo "Error: certificate authority not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
- fi
-
- if [ -e "$ssl_dir/$domain.ca" ]; then
- ca_vrf=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep 'OK')
- if [ -z "$ca_vrf" ]; then
- echo "Error: ssl certificate authority is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-
- crt_vrf=$(openssl verify -untrusted $ssl_dir/$domain.ca \
- $ssl_dir/$domain.crt 2>/dev/null |grep 'OK')
- if [ -z "$crt_vrf" ]; then
- echo "Error: root or/and intermediate cerificate not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
- fi
-
- key_vrf=$(grep 'RSA PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
- if [ "$key_vrf" -ne 2 ]; then
- echo "Error: ssl key is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-
- openssl s_server -quiet -cert $ssl_dir/$domain.crt \
- -key $ssl_dir/$domain.key >> /dev/null 2>&1 &
- pid=$!
- sleep 0.5
- disown &> /dev/null
- kill $pid &> /dev/null
- if [ "$?" -ne '0' ]; then
- echo "Error: ssl certificate key pair is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Delete web configuartion
-del_web_config() {
- get_web_config_brds || exit $?
- sed -i "$top_line,$bottom_line d" $conf
-}
-
-# Add ip virtual hosting support
-namehost_ip_support() {
- if [ "$WEB_SYSTEM" = 'apache' ]; then
- conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':')
- if [ ! -z "$conf_line" ]; then
- conf_ins=$((conf_line + 1))
- else
- conf_ins='1'
- fi
-
- if [ "$WEB_SSL" = 'mod_ssl' ]; then
- sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf
- sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf
- fi
-
- sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf
- sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
-
- if [ "$PROXY_SYSTEM" = 'nginx' ]; then
- cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \
- -e "s/%web_port%/$WEB_PORT/g" \
- -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf
-
- ips=$(grep 'MEFaccept ' $rconf |grep -v '#'| head -n1)
- sed -i "s/$ips/$ips $ip/g" $rconf
- fi
- web_restart='yes'
- fi
-}
-
-# Disable virtual ip hosting support
-namehost_ip_disable() {
- if [ "$WEB_SYSTEM" = 'apache' ]; then
- sed -i "/NameVirtualHost $ip:/d" $conf
- sed -i "/Listen $ip:/d" $conf
-
- if [ "$PROXY_SYSTEM" = 'nginx' ]; then
- tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ')
- ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\
- cut -f 1 -d :)
- conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :)
- if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
- then
- echo "Error: nginx config paring error"
- log_event "$E_PARSING" "$EVENT"
- exit $E_PARSING
- fi
- up_line=$((ip_line - 1))
- first_line=$((conf_line - up_line))
- last_line=$((conf_line - ip_line + tpl_ln))
-
- if [ -z "$first_line" ] || [ -z "$last_line" ]; then
- echo "Error: nginx config paring error"
- log_event "$E_PARSING" "$EVENT"
- exit $E_PARSING
- fi
- sed -i "$first_line,$last_line d" $nconf
- ips=$(grep 'RPAFproxy_ips' $rconf)
- new_ips=$(echo "$ips"|sed -e "s/$ip//")
- sed -i "s/$ips/$new_ips/g" $rconf
- fi
- web_restart='yes'
- fi
-}
-
-# Update web domain values
-upd_web_domain_values() {
- ip=$IP
- group="$user"
- email="$user@$domain"
- docroot="$HOMEDIR/$user/web/$domain/public_html"
- sdocroot=$docroot
- if [ "$SSL_HOME" = 'single' ]; then
- sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
- fi
-
- i=1
- j=1
- OLD_IFS="$IFS"
- IFS=','
- server_alias=''
- alias_string=''
- aliases_idn=''
-
- for dalias in $ALIAS; do
- dalias=$(idn -t --quiet -a $dalias)
- check_8k="$server_alias $dalias"
- if [ "${#check_8k}" -ge '8100' ]; then
- if [ "$j" -eq 1 ]; then
- alias_string="ServerAlias $server_alias"
- else
- alias_string="$alias_string\n ServerAlias $server_alias"
- fi
- j=2
- server_alias=''
- fi
- if [ "$i" -eq 1 ]; then
- aliases_idn="$dalias"
- server_alias="$dalias"
- alias_string="ServerAlias $server_alias"
- else
- aliases_idn="$aliases_idn,$dalias"
- server_alias="$server_alias $dalias"
- fi
- i=2
- done
-
- if [ $j -gt 1 ]; then
- alias_string="$alias_string\n ServerAlias $server_alias"
- else
- alias_string="ServerAlias $server_alias"
- fi
-
- IFS=$OLD_IFS
- if [ "$ELOG" = 'no' ]; then
- elog='#'
- else
- elog=''
- fi
-
- if [ "$CGI" != 'yes' ]; then
- cgi='#'
- cgi_option='-ExecCGI'
- else
- cgi=''
- cgi_option='+ExecCGI'
- fi
-
- ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
- ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
- ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
- ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
- if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
- ssl_ca_str='#'
- fi
-
- if [ "$SUSPENDED" = 'yes' ]; then
- docroot="$VESTA/data/templates/web/suspend"
- sdocroot="$VESTA/data/templates/web/suspend"
- fi
-}
-
+# Web template check
+is_apache_template_valid() {
+ t="$WEBTPL/apache_$template.tpl"
+ s="$WEBTPL/apache_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ template='default'
+ t="$WEBTPL/apache_$template.tpl"
+ s="$WEBTPL/apache_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ echo "Error: template $template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+ fi
+}
+
+# Nginx template check
+is_nginx_template_valid() {
+ t="$WEBTPL/nginx_$template.tpl"
+ s="$WEBTPL/nginx_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ template='default'
+ t="$WEBTPL/nginx_$template.tpl"
+ s="$WEBTPL/nginx_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ echo "Error: nginx $template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+ fi
+}
+
+# DNS template check
+is_dns_template_valid() {
+ tpl="$DNSTPL/$template.tpl"
+ if [ ! -e $tpl ]; then
+ template='default'
+ tpl="$DNSTPL/$template.tpl"
+ if [ ! -e $tpl ]; then
+ echo "Error: template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+ fi
+}
+
+# Checking domain existance
+is_domain_new() {
+ type="$1"
+ dom=${2-$domain}
+
+ web=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
+ dns=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
+ mail=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
+
+ # Check web domain
+ if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
+ echo "Error: domain $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"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ fi
+
+ # Check dns domain
+ if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then
+ echo "Error: domain $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"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ fi
+
+ # Check mail domain
+ if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then
+ echo "Error: domain $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"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ fi
+
+ # Check web aliases
+ web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf)
+ if [ ! -z "$web_alias" ]; then
+ c1=$(grep "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+
+ if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+
+ if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+
+ if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
+ echo "Error: domain $dom exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+ fi
+}
+
+# Checking mail account existance
+is_mail_new() {
+ check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
+ if [ ! -z "$check_acc" ]; then
+ echo "Error: mail account $1 exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit
+ fi
+ check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
+ check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
+ if [ ! -z "$check_als" ]; then
+ echo "Error: mail alias $1 exist"
+ log_event "$E_EXISTS" "$EVENT"
+ exit
+ fi
+}
+
+# Update domain zone
+update_domain_zone() {
+ conf="$HOMEDIR/$user/conf/dns/$domain.db"
+ line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
+ fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
+ if [ -e $conf ]; then
+ zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g")
+ s_date=$(echo ${zn_serial:0:8})
+ c_date=$(date +'%Y%m%d')
+ if [ "$s_date" == "$c_date" ]; then
+ cur_value=$(echo ${zn_serial:8} )
+ new_value=$(expr $cur_value + 1 )
+ len_value=$(expr length $new_value)
+ if [ 1 -eq "$len_value" ]; then
+ new_value='0'$new_value
+ fi
+ serial="$c_date""$new_value"
+ else
+ serial="$(date +'%Y%m%d01')"
+ fi
+ else
+ serial="$(date +'%Y%m%d01')"
+ fi
+
+ eval $line
+ SOA=$(idn --quiet -a -t "$SOA")
+ echo "\$TTL $TTL
+@ IN SOA $SOA. root.$domain_idn. (
+ $serial
+ 7200
+ 3600
+ 1209600
+ 180 )
+" > $conf
+ while read line ; do
+ IFS=$'\n'
+ for key in $(echo $line|sed -e "s/' /'\n/g"); do
+ eval ${key%%=*}="${key#*=}"
+ done
+
+ RECORD=$(idn --quiet -a -t "$RECORD")
+ if [ "$SUSPENDED" != 'yes' ]; then
+ eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
+ fi
+ done < $USER_DATA/dns/$domain.conf
+}
+
+# Get next DNS record ID
+get_next_dnsrecord(){
+ if [ -z "$id" ]; then
+ curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
+ sort -n|tail -n1)
+ id="$((curr_str +1))"
+ fi
+}
+
+# Sort DNS records
+sort_dns_records() {
+ conf="$USER_DATA/dns/$domain.conf"
+ cat $conf |sort -n -k 2 -t \' >$conf.tmp
+ mv -f $conf.tmp $conf
+}
+
+# Add web config
+add_web_config() {
+ cat $tpl_file | \
+ sed -e "s/%ip%/$ip/g" \
+ -e "s/%web_port%/$WEB_PORT/g" \
+ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
+ -e "s/%proxy_port%/$PROXY_PORT/g" \
+ -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
+ -e "s/%domain_idn%/$domain_idn/g" \
+ -e "s/%domain%/$domain/g" \
+ -e "s/%user%/$user/g" \
+ -e "s/%group%/$group/g" \
+ -e "s/%home%/${HOMEDIR////\/}/g" \
+ -e "s/%docroot%/${docroot////\/}/g" \
+ -e "s/%sdocroot%/${sdocroot////\/}/g" \
+ -e "s/%email%/$email/g" \
+ -e "s/%alias_string%/$alias_string/g" \
+ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
+ -e "s/%alias%/${aliases//,/ }/g" \
+ -e "s/%ssl_crt%/${ssl_crt////\/}/g" \
+ -e "s/%ssl_key%/${ssl_key////\/}/g" \
+ -e "s/%ssl_pem%/${ssl_pem////\/}/g" \
+ -e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \
+ -e "s/%ssl_ca%/${ssl_ca////\/}/g" \
+ -e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \
+ -e "s/%elog%/$elog/g" \
+ -e "s/%cgi%/$cgi/g" \
+ -e "s/%cgi_option%/$cgi_option/g" \
+ >> $conf
+}
+
+# Get config top and bottom line numbers
+get_web_config_brds() {
+ serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
+ if [ -z "$serv_line" ]; then
+ log_event "$E_PARSING" "$EVENT"
+ return $E_PARSING
+ fi
+
+ last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
+ bfr_line=$((serv_line - 1))
+ aftr_line=$((last_line - serv_line - 1))
+
+ str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
+ top_line=$((str - serv_line + 1))
+ bottom_line=$((top_line + last_line -1))
+
+ multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
+ if [ "$multi" -ge 2 ]; then
+ bottom_line=$((bottom_line + multi -1))
+ fi
+
+}
+
+# Change web config
+change_web_config() {
+ get_web_config_brds || exit $?
+ vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
+ str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
+ str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
+ str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
+
+ str_repl=$(echo "$str_repl" | sed \
+ -e 's/\\/\\\\/g' \
+ -e 's/&/\\&/g' \
+ -e 's/\//\\\//g')
+
+ if [ ! -z "$str" ]; then
+ sed -i "$str_numb s/.*/$str_repl/" $conf
+ fi
+}
+
+# Replace web config
+replace_web_config() {
+ get_web_config_brds || exit $?
+ clean_new=$(echo "$new" | sed \
+ -e 's/\\/\\\\/g' \
+ -e 's/&/\\&/g' \
+ -e 's/\//\\\//g')
+ clean_old=$(echo "$old" | sed \
+ -e 's/\\/\\\\/g' \
+ -e 's/&/\\&/g' \
+ -e 's/\//\\\//g')
+
+ sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
+}
+
+# Get domain variables
+get_domain_values() {
+ for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
+ eval $line
+ done
+}
+
+# SSL certificate verification
+is_web_domain_cert_valid() {
+ if [ ! -e "$ssl_dir/$domain.crt" ]; then
+ echo "Error: $ssl_dir/$domain.crt not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+
+ if [ ! -e "$ssl_dir/$domain.key" ]; then
+ echo "Error: $ssl_dir/$domain.key not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+
+ crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
+ if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
+ echo "Error: certificate is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+
+ if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
+ if [ ! -e "$ssl_dir/$domain.ca" ]; then
+ echo "Error: certificate authority not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+ fi
+
+ if [ -e "$ssl_dir/$domain.ca" ]; then
+ ca_vrf=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep 'OK')
+ if [ -z "$ca_vrf" ]; then
+ echo "Error: ssl certificate authority is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+
+ crt_vrf=$(openssl verify -untrusted $ssl_dir/$domain.ca \
+ $ssl_dir/$domain.crt 2>/dev/null |grep 'OK')
+ if [ -z "$crt_vrf" ]; then
+ echo "Error: root or/and intermediate cerificate not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+ fi
+
+ key_vrf=$(grep 'RSA PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
+ if [ "$key_vrf" -ne 2 ]; then
+ echo "Error: ssl key is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+
+ openssl s_server -quiet -cert $ssl_dir/$domain.crt \
+ -key $ssl_dir/$domain.key >> /dev/null 2>&1 &
+ pid=$!
+ sleep 0.5
+ disown &> /dev/null
+ kill $pid &> /dev/null
+ if [ "$?" -ne '0' ]; then
+ echo "Error: ssl certificate key pair is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Delete web configuartion
+del_web_config() {
+ get_web_config_brds || exit $?
+ sed -i "$top_line,$bottom_line d" $conf
+}
+
+# Add ip virtual hosting support
+namehost_ip_support() {
+ if [ "$WEB_SYSTEM" = 'apache' ]; then
+ conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':')
+ if [ ! -z "$conf_line" ]; then
+ conf_ins=$((conf_line + 1))
+ else
+ conf_ins='1'
+ fi
+
+ if [ "$WEB_SSL" = 'mod_ssl' ]; then
+ sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf
+ sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf
+ fi
+
+ sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf
+ sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
+
+ if [ "$PROXY_SYSTEM" = 'nginx' ]; then
+ cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \
+ -e "s/%web_port%/$WEB_PORT/g" \
+ -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf
+
+ ips=$(grep 'MEFaccept ' $rconf |grep -v '#'| head -n1)
+ sed -i "s/$ips/$ips $ip/g" $rconf
+ fi
+ web_restart='yes'
+ fi
+}
+
+# Disable virtual ip hosting support
+namehost_ip_disable() {
+ if [ "$WEB_SYSTEM" = 'apache' ]; then
+ sed -i "/NameVirtualHost $ip:/d" $conf
+ sed -i "/Listen $ip:/d" $conf
+
+ if [ "$PROXY_SYSTEM" = 'nginx' ]; then
+ tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ')
+ ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\
+ cut -f 1 -d :)
+ conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :)
+ if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
+ then
+ echo "Error: nginx config paring error"
+ log_event "$E_PARSING" "$EVENT"
+ exit $E_PARSING
+ fi
+ up_line=$((ip_line - 1))
+ first_line=$((conf_line - up_line))
+ last_line=$((conf_line - ip_line + tpl_ln))
+
+ if [ -z "$first_line" ] || [ -z "$last_line" ]; then
+ echo "Error: nginx config paring error"
+ log_event "$E_PARSING" "$EVENT"
+ exit $E_PARSING
+ fi
+ sed -i "$first_line,$last_line d" $nconf
+ ips=$(grep 'RPAFproxy_ips' $rconf)
+ new_ips=$(echo "$ips"|sed -e "s/$ip//")
+ sed -i "s/$ips/$new_ips/g" $rconf
+ fi
+ web_restart='yes'
+ fi
+}
+
+# Update web domain values
+upd_web_domain_values() {
+ ip=$IP
+ group="$user"
+ email="$user@$domain"
+ docroot="$HOMEDIR/$user/web/$domain/public_html"
+ sdocroot=$docroot
+ if [ "$SSL_HOME" = 'single' ]; then
+ sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
+ fi
+
+ i=1
+ j=1
+ OLD_IFS="$IFS"
+ IFS=','
+ server_alias=''
+ alias_string=''
+ aliases_idn=''
+
+ for dalias in $ALIAS; do
+ dalias=$(idn -t --quiet -a $dalias)
+ check_8k="$server_alias $dalias"
+ if [ "${#check_8k}" -ge '8100' ]; then
+ if [ "$j" -eq 1 ]; then
+ alias_string="ServerAlias $server_alias"
+ else
+ alias_string="$alias_string\n ServerAlias $server_alias"
+ fi
+ j=2
+ server_alias=''
+ fi
+ if [ "$i" -eq 1 ]; then
+ aliases_idn="$dalias"
+ server_alias="$dalias"
+ alias_string="ServerAlias $server_alias"
+ else
+ aliases_idn="$aliases_idn,$dalias"
+ server_alias="$server_alias $dalias"
+ fi
+ i=2
+ done
+
+ if [ $j -gt 1 ]; then
+ alias_string="$alias_string\n ServerAlias $server_alias"
+ else
+ alias_string="ServerAlias $server_alias"
+ fi
+
+ IFS=$OLD_IFS
+ if [ "$ELOG" = 'no' ]; then
+ elog='#'
+ else
+ elog=''
+ fi
+
+ if [ "$CGI" != 'yes' ]; then
+ cgi='#'
+ cgi_option='-ExecCGI'
+ else
+ cgi=''
+ cgi_option='+ExecCGI'
+ fi
+
+ ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
+ ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
+ ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
+ ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
+ if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
+ ssl_ca_str='#'
+ fi
+
+ if [ "$SUSPENDED" = 'yes' ]; then
+ docroot="$VESTA/data/templates/web/suspend"
+ sdocroot="$VESTA/data/templates/web/suspend"
+ fi
+}
+
diff --git a/func/main.sh b/func/main.sh
index 697ef4ff..c4a6c133 100644
--- a/func/main.sh
+++ b/func/main.sh
@@ -1,772 +1,772 @@
-# Internal variables
-DATE=$(date +%F)
-TIME=$(date +%T)
-SCRIPT=$(basename $0)
-A1=$1
-A2=$2
-A3=$3
-A4=$4
-A5=$5
-A6=$6
-A7=$7
-A8=$8
-A9=$9
-EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
-EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
-HOMEDIR='/home'
-BACKUP='/backup'
-BACKUP_GZIP=5
-BACKUP_DISK_LIMIT=95
-BACKUP_LA_LIMIT=5
-RRD_STEP=300
-RRD_IFACE_EXCLUDE=lo
-
-BIN=$VESTA/bin
-USER_DATA=$VESTA/data/users/$user
-WEBTPL=$VESTA/data/templates/web
-DNSTPL=$VESTA/data/templates/dns
-RRD=$VESTA/web/rrd
-
-# Return codes
-OK=0
-E_ARGS=1
-E_INVALID=2
-E_NOTEXIST=3
-E_EXISTS=4
-E_SUSPENDED=5
-E_UNSUSPENDED=6
-E_INUSE=7
-E_LIMIT=8
-E_PASSWORD=9
-E_FORBIDEN=10
-E_DISABLED=11
-E_PARSING=12
-E_DISK=13
-E_LA=14
-E_FTP=15
-E_SSH=16
-E_DB=17
-E_RRD=18
-E_UPDATE=19
-E_RESTART=20
-
-# Log event function
-log_event() {
- echo "RC='$1' $2" >> $VESTA/log/system.log
-}
-
-# Log user history
-log_history() {
- cmd=$1
- undo=${2-no}
- log_user=${3-$user}
- log=$VESTA/data/users/$log_user/history.log
-
- touch $log
- if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then
- tail -n 99 $log > $log.moved
- mv -f $log.moved $log
- chmod 660 $log
- fi
-
- curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1)
- id="$((curr_str +1))"
- echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log
-}
-
-# Argument list checker
-check_args() {
- if [ "$1" -gt "$2" ]; then
- echo "Error: not enought arguments"
- echo "Usage: $SCRIPT $3"
- log_event "$E_ARGS" "$EVENT"
- exit $E_ARGS
- fi
-}
-
-# Subsystem checker
-is_system_enabled() {
- if [ -z "$1" ] || [ "$1" = no ]; then
- echo "Error: subsystem disabled"
- log_event "$E_DISABLED" "$EVENT"
- exit $E_DISABLED
- fi
-}
-
-# User package check
-is_package_full() {
- case "$1" in
- WEB_DOMAINS) used=$(wc -l $USER_DATA/web.conf|cut -f1 -d \ );;
- WEB_ALIASES) used=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |\
- awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\
- wc -l );;
- DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );;
- DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain.conf |cut -f1 -d \ );;
- MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );;
- MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.conf |\
- cut -f1 -d \ );;
- DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );;
- CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );;
- esac
- limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
- if [ "$used" -ge "$limit" ]; then
- echo "Error: Limit reached / Upgrade package"
- log_event "$E_LIMIT" "$EVENT"
- exit $E_LIMIT
- fi
-}
-
-# Random password generator
-gen_password() {
- matrix='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
- lenght=10
- while [ ${n:=1} -le $lenght ]; do
- pass="$pass${matrix:$(($RANDOM%${#matrix})):1}"
- let n+=1
- done
- echo "$pass"
-}
-
-# Package existance check
-is_package_valid() {
- if [ -z "$1" ]; then
- pkg_dir="$VESTA/data/packages"
- fi
- if [ ! -e "$pkg_dir/$package.pkg" ]; then
- echo "Error: package $package not exist"
- log_event "$E_NOTEXIST $EVENT"
- exit $E_NOTEXIST
- fi
-}
-
-# Validate system type
-is_type_valid() {
- if [ -z "$(echo $1 | grep -w $2)" ]; then
- echo "Error: $2 is unknown type"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Check user backup settings
-is_backup_enabled() {
- BACKUPS=$(grep "^BACKUPS=" $USER_DATA/user.conf | cut -f2 -d \')
- if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then
- echo "Error: user backup disabled"
- log_event "$E_DISABLED" "$EVENT"
- exit $E_DISABLED
- fi
-}
-
-# Check if object is free and can be created
-is_object_free() {
- if [ $2 = 'USER' ]; then
- if [ -d "$USER_DATA" ]; then
- object="OK"
- fi
- else
- object=$(grep "$2='$3'" $USER_DATA/$1.conf)
- fi
- if [ ! -z "$object" ]; then
- echo "Error: $2 with value $3 exists"
- log_event "$E_EXISTS" "$EVENT"
- exit $E_EXISTS
- fi
-}
-
-# Check if object exists and can be used
-is_object_valid() {
- if [ $2 = 'USER' ]; then
- if [ -d "$VESTA/data/users/$user" ]; then
- sobject="OK"
- fi
- else
- if [ $2 = 'DBHOST' ]; then
- sobject=$(grep "HOST='$host'" $VESTA/conf/$type.conf)
- else
- sobject=$(grep "$2='$3'" $VESTA/data/users/$user/$1.conf)
- fi
- fi
- if [ -z "$sobject" ]; then
- echo "Error: $3 not exist"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
-}
-
-# Check if object is supended
-is_object_suspended() {
- if [ $2 = 'USER' ]; then
- spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
- else
- spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
- fi
- if [ -z "$spnd" ]; then
- echo "Error: $1 $3 is not suspended"
- log_event "$E_SUSPENDED" "$EVENT"
- exit $E_SUSPENDED
- fi
-}
-
-# Check if object is unsupended
-is_object_unsuspended() {
- if [ $2 = 'USER' ]; then
- spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
- else
- spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
- fi
- if [ ! -z "$spnd" ]; then
- echo "Error: $1 $3 is already suspended"
- log_event "$E_UNSUSPENDED" "$EVENT"
- exit $E_UNSUSPENDED
- fi
-}
-
-# Check if object value is empty
-is_object_value_empty() {
- str=$(grep "$2='$3'" $USER_DATA/$1.conf)
- eval $str
- eval value=$4
- if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
- echo "Error: ${4//$}=$value (not empty)"
- log_event "$E_EXISTS" "$EVENT"
- exit $E_EXISTS
- fi
-}
-
-# Check if object value is empty
-is_object_value_exist() {
- str=$(grep "$2='$3'" $USER_DATA/$1.conf)
- eval $str
- eval value=$4
- if [ -z "$value" ] || [ "$value" = 'no' ]; then
- echo "Error: ${4//$}=$value (not exist)"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
- fi
-}
-
-# Get object value
-get_object_value() {
- object=$(grep "$2='$3'" $USER_DATA/$1.conf)
- eval "$object"
- eval echo $4
-}
-
-# Update object value
-update_object_value() {
- row=$(grep -n "$2='$3'" $USER_DATA/$1.conf)
- lnr=$(echo $row | cut -f 1 -d ':')
- object=$(echo $row | sed -e "s/^$lnr://")
- eval "$object"
- eval old="$4"
- old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
- new=$(echo "$5" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
- sed -i "$lnr s/${4//$/}='${old//\*/\\*}'/${4//$/}='${new//\*/\\*}'/g" \
- $USER_DATA/$1.conf
-}
-
-# Search objects
-search_objects() {
- OLD_IFS="$IFS"
- IFS=$'\n'
- for line in $(grep $2=\'$3\' $USER_DATA/$1.conf); do
- eval $line
- eval echo \$$4
- done
- IFS="$OLD_IFS"
-}
-
-# Get user value
-get_user_value() {
- grep "^${1//$/}=" $USER_DATA/user.conf| cut -f 2 -d \'
-}
-
-# Update user value in user.conf
-update_user_value() {
- key="${2//$}"
- lnr=$(grep -n "^$key='" $VESTA/data/users/$1/user.conf |cut -f 1 -d ':')
- if [ ! -z "$lnr" ]; then
- sed -i "$lnr d" $VESTA/data/users/$1/user.conf
- sed -i "$lnr i\\$key='${3}'" $VESTA/data/users/$1/user.conf
- fi
-}
-
-# Increase user counter
-increase_user_value() {
- key="${2//$}"
- factor="${3-1}"
- conf="$VESTA/data/users/$1/user.conf"
- old=$(grep "$key=" $conf | cut -f 2 -d \')
- if [ -z "$old" ]; then
- old=0
- fi
- new=$((old + factor))
- sed -i "s/$key='$old'/$key='$new'/g" $conf
-}
-
-# Decrease user counter
-decrease_user_value() {
- key="${2//$}"
- factor="${3-1}"
- conf="$VESTA/data/users/$1/user.conf"
- old=$(grep "$key=" $conf | cut -f 2 -d \')
- if [ -z "$old" ]; then
- old=0
- fi
- if [ "$old" -le 1 ]; then
- new=0
- else
- new=$((old - factor))
- fi
- sed -i "s/$key='$old'/$key='$new'/g" $conf
-}
-
-# Json listing function
-json_list() {
- echo '{'
- fileds_count=$(echo $fields| wc -w )
- #for line in $(cat $conf); do
- while read line; do
- eval $line
- if [ -n "$data_output" ]; then
- echo -e ' },'
- fi
- i=1
- for field in $fields; do
- eval value=$field
- if [ $i -eq 1 ]; then
- (( ++i))
- echo -e "\t\"$value\": {"
- else
- if [ $i -lt $fileds_count ]; then
- (( ++i))
- echo -e "\t\t\"${field//$/}\": \"$value\","
- else
- echo -e "\t\t\"${field//$/}\": \"$value\""
- data_output=yes
- fi
- fi
- done
- done < $conf
-
- if [ "$data_output" = 'yes' ]; then
- echo -e ' }'
- fi
- echo -e '}'
-}
-
-# Shell listing function
-shell_list() {
- if [ -z "$nohead" ] ; then
- echo "${fields//$/}"
- for a in $fields; do
- echo -e "------ \c"
- done
- echo
- fi
- while read line ; do
- eval $line
- for field in $fields; do
- eval value=$field
- if [ -z "$value" ]; then
- value='NULL'
- fi
- echo -n "$value "
- done
- echo
- done < $conf
-}
-
-# Recalculate U_DISK value
-recalc_user_disk_usage() {
- u_usage=0
- if [ -f "$USER_DATA/web.conf" ]; then
- usage=0
- dusage=$(grep 'U_DISK=' $USER_DATA/web.conf |\
- awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
- for disk_usage in $dusage; do
- usage=$((usage + disk_usage))
- done
- d=$(grep "U_DISK_WEB='" $USER_DATA/user.conf | cut -f 2 -d \')
- sed -i "s/U_DISK_WEB='$d'/U_DISK_WEB='$usage'/g" $USER_DATA/user.conf
- u_usage=$((u_usage + usage))
- fi
-
- if [ -f "$USER_DATA/mail.conf" ]; then
- usage=0
- dusage=$(grep 'U_DISK=' $USER_DATA/mail.conf |\
- awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
- for disk_usage in $dusage; do
- usage=$((usage + disk_usage))
- done
- d=$(grep "U_DISK_MAIL='" $USER_DATA/user.conf | cut -f 2 -d \')
- sed -i "s/U_DISK_MAIL='$d'/U_DISK_MAIL='$usage'/g" $USER_DATA/user.conf
- u_usage=$((u_usage + usage))
- fi
-
- if [ -f "$USER_DATA/db.conf" ]; then
- usage=0
- dusage=$(grep 'U_DISK=' $USER_DATA/db.conf |\
- awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
- for disk_usage in $dusage; do
- usage=$((usage + disk_usage))
- done
- d=$(grep "U_DISK_DB='" $USER_DATA/user.conf | cut -f 2 -d \')
- sed -i "s/U_DISK_DB='$d'/U_DISK_DB='$usage'/g" $USER_DATA/user.conf
- u_usage=$((u_usage + usage))
- fi
- usage=$(grep 'U_DIR_DISK=' $USER_DATA/user.conf | cut -f 2 -d "'")
- u_usage=$((u_usage + usage))
- old=$(grep "U_DISK='" $USER_DATA/user.conf | cut -f 2 -d \')
- sed -i "s/U_DISK='$old'/U_DISK='$u_usage'/g" $USER_DATA/user.conf
-}
-
-# Recalculate U_BANDWIDTH value
-recalc_user_bandwidth_usage() {
- usage=0
- bandwidth_usage=$(grep 'U_BANDWIDTH=' $USER_DATA/web.conf |\
- awk -F "U_BANDWIDTH='" '{print $2}'|cut -f 1 -d \')
- for bandwidth in $bandwidth_usage; do
- usage=$((usage + bandwidth))
- done
- old=$(grep "U_BANDWIDTH='" $USER_DATA/user.conf | cut -f 2 -d \')
- sed -i "s/U_BANDWIDTH='$old'/U_BANDWIDTH='$usage'/g" $USER_DATA/user.conf
-}
-
-# Get next cron job id
-get_next_cronjob() {
- if [ -z "$job" ]; then
- curr_str=$(grep "JOB=" $USER_DATA/cron.conf|cut -f 2 -d \'|\
- sort -n|tail -n1)
- job="$((curr_str +1))"
- fi
-}
-
-# Sort cron jobs by id
-sort_cron_jobs() {
- cat $USER_DATA/cron.conf |sort -n -k 2 -t \' > $USER_DATA/cron.tmp
- mv -f $USER_DATA/cron.tmp $USER_DATA/cron.conf
-}
-
-# Sync cronjobs with system cron
-sync_cron_jobs() {
- source $USER_DATA/user.conf
- rm -f /var/spool/cron/$user
- if [ "$CRON_REPORTS" = 'yes' ]; then
- echo "MAILTO=$CONTACT" > /var/spool/cron/$user
- fi
- while read line; do
- eval $line
- if [ "$SUSPENDED" = 'no' ]; then
- echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\
- sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" \
- >> /var/spool/cron/$user
- fi
- done < $USER_DATA/cron.conf
-}
-
-
-### Format Validators ###
-# Shell
-validate_format_shell() {
- if [ -z "$(grep -w $1 /etc/shells)" ]; then
- echo "Error: shell $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Password
-validate_format_password() {
- if [ "${#1}" -lt '6' ]; then
- echo "Error: password is too short"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Integer
-validate_format_int() {
- if ! [[ "$1" =~ ^[0-9]+$ ]] ; then
- echo "Error: int $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Boolean
-validate_format_boolean() {
- if [ "$1" != 'yes' ] && [ "$1" != 'no' ]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Network interface
-validate_format_interface() {
- netdevices=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ')
- if [ -z $(echo "$netdevices"| grep -x $1) ]; then
- echo "Error: intreface $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# IP address
-validate_format_ip() {
- valid_octets=0
- for octet in ${1//./ }; do
- if [[ $octet =~ ^[0-9]{1,3}$ ]] && [[ $octet -le 255 ]]; then
- ((++valid_octets))
- fi
- done
- if [ "$valid_octets" -lt 4 ]; then
- echo "Error: ip $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# IP address status
-validate_format_ip_status() {
- if [ -z "$(echo shared,dedicated | grep -w $1 )" ]; then
- echo "Error: ip_status $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Email address
-validate_format_email() {
- local_part=$(echo $1 | cut -s -f1 -d\@)
- remote_host=$(echo $1 | cut -s -f2 -d\@)
- mx_failed=1
- if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then
- /usr/bin/host -t mx "$remote_host" &> /dev/null
- mx_failed="$?"
- fi
- if [ "$mx_failed" -eq 1 ]; then
- echo "Error: email $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Username
-validate_format_username() {
- if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_][a-zA-Z0-9]+)?$ ]]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
- if [[ "${#1}" -gt 28 ]]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Domain
-validate_format_domain() {
- exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
- if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then
- echo "Error: domain $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Domain alias
-validate_format_domain_alias() {
- exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
- if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then
- echo "Error: domain alias $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Database
-validate_format_database() {
- exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%|\`| ]"
- if [[ "$1" =~ $exclude ]] || [ 17 -le ${#1} ]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# DNS type
-validate_format_dns_type() {
- known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF'
- if [ -z "$(echo $known_dnstype | grep -w $1)" ]; then
- echo "Error: dnstype $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# DKIM key size
-validate_format_key_size() {
- known_size='128,256,512,768,1024,2048'
- if [ -z "$(echo $known_size | grep -w $1)" ]; then
- echo "Error: key_size $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Minute / Hour / Day / Month / Day of Week
-validate_format_mhdmw() {
- limit=60
- check_format=''
- if [ "$2" = 'day' ]; then
- limit=31
- fi
- if [ "$2" = 'month' ]; then
- limit=12
- fi
- if [ "$2" = 'wday' ]; then
- limit=7
- fi
- if [ "$1" = '*' ]; then
- check_format='ok'
- fi
- if [[ "$1" =~ ^[\*]+[/]+[0-9] ]]; then
- if [ "$(echo $1 |cut -f 2 -d /)" -lt $limit ]; then
- check_format='ok'
- fi
- fi
- if [[ "$1" =~ ^[0-9]+$ ]] && [ "$1" -lt $limit ]; then
- check_format='ok'
- fi
- if [ "$check_format" != 'ok' ]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Nginx static extention or DNS record
-validate_format_common() {
- exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%|\`| ]"
- if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then
- echo "Error: $2 $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# DNS record value
-validate_format_dvalue() {
- record_types="$(echo A,AAAA,NS,CNAME | grep -w "$rtype")"
- if [[ "$1" =~ [\ ] ]] && [ ! -z "$record_types" ]; then
- echo "Error: dvalue $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
- if [ "$rtype" = 'A' ]; then
- validate_format_ip "$1"
- fi
- if [ "$rtype" = 'NS' ]; then
- validate_format_domain "$1"
- fi
- if [ "$rtype" = 'MX' ]; then
- validate_format_domain "$1"
- validate_format_int "$priority"
- fi
-
-}
-
-# Date
-validate_format_date() {
- if ! [[ "$1" =~ ^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]]; then
- echo "Error: date $1 is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Autoreply
-validate_format_autoreply() {
- exclude="[$|\`]"
- if [[ "$1" =~ $exclude ]] || [ 10240 -le ${#1} ]; then
- echo "Error: autoreply is not valid"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-}
-
-# Format validation controller
-validate_format(){
- for arg_name in $*; do
- eval arg=\$$arg_name
- if [ -z "$arg" ]; then
- echo "Error: argument $arg_name is not valid (empty)"
- log_event "$E_INVALID" "$EVENT"
- exit $E_INVALID
- fi
-
- case $arg_name in
- account) validate_format_username "$arg" "$arg_name" ;;
- antispam) validate_format_boolean "$arg" 'antispam' ;;
- antivirus) validate_format_boolean "$arg" 'antivirus' ;;
- autoreply) validate_format_autoreply "$arg" ;;
- backup) validate_format_date "$arg" ;;
- charset) validate_format_username "$arg" "$arg_name" ;;
- charsets) validate_format_common "$arg" 'charsets' ;;
- database) validate_format_database "$arg" 'database';;
- day) validate_format_mhdmw "$arg" $arg_name ;;
- dbpass) validate_format_password "$arg" ;;
- dbuser) validate_format_database "$arg" 'db_user';;
- dkim) validate_format_boolean "$arg" 'dkim' ;;
- dkim_size) validate_format_key_size "$arg" ;;
- domain) validate_format_domain "$arg" ;;
- dom_alias) validate_format_domain_alias "$arg" ;;
- dvalue) validate_format_dvalue "$arg";;
- email) validate_format_email "$arg" ;;
- exp) validate_format_date "$arg" ;;
- extentions) validate_format_common "$arg" 'extentions' ;;
- fname) validate_format_username "$arg" "$arg_name" ;;
- forward) validate_format_email "$arg" ;;
- ftp_password) validate_format_password "$arg" ;;
- ftp_user) validate_format_username "$arg" "$arg_name" ;;
- host) validate_format_domain "$arg" "$arg_name" ;;
- hour) validate_format_mhdmw "$arg" $arg_name ;;
- id) validate_format_int "$arg" ;;
- interface) validate_format_interface "$arg" ;;
- ip) validate_format_ip "$arg" ;;
- ip_name) validate_format_domain "$arg" ;;
- ip_status) validate_format_ip_status "$arg" ;;
- job) validate_format_int "$arg" ;;
- key) validate_format_username "$arg" "$arg_name" ;;
- lname) validate_format_username "$arg" "$arg_name" ;;
- malias) validate_format_username "$arg" "$arg_name" ;;
- mask) validate_format_ip "$arg" ;;
- max_db) validate_format_int "$arg" ;;
- min) validate_format_mhdmw "$arg" $arg_name ;;
- month) validate_format_mhdmw "$arg" $arg_name ;;
- ns1) validate_format_domain "$arg" ;;
- ns2) validate_format_domain "$arg" ;;
- ns3) validate_format_domain "$arg" ;;
- ns4) validate_format_domain "$arg" ;;
- package) validate_format_username "$arg" "$arg_name" ;;
- password) validate_format_password "$arg" ;;
- port) validate_format_int "$arg" ;;
- quota) validate_format_int "$arg" ;;
- restart) validate_format_boolean "$arg" 'restart' ;;
- record) validate_format_common "$arg" 'record';;
- rtype) validate_format_dns_type "$arg" ;;
- shell) validate_format_shell "$arg" ;;
- soa) validate_format_domain "$arg" ;;
- stats_pass) validate_format_password "$arg" ;;
- stats_user) validate_format_username "$arg" "$arg_name" ;;
- template) validate_format_username "$arg" "$arg_name" ;;
- ttl) validate_format_int "$arg" ;;
- user) validate_format_username "$arg" "$arg_name" ;;
- wday) validate_format_mhdmw "$arg" $arg_name ;;
- esac
- done
-}
+# Internal variables
+DATE=$(date +%F)
+TIME=$(date +%T)
+SCRIPT=$(basename $0)
+A1=$1
+A2=$2
+A3=$3
+A4=$4
+A5=$5
+A6=$6
+A7=$7
+A8=$8
+A9=$9
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
+HOMEDIR='/home'
+BACKUP='/backup'
+BACKUP_GZIP=5
+BACKUP_DISK_LIMIT=95
+BACKUP_LA_LIMIT=5
+RRD_STEP=300
+RRD_IFACE_EXCLUDE=lo
+
+BIN=$VESTA/bin
+USER_DATA=$VESTA/data/users/$user
+WEBTPL=$VESTA/data/templates/web
+DNSTPL=$VESTA/data/templates/dns
+RRD=$VESTA/web/rrd
+
+# Return codes
+OK=0
+E_ARGS=1
+E_INVALID=2
+E_NOTEXIST=3
+E_EXISTS=4
+E_SUSPENDED=5
+E_UNSUSPENDED=6
+E_INUSE=7
+E_LIMIT=8
+E_PASSWORD=9
+E_FORBIDEN=10
+E_DISABLED=11
+E_PARSING=12
+E_DISK=13
+E_LA=14
+E_FTP=15
+E_SSH=16
+E_DB=17
+E_RRD=18
+E_UPDATE=19
+E_RESTART=20
+
+# Log event function
+log_event() {
+ echo "RC='$1' $2" >> $VESTA/log/system.log
+}
+
+# Log user history
+log_history() {
+ cmd=$1
+ undo=${2-no}
+ log_user=${3-$user}
+ log=$VESTA/data/users/$log_user/history.log
+
+ touch $log
+ if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then
+ tail -n 99 $log > $log.moved
+ mv -f $log.moved $log
+ chmod 660 $log
+ fi
+
+ curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1)
+ id="$((curr_str +1))"
+ echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log
+}
+
+# Argument list checker
+check_args() {
+ if [ "$1" -gt "$2" ]; then
+ echo "Error: not enought arguments"
+ echo "Usage: $SCRIPT $3"
+ log_event "$E_ARGS" "$EVENT"
+ exit $E_ARGS
+ fi
+}
+
+# Subsystem checker
+is_system_enabled() {
+ if [ -z "$1" ] || [ "$1" = no ]; then
+ echo "Error: subsystem disabled"
+ log_event "$E_DISABLED" "$EVENT"
+ exit $E_DISABLED
+ fi
+}
+
+# User package check
+is_package_full() {
+ case "$1" in
+ WEB_DOMAINS) used=$(wc -l $USER_DATA/web.conf|cut -f1 -d \ );;
+ WEB_ALIASES) used=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |\
+ awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\
+ wc -l );;
+ DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );;
+ DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain.conf |cut -f1 -d \ );;
+ MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );;
+ MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.conf |\
+ cut -f1 -d \ );;
+ DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );;
+ CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );;
+ esac
+ limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
+ if [ "$used" -ge "$limit" ]; then
+ echo "Error: Limit reached / Upgrade package"
+ log_event "$E_LIMIT" "$EVENT"
+ exit $E_LIMIT
+ fi
+}
+
+# Random password generator
+gen_password() {
+ matrix='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
+ lenght=10
+ while [ ${n:=1} -le $lenght ]; do
+ pass="$pass${matrix:$(($RANDOM%${#matrix})):1}"
+ let n+=1
+ done
+ echo "$pass"
+}
+
+# Package existance check
+is_package_valid() {
+ if [ -z "$1" ]; then
+ pkg_dir="$VESTA/data/packages"
+ fi
+ if [ ! -e "$pkg_dir/$package.pkg" ]; then
+ echo "Error: package $package not exist"
+ log_event "$E_NOTEXIST $EVENT"
+ exit $E_NOTEXIST
+ fi
+}
+
+# Validate system type
+is_type_valid() {
+ if [ -z "$(echo $1 | grep -w $2)" ]; then
+ echo "Error: $2 is unknown type"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Check user backup settings
+is_backup_enabled() {
+ BACKUPS=$(grep "^BACKUPS=" $USER_DATA/user.conf | cut -f2 -d \')
+ if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then
+ echo "Error: user backup disabled"
+ log_event "$E_DISABLED" "$EVENT"
+ exit $E_DISABLED
+ fi
+}
+
+# Check if object is free and can be created
+is_object_free() {
+ if [ $2 = 'USER' ]; then
+ if [ -d "$USER_DATA" ]; then
+ object="OK"
+ fi
+ else
+ object=$(grep "$2='$3'" $USER_DATA/$1.conf)
+ fi
+ if [ ! -z "$object" ]; then
+ echo "Error: $2 with value $3 exists"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+}
+
+# Check if object exists and can be used
+is_object_valid() {
+ if [ $2 = 'USER' ]; then
+ if [ -d "$VESTA/data/users/$user" ]; then
+ sobject="OK"
+ fi
+ else
+ if [ $2 = 'DBHOST' ]; then
+ sobject=$(grep "HOST='$host'" $VESTA/conf/$type.conf)
+ else
+ sobject=$(grep "$2='$3'" $VESTA/data/users/$user/$1.conf)
+ fi
+ fi
+ if [ -z "$sobject" ]; then
+ echo "Error: $3 not exist"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+}
+
+# Check if object is supended
+is_object_suspended() {
+ if [ $2 = 'USER' ]; then
+ spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
+ else
+ spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
+ fi
+ if [ -z "$spnd" ]; then
+ echo "Error: $1 $3 is not suspended"
+ log_event "$E_SUSPENDED" "$EVENT"
+ exit $E_SUSPENDED
+ fi
+}
+
+# Check if object is unsupended
+is_object_unsuspended() {
+ if [ $2 = 'USER' ]; then
+ spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
+ else
+ spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
+ fi
+ if [ ! -z "$spnd" ]; then
+ echo "Error: $1 $3 is already suspended"
+ log_event "$E_UNSUSPENDED" "$EVENT"
+ exit $E_UNSUSPENDED
+ fi
+}
+
+# Check if object value is empty
+is_object_value_empty() {
+ str=$(grep "$2='$3'" $USER_DATA/$1.conf)
+ eval $str
+ eval value=$4
+ if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
+ echo "Error: ${4//$}=$value (not empty)"
+ log_event "$E_EXISTS" "$EVENT"
+ exit $E_EXISTS
+ fi
+}
+
+# Check if object value is empty
+is_object_value_exist() {
+ str=$(grep "$2='$3'" $USER_DATA/$1.conf)
+ eval $str
+ eval value=$4
+ if [ -z "$value" ] || [ "$value" = 'no' ]; then
+ echo "Error: ${4//$}=$value (not exist)"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
+}
+
+# Get object value
+get_object_value() {
+ object=$(grep "$2='$3'" $USER_DATA/$1.conf)
+ eval "$object"
+ eval echo $4
+}
+
+# Update object value
+update_object_value() {
+ row=$(grep -n "$2='$3'" $USER_DATA/$1.conf)
+ lnr=$(echo $row | cut -f 1 -d ':')
+ object=$(echo $row | sed -e "s/^$lnr://")
+ eval "$object"
+ eval old="$4"
+ old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
+ new=$(echo "$5" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
+ sed -i "$lnr s/${4//$/}='${old//\*/\\*}'/${4//$/}='${new//\*/\\*}'/g" \
+ $USER_DATA/$1.conf
+}
+
+# Search objects
+search_objects() {
+ OLD_IFS="$IFS"
+ IFS=$'\n'
+ for line in $(grep $2=\'$3\' $USER_DATA/$1.conf); do
+ eval $line
+ eval echo \$$4
+ done
+ IFS="$OLD_IFS"
+}
+
+# Get user value
+get_user_value() {
+ grep "^${1//$/}=" $USER_DATA/user.conf| cut -f 2 -d \'
+}
+
+# Update user value in user.conf
+update_user_value() {
+ key="${2//$}"
+ lnr=$(grep -n "^$key='" $VESTA/data/users/$1/user.conf |cut -f 1 -d ':')
+ if [ ! -z "$lnr" ]; then
+ sed -i "$lnr d" $VESTA/data/users/$1/user.conf
+ sed -i "$lnr i\\$key='${3}'" $VESTA/data/users/$1/user.conf
+ fi
+}
+
+# Increase user counter
+increase_user_value() {
+ key="${2//$}"
+ factor="${3-1}"
+ conf="$VESTA/data/users/$1/user.conf"
+ old=$(grep "$key=" $conf | cut -f 2 -d \')
+ if [ -z "$old" ]; then
+ old=0
+ fi
+ new=$((old + factor))
+ sed -i "s/$key='$old'/$key='$new'/g" $conf
+}
+
+# Decrease user counter
+decrease_user_value() {
+ key="${2//$}"
+ factor="${3-1}"
+ conf="$VESTA/data/users/$1/user.conf"
+ old=$(grep "$key=" $conf | cut -f 2 -d \')
+ if [ -z "$old" ]; then
+ old=0
+ fi
+ if [ "$old" -le 1 ]; then
+ new=0
+ else
+ new=$((old - factor))
+ fi
+ sed -i "s/$key='$old'/$key='$new'/g" $conf
+}
+
+# Json listing function
+json_list() {
+ echo '{'
+ fileds_count=$(echo $fields| wc -w )
+ #for line in $(cat $conf); do
+ while read line; do
+ eval $line
+ if [ -n "$data_output" ]; then
+ echo -e ' },'
+ fi
+ i=1
+ for field in $fields; do
+ eval value=$field
+ if [ $i -eq 1 ]; then
+ (( ++i))
+ echo -e "\t\"$value\": {"
+ else
+ if [ $i -lt $fileds_count ]; then
+ (( ++i))
+ echo -e "\t\t\"${field//$/}\": \"$value\","
+ else
+ echo -e "\t\t\"${field//$/}\": \"$value\""
+ data_output=yes
+ fi
+ fi
+ done
+ done < $conf
+
+ if [ "$data_output" = 'yes' ]; then
+ echo -e ' }'
+ fi
+ echo -e '}'
+}
+
+# Shell listing function
+shell_list() {
+ if [ -z "$nohead" ] ; then
+ echo "${fields//$/}"
+ for a in $fields; do
+ echo -e "------ \c"
+ done
+ echo
+ fi
+ while read line ; do
+ eval $line
+ for field in $fields; do
+ eval value=$field
+ if [ -z "$value" ]; then
+ value='NULL'
+ fi
+ echo -n "$value "
+ done
+ echo
+ done < $conf
+}
+
+# Recalculate U_DISK value
+recalc_user_disk_usage() {
+ u_usage=0
+ if [ -f "$USER_DATA/web.conf" ]; then
+ usage=0
+ dusage=$(grep 'U_DISK=' $USER_DATA/web.conf |\
+ awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+ for disk_usage in $dusage; do
+ usage=$((usage + disk_usage))
+ done
+ d=$(grep "U_DISK_WEB='" $USER_DATA/user.conf | cut -f 2 -d \')
+ sed -i "s/U_DISK_WEB='$d'/U_DISK_WEB='$usage'/g" $USER_DATA/user.conf
+ u_usage=$((u_usage + usage))
+ fi
+
+ if [ -f "$USER_DATA/mail.conf" ]; then
+ usage=0
+ dusage=$(grep 'U_DISK=' $USER_DATA/mail.conf |\
+ awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+ for disk_usage in $dusage; do
+ usage=$((usage + disk_usage))
+ done
+ d=$(grep "U_DISK_MAIL='" $USER_DATA/user.conf | cut -f 2 -d \')
+ sed -i "s/U_DISK_MAIL='$d'/U_DISK_MAIL='$usage'/g" $USER_DATA/user.conf
+ u_usage=$((u_usage + usage))
+ fi
+
+ if [ -f "$USER_DATA/db.conf" ]; then
+ usage=0
+ dusage=$(grep 'U_DISK=' $USER_DATA/db.conf |\
+ awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+ for disk_usage in $dusage; do
+ usage=$((usage + disk_usage))
+ done
+ d=$(grep "U_DISK_DB='" $USER_DATA/user.conf | cut -f 2 -d \')
+ sed -i "s/U_DISK_DB='$d'/U_DISK_DB='$usage'/g" $USER_DATA/user.conf
+ u_usage=$((u_usage + usage))
+ fi
+ usage=$(grep 'U_DIR_DISK=' $USER_DATA/user.conf | cut -f 2 -d "'")
+ u_usage=$((u_usage + usage))
+ old=$(grep "U_DISK='" $USER_DATA/user.conf | cut -f 2 -d \')
+ sed -i "s/U_DISK='$old'/U_DISK='$u_usage'/g" $USER_DATA/user.conf
+}
+
+# Recalculate U_BANDWIDTH value
+recalc_user_bandwidth_usage() {
+ usage=0
+ bandwidth_usage=$(grep 'U_BANDWIDTH=' $USER_DATA/web.conf |\
+ awk -F "U_BANDWIDTH='" '{print $2}'|cut -f 1 -d \')
+ for bandwidth in $bandwidth_usage; do
+ usage=$((usage + bandwidth))
+ done
+ old=$(grep "U_BANDWIDTH='" $USER_DATA/user.conf | cut -f 2 -d \')
+ sed -i "s/U_BANDWIDTH='$old'/U_BANDWIDTH='$usage'/g" $USER_DATA/user.conf
+}
+
+# Get next cron job id
+get_next_cronjob() {
+ if [ -z "$job" ]; then
+ curr_str=$(grep "JOB=" $USER_DATA/cron.conf|cut -f 2 -d \'|\
+ sort -n|tail -n1)
+ job="$((curr_str +1))"
+ fi
+}
+
+# Sort cron jobs by id
+sort_cron_jobs() {
+ cat $USER_DATA/cron.conf |sort -n -k 2 -t \' > $USER_DATA/cron.tmp
+ mv -f $USER_DATA/cron.tmp $USER_DATA/cron.conf
+}
+
+# Sync cronjobs with system cron
+sync_cron_jobs() {
+ source $USER_DATA/user.conf
+ rm -f /var/spool/cron/$user
+ if [ "$CRON_REPORTS" = 'yes' ]; then
+ echo "MAILTO=$CONTACT" > /var/spool/cron/$user
+ fi
+ while read line; do
+ eval $line
+ if [ "$SUSPENDED" = 'no' ]; then
+ echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\
+ sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" \
+ >> /var/spool/cron/$user
+ fi
+ done < $USER_DATA/cron.conf
+}
+
+
+### Format Validators ###
+# Shell
+validate_format_shell() {
+ if [ -z "$(grep -w $1 /etc/shells)" ]; then
+ echo "Error: shell $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Password
+validate_format_password() {
+ if [ "${#1}" -lt '6' ]; then
+ echo "Error: password is too short"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Integer
+validate_format_int() {
+ if ! [[ "$1" =~ ^[0-9]+$ ]] ; then
+ echo "Error: int $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Boolean
+validate_format_boolean() {
+ if [ "$1" != 'yes' ] && [ "$1" != 'no' ]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Network interface
+validate_format_interface() {
+ netdevices=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ')
+ if [ -z $(echo "$netdevices"| grep -x $1) ]; then
+ echo "Error: intreface $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# IP address
+validate_format_ip() {
+ valid_octets=0
+ for octet in ${1//./ }; do
+ if [[ $octet =~ ^[0-9]{1,3}$ ]] && [[ $octet -le 255 ]]; then
+ ((++valid_octets))
+ fi
+ done
+ if [ "$valid_octets" -lt 4 ]; then
+ echo "Error: ip $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# IP address status
+validate_format_ip_status() {
+ if [ -z "$(echo shared,dedicated | grep -w $1 )" ]; then
+ echo "Error: ip_status $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Email address
+validate_format_email() {
+ local_part=$(echo $1 | cut -s -f1 -d\@)
+ remote_host=$(echo $1 | cut -s -f2 -d\@)
+ mx_failed=1
+ if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then
+ /usr/bin/host -t mx "$remote_host" &> /dev/null
+ mx_failed="$?"
+ fi
+ if [ "$mx_failed" -eq 1 ]; then
+ echo "Error: email $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Username
+validate_format_username() {
+ if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_|-][a-zA-Z0-9]+)?$ ]]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+ if [[ "${#1}" -gt 28 ]]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Domain
+validate_format_domain() {
+ exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
+ if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then
+ echo "Error: domain $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Domain alias
+validate_format_domain_alias() {
+ exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
+ if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then
+ echo "Error: domain alias $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Database
+validate_format_database() {
+ exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%|\`| ]"
+ if [[ "$1" =~ $exclude ]] || [ 17 -le ${#1} ]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# DNS type
+validate_format_dns_type() {
+ known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF'
+ if [ -z "$(echo $known_dnstype | grep -w $1)" ]; then
+ echo "Error: dnstype $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# DKIM key size
+validate_format_key_size() {
+ known_size='128,256,512,768,1024,2048'
+ if [ -z "$(echo $known_size | grep -w $1)" ]; then
+ echo "Error: key_size $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Minute / Hour / Day / Month / Day of Week
+validate_format_mhdmw() {
+ limit=60
+ check_format=''
+ if [ "$2" = 'day' ]; then
+ limit=31
+ fi
+ if [ "$2" = 'month' ]; then
+ limit=12
+ fi
+ if [ "$2" = 'wday' ]; then
+ limit=7
+ fi
+ if [ "$1" = '*' ]; then
+ check_format='ok'
+ fi
+ if [[ "$1" =~ ^[\*]+[/]+[0-9] ]]; then
+ if [ "$(echo $1 |cut -f 2 -d /)" -lt $limit ]; then
+ check_format='ok'
+ fi
+ fi
+ if [[ "$1" =~ ^[0-9]+$ ]] && [ "$1" -lt $limit ]; then
+ check_format='ok'
+ fi
+ if [ "$check_format" != 'ok' ]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Nginx static extention or DNS record
+validate_format_common() {
+ exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%|\`| ]"
+ if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then
+ echo "Error: $2 $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# DNS record value
+validate_format_dvalue() {
+ record_types="$(echo A,AAAA,NS,CNAME | grep -w "$rtype")"
+ if [[ "$1" =~ [\ ] ]] && [ ! -z "$record_types" ]; then
+ echo "Error: dvalue $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+ if [ "$rtype" = 'A' ]; then
+ validate_format_ip "$1"
+ fi
+ if [ "$rtype" = 'NS' ]; then
+ validate_format_domain "$1"
+ fi
+ if [ "$rtype" = 'MX' ]; then
+ validate_format_domain "$1"
+ validate_format_int "$priority"
+ fi
+
+}
+
+# Date
+validate_format_date() {
+ if ! [[ "$1" =~ ^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]]; then
+ echo "Error: date $1 is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Autoreply
+validate_format_autoreply() {
+ exclude="[$|\`]"
+ if [[ "$1" =~ $exclude ]] || [ 10240 -le ${#1} ]; then
+ echo "Error: autoreply is not valid"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+}
+
+# Format validation controller
+validate_format(){
+ for arg_name in $*; do
+ eval arg=\$$arg_name
+ if [ -z "$arg" ]; then
+ echo "Error: argument $arg_name is not valid (empty)"
+ log_event "$E_INVALID" "$EVENT"
+ exit $E_INVALID
+ fi
+
+ case $arg_name in
+ account) validate_format_username "$arg" "$arg_name" ;;
+ antispam) validate_format_boolean "$arg" 'antispam' ;;
+ antivirus) validate_format_boolean "$arg" 'antivirus' ;;
+ autoreply) validate_format_autoreply "$arg" ;;
+ backup) validate_format_date "$arg" ;;
+ charset) validate_format_username "$arg" "$arg_name" ;;
+ charsets) validate_format_common "$arg" 'charsets' ;;
+ database) validate_format_database "$arg" 'database';;
+ day) validate_format_mhdmw "$arg" $arg_name ;;
+ dbpass) validate_format_password "$arg" ;;
+ dbuser) validate_format_database "$arg" 'db_user';;
+ dkim) validate_format_boolean "$arg" 'dkim' ;;
+ dkim_size) validate_format_key_size "$arg" ;;
+ domain) validate_format_domain "$arg" ;;
+ dom_alias) validate_format_domain_alias "$arg" ;;
+ dvalue) validate_format_dvalue "$arg";;
+ email) validate_format_email "$arg" ;;
+ exp) validate_format_date "$arg" ;;
+ extentions) validate_format_common "$arg" 'extentions' ;;
+ fname) validate_format_username "$arg" "$arg_name" ;;
+ forward) validate_format_email "$arg" ;;
+ ftp_password) validate_format_password "$arg" ;;
+ ftp_user) validate_format_username "$arg" "$arg_name" ;;
+ host) validate_format_domain "$arg" "$arg_name" ;;
+ hour) validate_format_mhdmw "$arg" $arg_name ;;
+ id) validate_format_int "$arg" ;;
+ interface) validate_format_interface "$arg" ;;
+ ip) validate_format_ip "$arg" ;;
+ ip_name) validate_format_domain "$arg" ;;
+ ip_status) validate_format_ip_status "$arg" ;;
+ job) validate_format_int "$arg" ;;
+ key) validate_format_username "$arg" "$arg_name" ;;
+ lname) validate_format_username "$arg" "$arg_name" ;;
+ malias) validate_format_username "$arg" "$arg_name" ;;
+ mask) validate_format_ip "$arg" ;;
+ max_db) validate_format_int "$arg" ;;
+ min) validate_format_mhdmw "$arg" $arg_name ;;
+ month) validate_format_mhdmw "$arg" $arg_name ;;
+ ns1) validate_format_domain "$arg" ;;
+ ns2) validate_format_domain "$arg" ;;
+ ns3) validate_format_domain "$arg" ;;
+ ns4) validate_format_domain "$arg" ;;
+ package) validate_format_username "$arg" "$arg_name" ;;
+ password) validate_format_password "$arg" ;;
+ port) validate_format_int "$arg" ;;
+ quota) validate_format_int "$arg" ;;
+ restart) validate_format_boolean "$arg" 'restart' ;;
+ record) validate_format_common "$arg" 'record';;
+ rtype) validate_format_dns_type "$arg" ;;
+ shell) validate_format_shell "$arg" ;;
+ soa) validate_format_domain "$arg" ;;
+ stats_pass) validate_format_password "$arg" ;;
+ stats_user) validate_format_username "$arg" "$arg_name" ;;
+ template) validate_format_username "$arg" "$arg_name" ;;
+ ttl) validate_format_int "$arg" ;;
+ user) validate_format_username "$arg" "$arg_name" ;;
+ wday) validate_format_mhdmw "$arg" $arg_name ;;
+ esac
+ done
+}
diff --git a/install/0.9.7/rhel/exim.conf b/install/0.9.7/rhel/exim.conf
index a97cc249..b1790ac8 100644
--- a/install/0.9.7/rhel/exim.conf
+++ b/install/0.9.7/rhel/exim.conf
@@ -1,340 +1,340 @@
-##########################################################################
-SPAMASSASSIN = yes
-SPAM_SCORE = 10
-CLAMD = yes
-##########################################################################
-
-domainlist local_domains = dsearch;/etc/exim/domains/
-domainlist relay_to_domains = dsearch;/etc/exim/domains/
-hostlist relay_from_hosts = 127.0.0.1
-hostlist spammers = net-iplsearch;/etc/exim/spam-blocks.conf
-
-acl_smtp_connect = acl_check_spammers
-acl_smtp_mail = acl_check_mail
-acl_smtp_rcpt = acl_check_rcpt
-acl_smtp_data = acl_check_data
-acl_smtp_mime = acl_check_mime
-
-.ifdef SPAMASSASSIN
-spamd_address = 127.0.0.1 783
-.endif
-
-.ifdef CLAMD
-av_scanner = clamd: /var/run/clamav/clamd.sock
-.endif
-
-tls_advertise_hosts = *
-tls_certificate = /etc/pki/tls/certs/exim.pem
-tls_privatekey = /etc/pki/tls/private/exim.pem
-
-daemon_smtp_ports = 25 : 465 : 587 : 2525
-tls_on_connect_ports = 465
-never_users = root
-host_lookup = *
-rfc1413_hosts = *
-rfc1413_query_timeout = 5s
-ignore_bounce_errors_after = 2d
-timeout_frozen_after = 7d
-
-DKIM_DOMAIN = ${lc:${domain:$h_from:}}
-DKIM_FILE = /etc/exim/domains/${lc:${domain:$h_from:}}/dkim.pem
-DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}}
-
-
-##########################################################################
-begin acl
-##########################################################################
-acl_check_spammers:
- drop message = Your host in blacklist on this server.
- log_message = Host in blacklist
- hosts = +spammers
- deny message = rejected because $sender_host_address is in a black list at $dnslist_domain\\n$dnslist_text
- dnslists = ${readfile {/etc/exim/dnsbl.conf}{:}}
- accept
-
-acl_check_mail:
- deny
- condition = ${if eq{$sender_helo_name}{}}
- message = HELO required before MAIL
- drop
- condition = ${if isip{$sender_helo_name}}
- message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
- drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
- condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
- condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
- delay = 45s
-# drop
-# condition = ${if match{$sender_helo_name}{\N^\[\N}{no}{yes}}
-# condition = ${if match{$sender_helo_name}{\N\.\N}{no}{yes}}
-# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
- drop
- condition = ${if isip{$sender_helo_name}}
- message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
- drop
- condition = ${if match{$sender_helo_name}{\N\.$\N}}
- message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
- drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]"
- condition = ${if match{$sender_helo_name}{$primary_hostname}}
- drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
- message = $interface_address is _my_ address
- accept
-
-
-acl_check_rcpt:
- accept hosts = :
-
- deny message = Restricted characters in address
- domains = +local_domains
- local_parts = ^[.] : ^.*[@%!/|]
-
- deny message = Restricted characters in address
- domains = !+local_domains
- local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
-
- require verify = sender
-
- accept hosts = +relay_from_hosts
- control = submission
-
- accept local_parts = postmaster
- domains = +local_domains
-
- accept authenticated = *
- control = submission/domain=
-
- require message = relay not permitted
- domains = +local_domains : +relay_to_domains
-
- deny message = smtp auth requried
- sender_domains = +local_domains
- !authenticated = *
-
- require verify = recipient
-
-.ifdef CLAMD
- warn set acl_m0 = no
- warn condition = ${if exists {/etc/exim/domains/$domain/antivirus}{yes}{no}}
- set acl_m0 = yes
-.endif
-.ifdef SPAMASSASSIN
- warn set acl_m1 = no
- warn condition = ${if exists {/etc/exim/domains/$domain/antispam}{yes}{no}}
- set acl_m1 = yes
-.endif
- accept
-
-
-acl_check_data:
-.ifdef CLAMD
- deny message = Message contains a virus ($malware_name) and has been rejected
- malware = *
- condition = ${if eq{$acl_m0}{yes}{yes}{no}}
-.endif
-
-.ifdef SPAMASSASSIN
- warn
- !authenticated = *
- hosts = !+relay_from_hosts
- condition = ${if < {$message_size}{100K}}
- condition = ${if eq{$acl_m1}{yes}{yes}{no}}
- spam = nobody:true/defer_ok
- add_header = X-Spam-Score: $spam_score_int
- add_header = X-Spam-Bar: $spam_bar
- add_header = X-Spam-Report: $spam_report
- set acl_m2 = $spam_score_int
- warn
- condition = ${if !eq{$acl_m2}{} {yes}{no}}
- condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}}
- add_header = X-Spam-Status: Yes
- message = SpamAssassin detected spam (from $sender_address to $recipients).
-.endif
- accept
-
-
-acl_check_mime:
- deny message = Blacklisted file extension detected
- condition = ${if match {${lc:$mime_filename}}{\N(\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh)$\N}{1}{0}}
- accept
-
-##########################################################################
-begin authenticators
-##########################################################################
-dovecot_plain:
- driver = dovecot
- public_name = PLAIN
- server_socket = /var/run/dovecot/auth-client
- server_set_id = $auth1
-
-dovecot_login:
- driver = dovecot
- public_name = LOGIN
- server_socket = /var/run/dovecot/auth-client
- server_set_id = $auth1
-
-##########################################################################
-begin routers
-##########################################################################
-dnslookup:
- driver = dnslookup
- domains = !+local_domains
- transport = remote_smtp
-# ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
- no_more
-
-#system_aliases:
-# domains = +local_domains
-# driver = redirect
-# allow_fail
-# allow_defer
-# data = ${lookup{$local_part}lsearch{/etc/aliases}}
-# file_transport = address_file
-# pipe_transport = address_pipe
-
-userforward:
- driver = redirect
- check_local_user
- file = $home/.forward
- allow_filter
- no_verify
- no_expn
- check_ancestor
- file_transport = address_file
- pipe_transport = address_pipe
- reply_transport = address_reply
-
-procmail:
- driver = accept
- check_local_user
- require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
- transport = procmail
- no_verify
-
-autoreplay:
- driver = accept
- require_files = /etc/exim/domains/$domain/autoreply.${local_part}.msg
- condition = ${if exists{/etc/exim/domains/$domain/autoreply.${local_part}.msg}}{yes}{no}}
- retry_use_local_part
- transport = userautoreply
- unseen
-
-aliases:
- driver = redirect
- headers_add = X-redirected: yes
- data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}}
- require_files = /etc/exim/domains/$domain/aliases
- redirect_router = dnslookup
- pipe_transport = address_pipe
- unseen
-
-
-localuser_spam:
- driver = accept
- transport = local_spam_delivery
- condition = ${if eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} {${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{yes}{no_such_user}}}}
-
-localuser:
- driver = accept
- transport = local_delivery
- condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}}
-
-catchall:
- driver = redirect
- headers_add = X-redirected: yes
- require_files = /etc/exim/domains/$domain/aliases
- data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}}
- file_transport = local_delivery
- redirect_router = dnslookup
-
-terminate_alias:
- driver = accept
- transport = devnull
- condition = ${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}{true}{false}}
-
-
-##########################################################################
-begin transports
-##########################################################################
-remote_smtp:
- driver = smtp
- helo_data = $sender_address_domain
- dkim_domain = DKIM_DOMAIN
- dkim_selector = mail
- dkim_private_key = DKIM_PRIVATE_KEY
- dkim_canon = relaxed
- dkim_strict = 0
-
-
-procmail:
- driver = pipe
- command = "/usr/bin/procmail -d $local_part"
- return_path_add
- delivery_date_add
- envelope_to_add
- user = $local_part
- initgroups
- return_output
-
-local_delivery:
- driver = appendfile
- maildir_format
- maildir_use_size_file
- user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
- group = mail
- create_directory
- directory_mode = 770
- mode = 660
- use_lockfile = no
- delivery_date_add
- envelope_to_add
- return_path_add
- directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part"
- quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M
- quota_warn_threshold = 75%
-
-local_spam_delivery:
- driver = appendfile
- maildir_format
- maildir_use_size_file
- user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
- group = mail
- create_directory
- directory_mode = 770
- mode = 660
- use_lockfile = no
- delivery_date_add
- envelope_to_add
- return_path_add
- directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part/.spam"
- quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M
- quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part"
- quota_warn_threshold = 75%
-
-address_pipe:
- driver = pipe
- return_output
-
-address_file:
- driver = appendfile
- delivery_date_add
- envelope_to_add
- return_path_add
-
-address_reply:
- driver = autoreply
-
-userautoreply:
- driver = autoreply
- file = /etc/exim/domains/$domain/autoreply.${local_part}.msg
- from = "${local_part}@${domain}"
- subject = "${if def:h_Subject: {Autoreply: ${quote:${escape:$h_Subject:}}} {Autoreply Message}}"
- to = "${sender_address}"
-
-devnull:
- driver = appendfile
- file = /dev/null
-
-##########################################################################
-begin retry
-* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
-##########################################################################
-begin rewrite
+##########################################################################
+SPAMASSASSIN = yes
+SPAM_SCORE = 10
+CLAMD = yes
+##########################################################################
+
+domainlist local_domains = dsearch;/etc/exim/domains/
+domainlist relay_to_domains = dsearch;/etc/exim/domains/
+hostlist relay_from_hosts = 127.0.0.1
+hostlist spammers = net-iplsearch;/etc/exim/spam-blocks.conf
+
+acl_smtp_connect = acl_check_spammers
+acl_smtp_mail = acl_check_mail
+acl_smtp_rcpt = acl_check_rcpt
+acl_smtp_data = acl_check_data
+acl_smtp_mime = acl_check_mime
+
+.ifdef SPAMASSASSIN
+spamd_address = 127.0.0.1 783
+.endif
+
+.ifdef CLAMD
+av_scanner = clamd: /var/run/clamav/clamd.sock
+.endif
+
+tls_advertise_hosts = *
+tls_certificate = /etc/pki/tls/certs/exim.pem
+tls_privatekey = /etc/pki/tls/private/exim.pem
+
+daemon_smtp_ports = 25 : 465 : 587 : 2525
+tls_on_connect_ports = 465
+never_users = root
+host_lookup = *
+rfc1413_hosts = *
+rfc1413_query_timeout = 5s
+ignore_bounce_errors_after = 2d
+timeout_frozen_after = 7d
+
+DKIM_DOMAIN = ${lc:${domain:$h_from:}}
+DKIM_FILE = /etc/exim/domains/${lc:${domain:$h_from:}}/dkim.pem
+DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}}
+
+
+##########################################################################
+begin acl
+##########################################################################
+acl_check_spammers:
+ drop message = Your host in blacklist on this server.
+ log_message = Host in blacklist
+ hosts = +spammers
+ deny message = rejected because $sender_host_address is in a black list at $dnslist_domain\\n$dnslist_text
+ dnslists = ${readfile {/etc/exim/dnsbl.conf}{:}}
+ accept
+
+acl_check_mail:
+ deny
+ condition = ${if eq{$sender_helo_name}{}}
+ message = HELO required before MAIL
+# drop
+# condition = ${if isip{$sender_helo_name}}
+# message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
+ drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
+ condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
+ condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
+ delay = 45s
+# drop
+# condition = ${if match{$sender_helo_name}{\N^\[\N}{no}{yes}}
+# condition = ${if match{$sender_helo_name}{\N\.\N}{no}{yes}}
+# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
+ drop
+ condition = ${if isip{$sender_helo_name}}
+ message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
+# drop
+# condition = ${if match{$sender_helo_name}{\N\.$\N}}
+# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
+# drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]"
+# condition = ${if match{$sender_helo_name}{$primary_hostname}}
+ drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
+ message = $interface_address is _my_ address
+ accept
+
+
+acl_check_rcpt:
+ accept hosts = :
+
+ deny message = Restricted characters in address
+ domains = +local_domains
+ local_parts = ^[.] : ^.*[@%!/|]
+
+ deny message = Restricted characters in address
+ domains = !+local_domains
+ local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
+
+ require verify = sender
+
+ accept hosts = +relay_from_hosts
+ control = submission
+
+ accept local_parts = postmaster
+ domains = +local_domains
+
+ accept authenticated = *
+ control = submission/domain=
+
+ require message = relay not permitted
+ domains = +local_domains : +relay_to_domains
+
+ deny message = smtp auth requried
+ sender_domains = +local_domains
+ !authenticated = *
+
+ require verify = recipient
+
+.ifdef CLAMD
+ warn set acl_m0 = no
+ warn condition = ${if exists {/etc/exim/domains/$domain/antivirus}{yes}{no}}
+ set acl_m0 = yes
+.endif
+.ifdef SPAMASSASSIN
+ warn set acl_m1 = no
+ warn condition = ${if exists {/etc/exim/domains/$domain/antispam}{yes}{no}}
+ set acl_m1 = yes
+.endif
+ accept
+
+
+acl_check_data:
+.ifdef CLAMD
+ deny message = Message contains a virus ($malware_name) and has been rejected
+ malware = *
+ condition = ${if eq{$acl_m0}{yes}{yes}{no}}
+.endif
+
+.ifdef SPAMASSASSIN
+ warn
+ !authenticated = *
+ hosts = !+relay_from_hosts
+ condition = ${if < {$message_size}{100K}}
+ condition = ${if eq{$acl_m1}{yes}{yes}{no}}
+ spam = nobody:true/defer_ok
+ add_header = X-Spam-Score: $spam_score_int
+ add_header = X-Spam-Bar: $spam_bar
+ add_header = X-Spam-Report: $spam_report
+ set acl_m2 = $spam_score_int
+ warn
+ condition = ${if !eq{$acl_m2}{} {yes}{no}}
+ condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}}
+ add_header = X-Spam-Status: Yes
+ message = SpamAssassin detected spam (from $sender_address to $recipients).
+.endif
+ accept
+
+
+acl_check_mime:
+ deny message = Blacklisted file extension detected
+ condition = ${if match {${lc:$mime_filename}}{\N(\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh)$\N}{1}{0}}
+ accept
+
+##########################################################################
+begin authenticators
+##########################################################################
+dovecot_plain:
+ driver = dovecot
+ public_name = PLAIN
+ server_socket = /var/run/dovecot/auth-client
+ server_set_id = $auth1
+
+dovecot_login:
+ driver = dovecot
+ public_name = LOGIN
+ server_socket = /var/run/dovecot/auth-client
+ server_set_id = $auth1
+
+##########################################################################
+begin routers
+##########################################################################
+dnslookup:
+ driver = dnslookup
+ domains = !+local_domains
+ transport = remote_smtp
+# ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
+ no_more
+
+#system_aliases:
+# domains = +local_domains
+# driver = redirect
+# allow_fail
+# allow_defer
+# data = ${lookup{$local_part}lsearch{/etc/aliases}}
+# file_transport = address_file
+# pipe_transport = address_pipe
+
+userforward:
+ driver = redirect
+ check_local_user
+ file = $home/.forward
+ allow_filter
+ no_verify
+ no_expn
+ check_ancestor
+ file_transport = address_file
+ pipe_transport = address_pipe
+ reply_transport = address_reply
+
+procmail:
+ driver = accept
+ check_local_user
+ require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
+ transport = procmail
+ no_verify
+
+autoreplay:
+ driver = accept
+ require_files = /etc/exim/domains/$domain/autoreply.${local_part}.msg
+ condition = ${if exists{/etc/exim/domains/$domain/autoreply.${local_part}.msg}}{yes}{no}}
+ retry_use_local_part
+ transport = userautoreply
+ unseen
+
+aliases:
+ driver = redirect
+ headers_add = X-redirected: yes
+ data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}}
+ require_files = /etc/exim/domains/$domain/aliases
+ redirect_router = dnslookup
+ pipe_transport = address_pipe
+ unseen
+
+
+localuser_spam:
+ driver = accept
+ transport = local_spam_delivery
+ condition = ${if eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} {${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{yes}{no_such_user}}}}
+
+localuser:
+ driver = accept
+ transport = local_delivery
+ condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}}
+
+catchall:
+ driver = redirect
+ headers_add = X-redirected: yes
+ require_files = /etc/exim/domains/$domain/aliases
+ data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}}
+ file_transport = local_delivery
+ redirect_router = dnslookup
+
+terminate_alias:
+ driver = accept
+ transport = devnull
+ condition = ${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}{true}{false}}
+
+
+##########################################################################
+begin transports
+##########################################################################
+remote_smtp:
+ driver = smtp
+ helo_data = $sender_address_domain
+ dkim_domain = DKIM_DOMAIN
+ dkim_selector = mail
+ dkim_private_key = DKIM_PRIVATE_KEY
+ dkim_canon = relaxed
+ dkim_strict = 0
+
+
+procmail:
+ driver = pipe
+ command = "/usr/bin/procmail -d $local_part"
+ return_path_add
+ delivery_date_add
+ envelope_to_add
+ user = $local_part
+ initgroups
+ return_output
+
+local_delivery:
+ driver = appendfile
+ maildir_format
+ maildir_use_size_file
+ user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
+ group = mail
+ create_directory
+ directory_mode = 770
+ mode = 660
+ use_lockfile = no
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+ directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part"
+ quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M
+ quota_warn_threshold = 75%
+
+local_spam_delivery:
+ driver = appendfile
+ maildir_format
+ maildir_use_size_file
+ user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
+ group = mail
+ create_directory
+ directory_mode = 770
+ mode = 660
+ use_lockfile = no
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+ directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part/.spam"
+ quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M
+ quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part"
+ quota_warn_threshold = 75%
+
+address_pipe:
+ driver = pipe
+ return_output
+
+address_file:
+ driver = appendfile
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+
+address_reply:
+ driver = autoreply
+
+userautoreply:
+ driver = autoreply
+ file = /etc/exim/domains/$domain/autoreply.${local_part}.msg
+ from = "${local_part}@${domain}"
+ subject = "${if def:h_Subject: {Autoreply: ${quote:${escape:$h_Subject:}}} {Autoreply Message}}"
+ to = "${sender_address}"
+
+devnull:
+ driver = appendfile
+ file = /dev/null
+
+##########################################################################
+begin retry
+* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
+##########################################################################
+begin rewrite
diff --git a/install/0.9.7/rhel/roundcube-driver.php b/install/0.9.7/rhel/roundcube-driver.php
index f4757441..9454a9e0 100644
--- a/install/0.9.7/rhel/roundcube-driver.php
+++ b/install/0.9.7/rhel/roundcube-driver.php
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
+ */
+
+class rcube_vesta_password
+{
+ function save($curpass, $passwd)
+ {
+ $rcmail = rcmail::get_instance();
+ $vesta_host = $rcmail->config->get('password_vesta_host');
+
+ if (empty($vesta_host))
+ {
+ $vesta_host = 'localhost';
+ }
+
+ $vesta_port = $rcmail->config->get('password_vesta_port');
+ if (empty($vesta_port))
+ {
+ $vesta_port = '8083';
+ }
+
+ $postvars = array(
+ 'email' => $_SESSION['username'],
+ 'password' => $curpass,
+ 'new' => $passwd
+ );
+
+ $postdata = http_build_query($postvars);
+
+ $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL;
+ $send .= 'Host: ' . $vesta_host . PHP_EOL;
+ $send .= 'User-Agent: PHP Script' . PHP_EOL;
+ $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL;
+ $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL;
+ $send .= 'Connection: close' . PHP_EOL;
+ $send .= PHP_EOL;
+ $send .= $postdata . PHP_EOL . PHP_EOL;
+
+ $fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
+ fputs($fp, $send);
+ $result = fread($fp, 2048);
+ fclose($fp);
+
+
+ if(strpos($result, 'ok') && !strpos($html, 'error'))
+ {
+ return PASSWORD_SUCCESS;
+ }
+ else {
+ return PASSWORD_ERROR;
+ }
+
+ }
+}
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/install/vst-install.sh b/install/vst-install.sh
index 6816707b..825400a0 100644
--- a/install/vst-install.sh
+++ b/install/vst-install.sh
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
#!/bin/bash
# Vesta installer
@@ -636,3 +637,652 @@ cd
bash
# EOF
+=======
+#!/bin/bash
+# Vesta installer
+
+# Define Variables
+RHOST='r.vestacp.com'
+CHOST='c.vestacp.com'
+
+REPO='cmmnt'
+VERSION='0.9.7'
+YUM_REPO='/etc/yum.repos.d/vesta.repo'
+arch=$(uname -i)
+
+tools="screen mc libpng libjpeg curl libmcrypt mhash zip unzip freetype ntp
+ openssl flex libxml2 ImageMagick sqlite pcre sudo bc jwhois mailx lsof
+ tar telnet rsync"
+
+rpms="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid ftp
+ webalizer awstats mysql mysql-server php php-bcmath php-cli php-common
+ php-gd php-imap php-mbstring php-mcrypt php-mysql php-pdo php-soap php-tidy
+ php-xml php-xmlrpc phpMyAdmin exim dovecot clamd spamassassin roundcubemail
+ bind bind-utils bind-libs vsftpd rrdtool GeoIP vesta vesta-nginx vesta-php"
+
+# Am I root?
+if [ "x$(id -u)" != 'x0' ]; then
+ echo 'Error: this script can only be executed by root'
+ exit 1
+fi
+
+# Check supported version
+if [ ! -e '/etc/redhat-release' ]; then
+ echo 'Error: sorry, we currently support RHEL and CentOS only'
+ exit 1
+fi
+
+os=$(cut -f 1 -d ' ' /etc/redhat-release)
+if [ $os != 'CentOS' ] && [ $os != 'Red' ]; then
+ echo 'Error: sorry, we currently support RHEL and CentOS only'
+fi
+release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
+
+help() {
+ echo "usage: $0 [OPTIONS]
+ -d, --disable-remi Disable remi
+ -e, --email Define email address
+ -h, --help Print this help and exit
+ -f, --force Force installation"
+ exit 1
+}
+
+# Translating argument to --gnu-long-options
+for arg; do
+ delim=""
+ case "$arg" in
+ --help) args="${args}-h " ;;
+ --disable-remi) args="${args}-d " ;;
+ --force) args="${args}-f " ;;
+ --email) args="${args}-e " ;;
+ *) [[ "${arg:0:1}" == "-" ]] || delim="\""
+ args="${args}${delim}${arg}${delim} ";;
+ esac
+done
+eval set -- "$args"
+
+# Getopt
+while getopts "dhfe:" Option; do
+ case $Option in
+ d) disable_remi='yes' ;; # Disable remi repo
+ h) help ;; # Help
+ e) email=$OPTARG ;; # Contact email
+ f) force=yes ;; # Force install
+ *) help ;; # Default
+ esac
+done
+
+# Are you sure ?
+if [ -z $email ]; then
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo ' ***********************************************************'
+ echo
+ echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
+ echo ' _| _| _| _| _| _| _| '
+ echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
+ echo ' _| _| _| _| _| _| _| '
+ echo ' _| _|_|_|_| _|_|_| _| _| _| '
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo ' ***********************************************************'
+ echo
+ echo
+ read -n 1 -p 'Do you want to install Vesta Control Panel? [y/n]): ' answer
+ if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
+ echo 'Goodbye'
+ exit 1
+ fi
+ echo
+
+ # Check email
+ read -p 'Please enter valid email address: ' email
+fi
+
+# Validate email
+local_part=$(echo $email | cut -s -f1 -d\@)
+remote_host=$(echo $email | cut -s -f2 -d\@)
+mx_failed=1
+if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then
+ /usr/bin/host -t mx "$remote_host" &> /dev/null
+ mx_failed="$?"
+fi
+
+if [ "$mx_failed" -eq 1 ]; then
+ echo "Error: email $email is not valid"
+ exit 1
+fi
+
+echo
+echo
+echo
+echo
+echo 'Installation will take about 15 minutes ...'
+echo
+sleep 2
+
+# Check wget
+if [ ! -e '/usr/bin/wget' ]; then
+ yum -y install wget
+ if [ $? -ne 0 ]; then
+ echo "Error: can't install wget"
+ exit 1
+ fi
+fi
+
+# Check repo availability
+wget "$RHOST/$REPO/vesta.conf" -O /dev/null
+if [ $? -ne 0 ]; then
+ echo "Error: no access to $REPO repository"
+ exit 1
+fi
+
+# Check installed packages
+tmpfile=$(mktemp -p /tmp)
+rpm -qa > $tmpfile
+for rpm in $rpms; do
+ if [ ! -z "$(grep ^$rpm. $tmpfile)" ]; then
+ conflicts="$rpm $conflicts"
+ fi
+done
+rm -f $tmpfile
+
+if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
+ echo
+ echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
+ echo
+ echo 'Following rpm packages aleady installed:'
+ echo "$conflicts"
+ echo
+ echo 'It is highly recommended to remove them before proceeding.'
+ echo
+ echo 'If you want to force installation run this script with -f option:'
+ echo "Example: bash $0 --force"
+ echo
+ echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
+ echo
+ exit 1
+fi
+
+# Password generator
+gen_pass() {
+ MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
+ LENGTH=10
+ while [ ${n:=1} -le $LENGTH ]; do
+ PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
+ let n+=1
+ done
+ echo "$PASS"
+}
+
+# Update system
+yum -y update
+if [ $? -ne 0 ]; then
+ echo 'Error: yum update failed'
+ exit 1
+fi
+
+# Install additional packages
+yum -y install $tools
+if [ $? -ne 0 ]; then
+ echo 'Error: yum install failed'
+ exit 1
+fi
+
+# Install EPEL repo
+if [ ! -e '/etc/yum.repos.d/epel.repo' ]; then
+ if [ "$release" -eq '5' ]; then
+ epel="5/$arch/epel-release-5-4.noarch.rpm"
+ fi
+
+ if [ "$release" -eq '6' ]; then
+ epel="6/$arch/epel-release-6-8.noarch.rpm"
+ fi
+
+ rpm -ivh http://dl.fedoraproject.org/pub/epel/$epel
+ if [ $? -ne 0 ]; then
+ echo "Error: can't install EPEL repository"
+ exit 1
+ fi
+fi
+
+# Install remi repo
+if [ ! -e '/etc/yum.repos.d/remi.repo' ]; then
+ if [ "$release" -eq '5' ]; then
+ remi="remi-release-5.rpm"
+ fi
+
+ if [ "$release" -eq '6' ]; then
+ remi="remi-release-6.rpm"
+ fi
+
+ rpm -ivh http://rpms.famillecollet.com/enterprise/$remi
+ if [ $? -ne 0 ]; then
+ echo "Error: can't install remi repository"
+ exit 1
+ fi
+fi
+
+# Install vesta repo
+echo "[vesta]
+name=Vesta - $REPO
+baseurl=http://$RHOST/$REPO/$release/\$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA" > $YUM_REPO
+wget $CHOST/GPG.txt -O /etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA
+
+# Checking if old MySQL stuff exists
+if [ -e '/var/lib/mysql' ]; then
+ mv -f /var/lib/mysql /var/lib/mysql_old
+fi
+if [ -e '/etc/my.cnf' ]; then
+ mv -f /etc/my.cnf /etc/my.cnf_old
+fi
+if [ -e '/root/.my.cnf' ]; then
+ mv -f /root/.my.cnf
+fi
+
+# Install Vesta packages
+if [ -z "$disable_remi" ]; then
+ yum -y --enablerepo=remi install $rpms
+else
+ yum -y install $rpms
+fi
+if [ $? -ne 0 ]; then
+ echo 'Error: yum install failed'
+ exit 1
+fi
+
+# Configuring run levels
+chkconfig iptables off
+if [ -e /etc/init.d/sendmail ]; then
+ chkconfig sendmail off
+fi
+if [ -e /etc/init.d/postfix ]; then
+ chkconfig postfix off
+fi
+chkconfig vesta on
+chkconfig httpd on
+chkconfig nginx on
+chkconfig mysqld on
+chkconfig vsftpd on
+chkconfig named on
+chkconfig exim on
+chkconfig clamd on
+chkconfig spamassassin on
+chkconfig dovecot on
+
+# Make dirs more visible
+echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile
+
+# Vesta does not support SELINUX for now
+if [ -e '/etc/sysconfig/selinux' ]; then
+ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
+ setenforce 0
+fi
+if [ -e '/etc/selinux/config' ]; then
+ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
+ setenforce 0
+fi
+
+# Vesta use own webalizer routine
+rm -f /etc/cron.daily/00webalizer
+
+# NTP Synchronization
+echo '#!/bin/sh' > /etc/cron.daily/ntpdate
+echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate
+chmod 775 /etc/cron.daily/ntpdate
+ntpdate -s pool.ntp.org
+
+# Vesta Environment
+echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
+chmod 755 /etc/profile.d/vesta.sh
+source /etc/profile.d/vesta.sh
+echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
+echo 'export PATH' >> /root/.bash_profile
+source /root/.bash_profile
+mkdir -p $VESTA/conf
+mkdir -p $VESTA/log
+mkdir -p $VESTA/data
+mkdir -p $VESTA/ssl
+chmod 770 $VESTA/conf
+
+# Make backup directory
+vst_backups="/root/vst_install_backups/$(date +%s)"
+mkdir -p $vst_backups
+mkdir -p $vst_backups/nginx
+mkdir -p $vst_backups/httpd
+mkdir -p $vst_backups/mysql
+mkdir -p $vst_backups/exim
+mkdir -p $vst_backups/dovecot
+mkdir -p $vst_backups/clamd
+mkdir -p $vst_backups/vsftpd
+mkdir -p $vst_backups/named
+
+wget $RHOST/$REPO/vesta.conf -O $VESTA/conf/vesta.conf
+if [ -e '/etc/sudoers' ]; then
+ mv /etc/sudoers $vst_backups/
+fi
+wget $CHOST/$VERSION/sudoers.conf -O /etc/sudoers
+chmod 0440 /etc/sudoers
+wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
+
+sed -i "s/umask 022/umask 002/g" /etc/profile
+
+# Create backup directory
+adduser backup
+ln -s /home/backup /backup
+chmod a+x /backup
+
+# Configuring data templates
+cd /usr/local/vesta/data
+mkdir ips
+mkdir queue
+mkdir users
+touch queue/backup.pipe
+touch queue/disk.pipe
+touch queue/webstats.pipe
+touch queue/restart.pipe
+touch queue/traffic.pipe
+chmod 750 users
+chmod 750 ips
+chmod -R 750 queue
+wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
+tar -xzf packages.tar.gz
+rm -f packages.tar.gz
+cd /usr/local/vesta/data
+wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
+tar -xzf templates.tar.gz
+rm -f templates.tar.gz
+chmod -R 755 /usr/local/vesta/data/templates
+
+cp templates/web/skel/public_html/index.html /var/www/html/
+sed -i 's/%domain%/It worked!/g' /var/www/html/index.html
+
+# Configuring ssl keys
+cd /usr/local/vesta/ssl
+wget $CHOST/$VERSION/certificate.crt -O certificate.crt
+wget $CHOST/$VERSION/certificate.key -O certificate.key
+
+# Adding admin user
+vpass=$(gen_pass)
+$VESTA/bin/v-add-user admin $vpass $email default System Administrator
+if [ $? -ne 0 ]; then
+ echo "Error: can't create admin user"
+ exit 1
+fi
+
+# Set shell
+$VESTA/bin/v-change-user-shell admin bash
+
+# Apache
+if [ -e '/etc/httpd/conf/httpd.conf' ]; then
+ mv /etc/httpd/conf/httpd.conf $vst_backups/httpd/
+fi
+if [ -e '/etc/httpd/conf.d/ssl.conf' ]; then
+ mv /etc/httpd/conf.d/ssl.conf $vst_backups/httpd/
+fi
+if [ -e '/etc/httpd/conf.d/proxy_ajp.conf' ]; then
+ mv /etc/httpd/conf.d/proxy_ajp.conf $vst_backups/httpd/
+fi
+wget $CHOST/$VERSION/httpd.conf -O /etc/httpd/conf/httpd.conf
+wget $CHOST/$VERSION/httpd-status.conf -O /etc/httpd/conf.d/status.conf
+wget $CHOST/$VERSION/httpd-ssl.conf -O /etc/httpd/conf.d/ssl.conf
+wget $CHOST/$VERSION/httpd.log -O /etc/logrotate.d/httpd
+echo "MEFaccept 127.0.0.1" >> /etc/httpd/conf.d/mod_extract_forwarded.conf
+echo > /etc/httpd/conf.d/proxy_ajp.conf
+echo > /etc/httpd/conf.d/vesta.conf
+touch /var/log/httpd/access_log
+touch /var/log/httpd/error_log
+touch /var/log/httpd/suexec.log
+mkdir -p /var/log/httpd/domains
+chmod a+x /var/log/httpd
+chmod 640 /var/log/httpd/access_log
+chmod 640 /var/log/httpd/error_log
+chmod 640 /var/log/httpd/suexec.log
+chmod 751 /var/log/httpd/domains
+
+# Nginx
+if [ -e '/etc/nginx/nginx.conf' ]; then
+ mv /etc/nginx/nginx.conf $vst_backups/nginx/
+fi
+if [ -f '/etc/nginx/conf.d/default.conf' ]; then
+ mv /etc/nginx/conf.d/default.conf $vst_backups/nginx/
+fi
+if [ -e '/etc/nginx/conf.d/example_ssl.conf' ]; then
+ mv /etc/nginx/conf.d/example_ssl.conf $vst_backups/nginx/
+fi
+
+wget $CHOST/$VERSION/nginx.conf -O /etc/nginx/nginx.conf
+wget $CHOST/$VERSION/nginx-status.conf -O /etc/nginx/conf.d/status.conf
+touch /etc/nginx/conf.d/vesta_ip.conf
+touch /etc/nginx/conf.d/vesta_users.conf
+
+# VsFTP
+if [ -e '/etc/vsftpd/vsftpd.conf' ]; then
+ mv /etc/vsftpd/vsftpd.conf $vst_backups/vsftpd/
+fi
+wget $CHOST/$VERSION/vsftpd.conf -O /etc/vsftpd/vsftpd.conf
+
+# MySQL
+if [ -e '/etc/my.cnf' ]; then
+ mv /etc/my.cnf $vst_backups/mysql/
+fi
+
+if [ -e '/root/.my.cnf' ]; then
+ mv /root/.my.cnf $vst_backups/mysql/
+fi
+mpass=$(gen_pass)
+server_memory="$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])"
+if [ "$server_memory" -gt '1000000' ]; then
+ wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf
+else
+ wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf
+fi
+service mysqld start
+mysqladmin -u root password $mpass
+echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf
+$VESTA/bin/v-add-database-server mysql localhost 3306 root $mpass
+$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
+
+# Bind
+if [ -e '/etc/named.conf' ]; then
+ mv /etc/named.conf $vst_backups/named/
+fi
+wget $CHOST/$VERSION/named.conf -O /etc/named.conf
+chown root:named /etc/named.conf
+chmod 640 /etc/named.conf
+
+# Exim
+if [ -e '/etc/exim/exim.conf' ]; then
+ mv /etc/exim/exim.conf $vst_backups/exim/
+fi
+if [ -e '/etc/clamd.conf' ]; then
+ mv /etc/clamd.conf $vst_backups/clamd/
+fi
+wget $CHOST/$VERSION/exim.conf -O /etc/exim/exim.conf
+wget $CHOST/$VERSION/dnsbl.conf -O /etc/exim/dnsbl.conf
+wget $CHOST/$VERSION/spam-blocks.conf -O /etc/exim/spam-blocks.conf
+wget $CHOST/$VERSION/clamd.conf -O /etc/clamd.conf
+mkdir /etc/exim/domains
+chmod 640 /etc/exim/exim.conf
+gpasswd -a clam exim
+gpasswd -a exim mail
+gpasswd -a clam mail
+gpasswd -a dovecot mail
+/usr/bin/freshclam
+
+# Dovecot config
+if [ "$release" -eq '5' ]; then
+ if -e [ '/etc/dovecot.conf' ]; then
+ mv /etc/dovecot.conf $vst_backups/dovecot/
+ fi
+ wget $CHOST/$VERSION/dovecot.conf -O /etc/dovecot.conf
+
+else
+ if [ -e '/etc/dovecot' ]; then
+ mv /etc/dovecot/* $vst_backups/dovecot/
+ fi
+ wget $CHOST/$VERSION/dovecot.tar.gz -O /etc/dovecot.tar.gz
+ cd /etc/
+ tar -xzf dovecot.tar.gz
+ rm -f dovecot.tar.gz
+fi
+
+# PMA
+wget $CHOST/$VERSION/httpd-pma.conf -O /etc/httpd/conf.d/phpMyAdmin.conf
+wget $CHOST/$VERSION/pma.conf -O /etc/phpMyAdmin/config.inc.php
+sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php
+
+# Roundcube setup
+wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf
+wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php
+wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php
+wget $CHOST/$VERSION/roundcube-driver.php -O /usr/share/roundcubemail/plugins/password/vesta.php
+wget $CHOST/$VERSION/roundcube-pw.conf -O /usr/share/roundcubemail/plugins/password/config.inc.php
+
+r="$(gen_pass)"
+mysql -e "CREATE DATABASE roundcube"
+mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
+sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php
+mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql
+
+# Configuring ip
+$VESTA/bin/v-update-sys-ip
+
+# Get main ip
+main_ip=$(ifconfig |grep 'inet addr:' |grep -v 127.0.0.1 |head -n1 |\
+ cut -f2 -d: | cut -f1 -d ' ')
+
+# Add default web domain on main ip
+$VESTA/bin/v-add-web-domain admin default.domain $main_ip
+
+# Add default dns domain on main ip
+$VESTA/bin/v-add-dns-domain admin default.domain $main_ip
+
+# Add default mail domain
+$VESTA/bin/v-add-mail-domain admin default.domain
+
+# Configuring crond
+command='sudo /usr/local/vesta/bin/v-update-sys-queue disk'
+$VESTA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-update-sys-queue traffic'
+$VESTA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-update-sys-queue webstats'
+$VESTA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-update-sys-queue backup'
+$VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-backup-users'
+$VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-update-user-stats'
+$VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command"
+command='sudo /usr/local/vesta/bin/v-update-sys-rrd'
+$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
+
+# Creating symlink
+ln -s /usr/local/vesta/log /var/log/vesta
+
+# Stop unused services
+services='iptables sendmail postfix'
+for srv in $services; do
+ service $srv status > /dev/null
+ if [ $? -eq 0 ]; then
+ service $srv stop
+ fi
+done
+
+# Start system service
+services='vesta httpd nginx vsftpd exim dovecot clamd spamassassin named crond'
+for srv in $services; do
+ service $srv status > /dev/null
+ if [ $? -gt 0 ]; then
+ service $srv start
+ else
+ service $srv restart
+ fi
+done
+
+# Change sendmail client
+rm -f /etc/alternatives/mta
+ln -s /usr/sbin/sendmail.exim /etc/alternatives/mta
+
+# Build inititall rrd images
+$VESTA/bin/v-update-sys-rrd
+
+# Send notification to vestacp.com
+wget vestacp.com/notify/?$REPO -O /dev/null
+
+# Get server ip
+vst_ip=$(wget vestacp.com/what-is-my-ip/ -O - 2>/dev/null)
+if [ ! -z "$vst_ip" ] && [ "$vst_ip" != "$main_ip" ]; then
+ # Assign passive ip address
+ echo "pasv_address=$vst_ip" >> /etc/vsftpd/vsftpd.conf
+fi
+
+if [ -z "$vst_ip" ]; then
+ vst_ip=$main_ip
+fi
+
+# Send email
+echo -e "Congratulations, you have just successfully installed \
+the Vesta Control Panel
+
+You can login in Vesta with following credentials:
+ username: admin
+ password: $vpass
+ https://$vst_ip:8083
+
+We hope that you enjoy your installation of Vesta. Please \
+feel free to contact us anytime if you have any questions.
+Thank you.
+
+--
+Sincerely yours
+vestacp.com team
+" > $tmpfile
+
+cat $tmpfile | mail -s "Vesta Control Panel" $email
+rm -f $tmpfile
+
+# Congrats
+echo
+echo
+echo ' ***********************************************************'
+echo
+echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
+echo ' _| _| _| _| _| _| _| '
+echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
+echo ' _| _| _| _| _| _| _| '
+echo ' _| _|_|_|_| _|_|_| _| _| _| '
+echo
+echo ' Congratulations, you have just successfully installed'
+echo ' the Vesta Control Panel!'
+echo
+echo ' Now you can login in Vesta with following credentials:'
+echo ' username: admin'
+echo " password: $vpass"
+echo " https://$vst_ip:8083/"
+echo
+echo
+echo ' Thank you for using our product.'
+echo
+echo ' ***********************************************************'
+echo
+echo
+
+# Tricky way to get new PATH variable
+cd
+bash
+
+# EOF
+>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d
diff --git a/web/add/db/index.php b/web/add/db/index.php
index 46b61dd6..834b21c0 100644
--- a/web/add/db/index.php
+++ b/web/add/db/index.php
@@ -1,76 +1,93 @@
- $error) {
- if ( $i == 0 ) {
- $error_msg = $error;
- } else {
- $error_msg = $error_msg.", ".$error;
- }
- }
- $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg);
- } else {
- // Add Database
- $v_type = escapeshellarg($_POST['v_type']);
- $v_charset = escapeshellarg($_POST['v_charset']);
- exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var);
- $v_type = $_POST['v_type'];
- $v_charset = $_POST['v_charset'];
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- unset($v_password);
- unset($output);
- } else {
- $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']);
- unset($v_database);
- unset($v_dbuser);
- unset($v_password);
- unset($v_type);
- unset($v_charset);
- unset($output);
- }
- }
- }
- exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var);
- $db_types = json_decode(implode('', $output), true);
- unset($output);
-
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
- unset($_SESSION['error_msg']);
- unset($_SESSION['ok_msg']);
-//}
-
-// Footer
-include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
+ $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg);
+ } else {
+ // Add Database
+ $v_type = escapeshellarg($_POST['v_type']);
+ $v_charset = escapeshellarg($_POST['v_charset']);
+ exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var);
+ $v_type = $_POST['v_type'];
+ $v_charset = $_POST['v_charset'];
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ unset($v_password);
+ unset($output);
+ } else {
+ if (empty($v_notify)) {
+ list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]);
+ if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/";
+ if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/";
+
+ $to = $panel[$user]['CONTACT'];
+ $subject = _("Database Credentials");
+ $hostname = exec('hostname');
+ $from = _('MAIL_FROM',$hostname);
+ $mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']);
+ $mailtext .= $db_admin_link."\n\n";
+
+ $mailtext .= "--\n"._('Vesta Control Panel')."\n";
+ send_email($to, $subject, $mailtext, $from);
+ }
+ $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']);
+ unset($v_database);
+ unset($v_dbuser);
+ unset($v_password);
+ unset($v_type);
+ unset($v_charset);
+ unset($output);
+ }
+ }
+}
+exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var);
+$db_types = json_decode(implode('', $output), true);
+unset($output);
+
+include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
+//}
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
\ No newline at end of file
diff --git a/web/edit/web/index.php b/web/edit/web/index.php
index 3116d876..309d8aea 100644
--- a/web/edit/web/index.php
+++ b/web/edit/web/index.php
@@ -1,587 +1,587 @@
-', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- } else {
- $data = json_decode(implode('', $output), true);
- unset($output);
- $v_username = $user;
- $v_domain = $_GET['domain'];
- $v_ip = $data[$v_domain]['IP'];
- $v_template = $data[$v_domain]['TPL'];
- $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']);
- $valiases = explode(",", $data[$v_domain]['ALIAS']);
- $v_tpl = $data[$v_domain]['IP'];
- $v_cgi = $data[$v_domain]['CGI'];
- $v_elog = $data[$v_domain]['ELOG'];
- $v_ssl = $data[$v_domain]['SSL'];
- if ( $v_ssl == 'yes' ) {
- exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
- $ssl_str = json_decode(implode('', $output), true);
- unset($output);
- $v_ssl_crt = $ssl_str[$v_domain]['CRT'];
- $v_ssl_key = $ssl_str[$v_domain]['KEY'];
- $v_ssl_ca = $ssl_str[$v_domain]['CA'];
- }
- $v_ssl_home = $data[$v_domain]['SSL_HOME'];
- $v_nginx = $data[$v_domain]['NGINX'];
- $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']);
- $v_stats = $data[$v_domain]['STATS'];
- $v_stats_user = $data[$v_domain]['STATS_USER'];
- if (!empty($v_stats_user)) $v_stats_password = "••••••••";
- $v_ftp_user = $data[$v_domain]['FTP_USER'];
- if (!empty($v_ftp_user)) $v_ftp_password = "••••••••";
- $v_suspended = $data[$v_domain]['SUSPENDED'];
- if ( $v_suspended == 'yes' ) {
- $v_status = 'suspended';
- } else {
- $v_status = 'active';
- }
- $v_time = $data[$v_domain]['TIME'];
- $v_date = $data[$v_domain]['DATE'];
-
- exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
- $ips = json_decode(implode('', $output), true);
- unset($output);
-
- exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
- $templates = json_decode(implode('', $output), true);
- unset($output);
-
- exec (VESTA_CMD."v-list-web-stats json", $output, $return_var);
- $stats = json_decode(implode('', $output), true);
- unset($output);
- }
-
- // Action
- if (!empty($_POST['save'])) {
- $v_domain = escapeshellarg($_POST['v_domain']);
-
- // IP
- if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
- $v_ip = escapeshellarg($_POST['v_ip']);
- exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $restart_web = 'yes';
- unset($output);
- exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var);
- if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) {
- exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $restart_dns = 'yes';
- }
- unset($output);
- foreach($valiases as $v_alias ){
- exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var);
- if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) {
- exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $restart_dns = 'yes';
- }
- unset($output);
- }
- }
-
- // Template
- if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
- $v_template = escapeshellarg($_POST['v_template']);
- exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $restart_web = 'yes';
- }
-
- // Aliases
- if (empty($_SESSION['error_msg'])) {
- $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']);
- $waliases = preg_replace("/,/", " ", $waliases);
- $waliases = preg_replace('/\s+/', ' ',$waliases);
- $waliases = trim($waliases);
- $aliases = explode(" ", $waliases);
- $v_aliases = str_replace(' ', "\n", $waliases);
- $result = array_diff($valiases, $aliases);
- foreach ($result as $alias) {
- if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
- $restart_web = 'yes';
- $v_template = escapeshellarg($_POST['v_template']);
- exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
-
- if (empty($_SESSION['error_msg'])) {
- exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $restart_dns = 'yes';
- }
- unset($output);
- }
- }
-
- $result = array_diff($aliases, $valiases);
- foreach ($result as $alias) {
- if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
- $restart_web = 'yes';
- $v_template = escapeshellarg($_POST['v_template']);
- exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- if (empty($_SESSION['error_msg'])) {
- exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $restart_dns = 'yes';
- }
- unset($output);
- }
- }
- }
-
- // Nginx
- if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
- exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- unset($v_nginx);
- $restart_web = 'yes';
- }
- if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
- $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
- $ext = preg_replace("/,/", " ", $ext);
- $ext = preg_replace('/\s+/', ' ',$ext);
- $ext = trim($ext);
- $ext = str_replace(' ', ", ", $ext);
- if ( $v_nginx_ext != $ext ) {
- $ext = str_replace(', ', ",", $ext);
- exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $v_nginx_ext = str_replace(',', ', ', $ext);
- unset($output);
- $restart_web = 'yes';
- }
- }
- if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
- $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'";
- if (!empty($_POST['v_nginx_ext'])) {
- $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
- $ext = preg_replace("/,/", " ", $ext);
- $ext = preg_replace('/\s+/', ' ',$ext);
- $ext = trim($ext);
- $ext = str_replace(' ', ",", $ext);
- $v_nginx_ext = str_replace(',', ', ', $ext);
- }
- exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_nginx = 'default';
- $restart_web = 'yes';
- }
-
- // SSL
- if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
- exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_ssl = 'no';
- $restart_web = 'yes';
- }
- if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
- if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) {
- exec ('mktemp -d', $mktemp_output, $return_var);
- $tmpdir = $mktemp_output[0];
-
- // Certificate
- if (!empty($_POST['v_ssl_crt'])) {
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
- fwrite($fp, "\n");
- fclose($fp);
- }
-
- // Key
- if (!empty($_POST['v_ssl_key'])) {
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
- fwrite($fp, "\n");
- fclose($fp);
- }
-
- // CA
- if (!empty($_POST['v_ssl_ca'])) {
- $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
- fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
- fwrite($fp, "\n");
- fclose($fp);
- }
-
- exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $restart_web = 'yes';
- $v_ssl_crt = $_POST['v_ssl_crt'];
- $v_ssl_key = $_POST['v_ssl_key'];
- $v_ssl_ca = $_POST['v_ssl_ca'];
- }
- }
- if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
- if ( $v_ssl_home != $_POST['v_ssl_home'] ) {
- $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
- exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- $v_ssl_home = $_POST['v_ssl_home'];
- unset($output);
- }
- }
- if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate';
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key';
- if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home';
- $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
- if (!empty($errors[0])) {
- foreach ($errors as $i => $error) {
- if ( $i == 0 ) {
- $error_msg = $error;
- } else {
- $error_msg = $error_msg.", ".$error;
- }
- }
- $_SESSION['error_msg'] = _('Error: 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);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_ssl = 'yes';
- $restart_web = 'yes';
- $v_ssl_crt = $_POST['v_ssl_crt'];
- $v_ssl_key = $_POST['v_ssl_key'];
- $v_ssl_ca = $_POST['v_ssl_ca'];
- $v_ssl_home = $_POST['v_ssl_home'];
- }
- }
-
- // 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);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_stats = '';
- }
- 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);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- }
- 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);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- }
-
- // Web Stats Auth
- 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);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_stats_user = '';
- $v_stats_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($_POST['v_stats_password'])) $errors[] = _('stats 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'] = _('Error: field "%s" can not be blank.',$error_msg);
- } else {
- $v_stats_user = escapeshellarg($_POST['v_stats_user']);
- $v_stats_password = escapeshellarg($_POST['v_stats_password']);
- exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_stats_password = "••••••••";
- }
- }
- 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($_POST['v_stats_password'])) $errors[] = _('stats 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'] = _('Error: field "%s" can not be blank.',$error_msg);
- }
- if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) {
- $v_stats_user = escapeshellarg($_POST['v_stats_user']);
- $v_stats_password = escapeshellarg($_POST['v_stats_password']);
- exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_stats_password = "••••••••";
- }
- }
-
- // FTP Account
- if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
- exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_ftp= '';
- $v_ftp_user = '';
- $v_ftp_password = '';
- }
- if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
- if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user');
- if (empty($_POST['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'] = _('Error: field "%s" can not be blank.',$error_msg);
- }
- if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) {
- $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']);
- $v_ftp_user = escapeshellarg($v_ftp_user);
- $v_ftp_password = escapeshellarg($_POST['v_ftp_password']);
- exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- unset($output);
- $v_ftp_user = $user."_".$_POST['v_ftp_user'];
- $v_ftp_password = "••••••••";
- }
- }
-
- if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
- if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.');
- if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user';
- if (empty($_POST['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'] = _('Error: field "%s" can not be blank.',$error_msg);
- }
- if (empty($_SESSION['error_msg'])) {
- $v_ftp_user = escapeshellarg($_POST['v_ftp_user']);
- $v_ftp_password = escapeshellarg($_POST['v_ftp_password']);
- exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- } else {
- if (!empty($_POST['v_ftp_email'])) {
- $to = $_POST['v_ftp_email'];
- $subject = _("FTP login credentials");
- $hostname = exec('hostname');
- $from = _('MAIL_FROM',$hostname);
- $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']);
- send_email($to, $subject, $mailtext, $from);
- unset($v_ftp_email);
- }
- }
- unset($output);
- $v_ftp_user = $user."_".$_POST['v_ftp_user'];
- $v_ftp_password = "••••••••";
- }
- }
-
- // Restart web
- if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {
- exec (VESTA_CMD."v-restart-web", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- }
-
- // Restart dns
- if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
- exec (VESTA_CMD."v-restart-dns", $output, $return_var);
- if ($return_var != 0) {
- $error = implode(' ', $output);
- if (empty($error)) $error = _('Error: vesta did not return any output.');
- $_SESSION['error_msg'] = $error;
- }
- }
-
- if (empty($_SESSION['error_msg'])) {
- $_SESSION['ok_msg'] = _('OK: changes has been saved.');
- }
-
- }
-if ($_SESSION['user'] == 'admin') {
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html');
-} else {
- include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html');
-}
- unset($_SESSION['error_msg']);
- unset($_SESSION['ok_msg']);
-//}
-
-// Footer
-include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
+', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+} else {
+ $data = json_decode(implode('', $output), true);
+ unset($output);
+ $v_username = $user;
+ $v_domain = $_GET['domain'];
+ $v_ip = $data[$v_domain]['IP'];
+ $v_template = $data[$v_domain]['TPL'];
+ $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']);
+ $valiases = explode(",", $data[$v_domain]['ALIAS']);
+ $v_tpl = $data[$v_domain]['IP'];
+ $v_cgi = $data[$v_domain]['CGI'];
+ $v_elog = $data[$v_domain]['ELOG'];
+ $v_ssl = $data[$v_domain]['SSL'];
+ if ( $v_ssl == 'yes' ) {
+ exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var);
+ $ssl_str = json_decode(implode('', $output), true);
+ unset($output);
+ $v_ssl_crt = $ssl_str[$v_domain]['CRT'];
+ $v_ssl_key = $ssl_str[$v_domain]['KEY'];
+ $v_ssl_ca = $ssl_str[$v_domain]['CA'];
+ }
+ $v_ssl_home = $data[$v_domain]['SSL_HOME'];
+ $v_nginx = $data[$v_domain]['NGINX'];
+ $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']);
+ $v_stats = $data[$v_domain]['STATS'];
+ $v_stats_user = $data[$v_domain]['STATS_USER'];
+ if (!empty($v_stats_user)) $v_stats_password = "••••••••";
+ $v_ftp_user = $data[$v_domain]['FTP_USER'];
+ if (!empty($v_ftp_user)) $v_ftp_password = "••••••••";
+ $v_suspended = $data[$v_domain]['SUSPENDED'];
+ if ( $v_suspended == 'yes' ) {
+ $v_status = 'suspended';
+ } else {
+ $v_status = 'active';
+ }
+ $v_time = $data[$v_domain]['TIME'];
+ $v_date = $data[$v_domain]['DATE'];
+
+ exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
+ $ips = json_decode(implode('', $output), true);
+ unset($output);
+
+ exec (VESTA_CMD."v-list-web-templates json", $output, $return_var);
+ $templates = json_decode(implode('', $output), true);
+ unset($output);
+
+ exec (VESTA_CMD."v-list-web-stats json", $output, $return_var);
+ $stats = json_decode(implode('', $output), true);
+ unset($output);
+}
+
+// Action
+if (!empty($_POST['save'])) {
+ $v_domain = escapeshellarg($_POST['v_domain']);
+
+ // IP
+ if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
+ $v_ip = escapeshellarg($_POST['v_ip']);
+ exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $restart_web = 'yes';
+ unset($output);
+ exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var);
+ if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) {
+ exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $restart_dns = 'yes';
+ }
+ unset($output);
+ foreach($valiases as $v_alias ){
+ exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var);
+ if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) {
+ exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $restart_dns = 'yes';
+ }
+ unset($output);
+ }
+ }
+
+ // Template
+ if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
+ $v_template = escapeshellarg($_POST['v_template']);
+ exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $restart_web = 'yes';
+ }
+
+ // Aliases
+ if (empty($_SESSION['error_msg'])) {
+ $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']);
+ $waliases = preg_replace("/,/", " ", $waliases);
+ $waliases = preg_replace('/\s+/', ' ',$waliases);
+ $waliases = trim($waliases);
+ $aliases = explode(" ", $waliases);
+ $v_aliases = str_replace(' ', "\n", $waliases);
+ $result = array_diff($valiases, $aliases);
+ foreach ($result as $alias) {
+ if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
+ $restart_web = 'yes';
+ $v_template = escapeshellarg($_POST['v_template']);
+ exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $restart_dns = 'yes';
+ }
+ unset($output);
+ }
+ }
+
+ $result = array_diff($aliases, $valiases);
+ foreach ($result as $alias) {
+ if ((empty($_SESSION['error_msg'])) && (!empty($alias))) {
+ $restart_web = 'yes';
+ $v_template = escapeshellarg($_POST['v_template']);
+ exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ if (empty($_SESSION['error_msg'])) {
+ exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $restart_dns = 'yes';
+ }
+ unset($output);
+ }
+ }
+ }
+
+ // Nginx
+ if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ unset($v_nginx);
+ $restart_web = 'yes';
+ }
+ if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
+ $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
+ $ext = preg_replace("/,/", " ", $ext);
+ $ext = preg_replace('/\s+/', ' ',$ext);
+ $ext = trim($ext);
+ $ext = str_replace(' ', ", ", $ext);
+ if ( $v_nginx_ext != $ext ) {
+ $ext = str_replace(', ', ",", $ext);
+ exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $v_nginx_ext = str_replace(',', ', ', $ext);
+ unset($output);
+ $restart_web = 'yes';
+ }
+ }
+ if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) {
+ $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'";
+ if (!empty($_POST['v_nginx_ext'])) {
+ $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']);
+ $ext = preg_replace("/,/", " ", $ext);
+ $ext = preg_replace('/\s+/', ' ',$ext);
+ $ext = trim($ext);
+ $ext = str_replace(' ', ",", $ext);
+ $v_nginx_ext = str_replace(',', ', ', $ext);
+ }
+ exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_nginx = 'default';
+ $restart_web = 'yes';
+ }
+
+ // SSL
+ if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_ssl = 'no';
+ $restart_web = 'yes';
+ }
+ if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
+ if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) {
+ exec ('mktemp -d', $mktemp_output, $return_var);
+ $tmpdir = $mktemp_output[0];
+
+ // Certificate
+ if (!empty($_POST['v_ssl_crt'])) {
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w');
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
+ fwrite($fp, "\n");
+ fclose($fp);
+ }
+
+ // Key
+ if (!empty($_POST['v_ssl_key'])) {
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w');
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
+ fwrite($fp, "\n");
+ fclose($fp);
+ }
+
+ // CA
+ if (!empty($_POST['v_ssl_ca'])) {
+ $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w');
+ fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca']));
+ fwrite($fp, "\n");
+ fclose($fp);
+ }
+
+ exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $restart_web = 'yes';
+ $v_ssl_crt = $_POST['v_ssl_crt'];
+ $v_ssl_key = $_POST['v_ssl_key'];
+ $v_ssl_ca = $_POST['v_ssl_ca'];
+ }
+ }
+ if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
+ if ( $v_ssl_home != $_POST['v_ssl_home'] ) {
+ $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
+ exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ $v_ssl_home = $_POST['v_ssl_home'];
+ unset($output);
+ }
+ }
+ if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate';
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key';
+ if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home';
+ $v_ssl_home = escapeshellarg($_POST['v_ssl_home']);
+ if (!empty($errors[0])) {
+ foreach ($errors as $i => $error) {
+ if ( $i == 0 ) {
+ $error_msg = $error;
+ } else {
+ $error_msg = $error_msg.", ".$error;
+ }
+ }
+ $_SESSION['error_msg'] = _('Error: 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);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_ssl = 'yes';
+ $restart_web = 'yes';
+ $v_ssl_crt = $_POST['v_ssl_crt'];
+ $v_ssl_key = $_POST['v_ssl_key'];
+ $v_ssl_ca = $_POST['v_ssl_ca'];
+ $v_ssl_home = $_POST['v_ssl_home'];
+ }
+ }
+
+ // 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);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_stats = '';
+ }
+ 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);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ }
+ 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);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ }
+
+ // Web Stats Auth
+ 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);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_stats_user = '';
+ $v_stats_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($_POST['v_stats_password'])) $errors[] = _('stats 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'] = _('Error: field "%s" can not be blank.',$error_msg);
+ } else {
+ $v_stats_user = escapeshellarg($_POST['v_stats_user']);
+ $v_stats_password = escapeshellarg($_POST['v_stats_password']);
+ exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_stats_password = "••••••••";
+ }
+ }
+ 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($_POST['v_stats_password'])) $errors[] = _('stats 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'] = _('Error: field "%s" can not be blank.',$error_msg);
+ }
+ if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) {
+ $v_stats_user = escapeshellarg($_POST['v_stats_user']);
+ $v_stats_password = escapeshellarg($_POST['v_stats_password']);
+ exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_stats_password = "••••••••";
+ }
+ }
+
+ // FTP Account
+ if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_ftp= '';
+ $v_ftp_user = '';
+ $v_ftp_password = '';
+ }
+ if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
+ if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user');
+ if (empty($_POST['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'] = _('Error: field "%s" can not be blank.',$error_msg);
+ }
+ if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) {
+ $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']);
+ $v_ftp_user = escapeshellarg($v_ftp_user);
+ $v_ftp_password = escapeshellarg($_POST['v_ftp_password']);
+ exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ unset($output);
+ $v_ftp_user = $_POST['v_ftp_user'];
+ $v_ftp_password = "••••••••";
+ }
+ }
+
+ if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) {
+ if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.');
+ if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user';
+ if (empty($_POST['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'] = _('Error: field "%s" can not be blank.',$error_msg);
+ }
+ if (empty($_SESSION['error_msg'])) {
+ $v_ftp_user = escapeshellarg($_POST['v_ftp_user']);
+ $v_ftp_password = escapeshellarg($_POST['v_ftp_password']);
+ exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ } else {
+ if (!empty($_POST['v_ftp_email'])) {
+ $to = $_POST['v_ftp_email'];
+ $subject = _("FTP login credentials");
+ $hostname = exec('hostname');
+ $from = _('MAIL_FROM',$hostname);
+ $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user."_".$_POST['v_ftp_user'],$_POST['v_ftp_password']);
+ send_email($to, $subject, $mailtext, $from);
+ unset($v_ftp_email);
+ }
+ }
+ unset($output);
+ $v_ftp_user = $user."_".$_POST['v_ftp_user'];
+ $v_ftp_password = "••••••••";
+ }
+ }
+
+ // Restart web
+ if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-restart-web", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ }
+
+ // Restart dns
+ if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) {
+ exec (VESTA_CMD."v-restart-dns", $output, $return_var);
+ if ($return_var != 0) {
+ $error = implode(' ', $output);
+ if (empty($error)) $error = _('Error: vesta did not return any output.');
+ $_SESSION['error_msg'] = $error;
+ }
+ }
+
+ if (empty($_SESSION['error_msg'])) {
+ $_SESSION['ok_msg'] = _('OK: changes has been saved.');
+ }
+
+}
+if ($_SESSION['user'] == 'admin') {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html');
+} else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html');
+}
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
+//}
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
\ No newline at end of file
diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php
index 44df420c..359a2406 100644
--- a/web/inc/i18n/ru.php
+++ b/web/inc/i18n/ru.php
@@ -147,5 +147,8 @@ $LANG = array(
'Reset Code'=>'Код сброса',
'disk'=>'Место',
'traffic'=>'Трафик',
+ 'Database Credentials'=>'Данные для доступа к БД',
+ 'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n",
+ 'Send credentials to'=>'Отправить данные для доступа к '
);
\ No newline at end of file
diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html
index fdeb1d8b..35aecc0a 100644
--- a/web/templates/admin/add_db.html
+++ b/web/templates/admin/add_db.html
@@ -1,176 +1,184 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html
index a11e6321..0aee6810 100644
--- a/web/templates/admin/list_dns.html
+++ b/web/templates/admin/list_dns.html
@@ -1,147 +1,146 @@
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [] template
-
-
-
-
-
-
-
- SOA:
-
-
-
- TTL:
-
-
-
-
-
-
-
- Expire:
-
-
-
- Records:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [] template
+
+
+
+
+
+
+
+ SOA:
+
+
+
+ TTL:
+
+
+
+
+
+
+
+ Expire:
+
+
+
+ Records:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html
index 2489aea7..ee823723 100644
--- a/web/templates/admin/list_dns_rec.html
+++ b/web/templates/admin/list_dns_rec.html
@@ -1,107 +1,115 @@
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- ?>
-
-
-
-
-
-
-
-
-
- edit
-
-
-
-
-
-
Are you sure you want to record?
-
-
-
-
- delete
-
-
-
Are you sure you want to delete record?
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ edit
+
+
+
+
+
+
Are you sure you want to record?
+
+
+
+
+ delete
+
+
+
Are you sure you want to delete record?
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html
index e5a1844c..000a4e8f 100644
--- a/web/templates/admin/list_mail.html
+++ b/web/templates/admin/list_mail.html
@@ -1,173 +1,173 @@
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- if (empty($data[$key]['CATCHALL'])) {
- $data[$key]['CATCHALL'] = '/dev/null';
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- catchall >
-
-
-
-
- Disk:
-
-
-
-
-
-
-
-
-
- Antivirus:
-
-
-
-
-
-
-
- Antispam:
-
-
-
-
-
-
-
-
-
-
-
- DKIM:
-
-
-
-
-
-
-
- Accounts:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ if (empty($data[$key]['CATCHALL'])) {
+ $data[$key]['CATCHALL'] = '/dev/null';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ catchall >
+
+
+
+
+ Disk:
+
+
+
+
+
+
+
+
+
+ Antivirus:
+
+
+
+
+
+
+
+ Antispam:
+
+
+
+
+
+
+
+
+
+
+
+ DKIM:
+
+
+
+
+
+
+
+ Accounts:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html
index 2137383d..f13e33ca 100644
--- a/web/templates/admin/list_mail_acc.html
+++ b/web/templates/admin/list_mail_acc.html
@@ -1,155 +1,162 @@
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend';
- }
- ?>
-
-
-
-
-
-
-
-
-
- edit
-
-
-
-
-
-
Are you sure you want to account?
-
-
-
-
- delete
-
-
-
Are you sure you want to delete account?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Disk:
-
-
-
-
-
-
-
-
-
- Quota:
-
-
-
-
-
-
-
- Autoreply:
-
-
-
-
-
-
-
-
-
-
-
- Forward:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ edit
+
+
+
+
+
+
Are you sure you want to account?
+
+
+
+
+ delete
+
+
+
Are you sure you want to delete account?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Disk:
+
+
+
+
+
+
+
+
+
+ Quota:
+
+
+
+
+
+
+
+ Autoreply:
+
+
+
+
+
+
+
+
+
+
+
+ Forward:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/header.html b/web/templates/header.html
index 4ae4b1aa..c8759d5b 100644
--- a/web/templates/header.html
+++ b/web/templates/header.html
@@ -1,721 +1,718 @@
-
-
-
- Vesta -
-
-
-
-
-
-
-
-
-
+
+
+
+Vesta -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html
index 070e7899..a6cbf6f5 100644
--- a/web/templates/user/list_dns.html
+++ b/web/templates/user/list_dns.html
@@ -1,137 +1,136 @@
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [] template
-
-
-
-
-
-
-
- SOA:
-
-
-
- TTL:
-
-
-
-
-
-
-
- Expire:
-
-
-
- Records:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [] template
+
+
+
+
+
+
+
+ SOA:
+
+
+
+ TTL:
+
+
+
+
+
+
+
+ Expire:
+
+
+
+ Records:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html
index 2cec75fa..2179cc99 100644
--- a/web/templates/user/list_dns_rec.html
+++ b/web/templates/user/list_dns_rec.html
@@ -1,98 +1,105 @@
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- ?>
-
-
-
-
-
-
-
-
-
- edit
-
-
- delete
-
-
-
Are you sure you want to delete record?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ edit
+
+
+ delete
+
+
+
Are you sure you want to delete record?
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html
index 3d15bc71..c0db21ef 100644
--- a/web/templates/user/list_mail.html
+++ b/web/templates/user/list_mail.html
@@ -1,164 +1,163 @@
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- if (empty($data[$key]['CATCHALL'])) {
- $data[$key]['CATCHALL'] = '/dev/null';
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- catchall >
-
-
-
-
- Disk:
-
-
-
-
-
-
-
-
-
- Antivirus:
-
-
-
-
-
-
-
- Antispam:
-
-
-
-
-
-
-
-
-
-
-
- DKIM:
-
-
-
-
-
-
-
- Accounts:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ if (empty($data[$key]['CATCHALL'])) {
+ $data[$key]['CATCHALL'] = '/dev/null';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ catchall >
+
+
+
+
+ Disk:
+
+
+
+
+
+
+
+
+
+ Antivirus:
+
+
+
+
+
+
+
+ Antispam:
+
+
+
+
+
+
+
+
+
+
+
+ DKIM:
+
+
+
+
+
+
+
+ Accounts:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html
index cfa9c9e0..4548743b 100644
--- a/web/templates/user/list_mail_acc.html
+++ b/web/templates/user/list_mail_acc.html
@@ -1,145 +1,152 @@
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend';
- }
- ?>
-
-
-
-
-
-
-
-
-
- edit
-
-
- delete
-
-
-
Are you sure you want to delete account?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Disk:
-
-
-
-
-
-
-
-
-
- Quota:
-
-
-
-
-
-
-
- Autoreply:
-
-
-
-
-
-
-
-
-
-
-
- Forward:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ edit
+
+
+ delete
+
+
+
Are you sure you want to delete account?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Disk:
+
+
+
+
+
+
+
+
+
+ Quota:
+
+
+
+
+
+
+
+ Autoreply:
+
+
+
+
+
+
+
+
+
+
+
+ Forward:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file