diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias
index f4889da67..c5890b184 100755
--- a/bin/v-add-dns-on-web-alias
+++ b/bin/v-add-dns-on-web-alias
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#!/bin/bash
# info: add dns domain or dns record based on web domain alias restart
# options: USER DOMAIN
@@ -50,15 +49,21 @@ 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
+ $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
- $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart
+ $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)
@@ -66,7 +71,8 @@ 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
+ $BIN/v-add-dns-domain-record \
+ $user $dom "$sub" A $IP '' '' $restart > /dev/null
fi
fi
fi
@@ -79,92 +85,3 @@ 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 69c58673d..4644f8df7 100755
--- a/bin/v-add-web-domain-ftp
+++ b/bin/v-add-web-domain-ftp
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#!/bin/bash
# info: add ftp account for web domain.
# options: USER DOMAIN FTP_USER FTP_PASSWORD
@@ -44,8 +43,14 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
# Action #
#----------------------------------------------------------#
-# Get domain values
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
@@ -70,82 +75,3 @@ 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-list-sys-services b/bin/v-list-sys-services
new file mode 100755
index 000000000..cc5951576
--- /dev/null
+++ b/bin/v-list-sys-services
@@ -0,0 +1,188 @@
+#!/bin/bash
+# info: list system config
+# options: [FORMAT]
+#
+# The function for obtaining the list of system parameters.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+format=${1-shell}
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+
+get_srv_state() {
+ srv=$1
+ proc_name=${2-$1}
+
+ # Check service status
+ /etc/init.d/$srv status > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ state='running'
+
+ # Calculate cpu and memory usage
+ cpu=0
+ mem=0
+ for pid in $(/sbin/pidof $proc_name); do
+ pid_mem=$(pmap -x $pid | tail -n1 | awk '{print $3}')
+ pid_cpu=$(grep "^$pid " $tmp_file | cut -f 2 -d ' ')
+ cpu=$((cpu + pid_cpu))
+ mem=$((mem + pid_mem))
+ done
+ mem=$((mem / 1024))
+
+ # Get pid date
+ if [ ! -z $pid ] && [ -e "/proc/$pid/cmdline" ]; then
+ mtime=$(stat -c "%Y" /proc/$pid/cmdline)
+ rtime=$((ctime - mtime))
+ rtime=$((rtime / 60))
+ fi
+ else
+ # Service is stopped
+ state='stopped'
+ mem=0
+ cpu=0
+ rtime="0"
+ fi
+}
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+# Save current proccess list
+tmp_file=$(mktemp)
+if [ "$format" = 'json' ]; then
+ ps aux | awk '{print $2" "$3}' | tr -d '.' > $tmp_file
+else
+ ps aux | awk '{print $2" "$3}' | cut -f 1 -d '.' > $tmp_file
+fi
+
+# Get current time
+ctime=$(date +%s)
+
+# Proxy
+service=$PROXY_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service
+ str="NAME='$service' SYSTEM='reverse proxy' STATE='$state' CPU='$cpu'"
+ str="$str MEM='$mem' RTIME='$rtime'"
+fi
+
+# Web
+service=$WEB_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ if [ "$service" == 'apache' ]; then
+ service='httpd'
+ fi
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='web server' STATE='$state' CPU='$cpu'"
+ str="$str MEM='$mem' RTIME='$rtime'"
+
+fi
+
+# DNS
+service=$DNS_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ if [ "$service" == 'bind' ]; then
+ service='named'
+ fi
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='dns server' STATE='$state' CPU='$cpu'"
+ str="$str MEM='$mem' RTIME='$rtime'"
+fi
+
+# MAIL
+service=$MAIL_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='mail server' STATE='$state' CPU='$cpu'"
+ str="$str MEM='$mem' RTIME='$rtime'"
+fi
+
+# IMAP
+service=$IMAP_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='pop/imap server' STATE='$state'"
+ str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+fi
+
+# ANTIVIRUS
+service=$ANTIVIRUS_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ if [ "$ANTIVIRUS_SYSTEM" = 'clamav' ]; then
+ service='clamd'
+ fi
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='email antivirus' STATE='$state'"
+ str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+fi
+
+# ANTISPAM
+service=$ANTISPAM_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service spamd
+ str="$str\nNAME='$service' SYSTEM='email antispam' STATE='$state'"
+ str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+fi
+
+# DB
+service=$DB_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ for db in ${DB_SYSTEM//,/ }; do
+ service="$db"
+ if [ "$service" == 'mysql' ] && [ ! -e "/etc/init.d/$service" ]; then
+ service='mysqld'
+ fi
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='database server' STATE='$state'"
+ str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+ done
+fi
+
+# FTP
+service=$FTP_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='ftp server' STATE='$state' CPU='$cpu'"
+ str="$str MEM='$mem' RTIME='$rtime'"
+fi
+
+# CRON
+service=$CRON_SYSTEM
+if [ ! -z "$service" ] && [ "$service" != 'no' ]; then
+ get_srv_state $service
+ str="$str\nNAME='$service' SYSTEM='job scheduler' STATE='$state'"
+ str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+fi
+
+# Defining config
+echo -e "$str" > $tmp_file
+conf=$tmp_file
+
+# Defining fileds to select
+fields="\$NAME \$SYSTEM \$STATE \$CPU \$MEM \$RTIME"
+
+# Listing services
+case $format in
+ json) json_list ;;
+ plain) nohead=1; shell_list ;;
+ shell) fields='$NAME $STATE $CPU $MEM $RTIME'
+ shell_list | column -t ;;
+ *) check_args '1' '0' 'USER [FORMAT]'
+esac
+
+rm -f $tmp_file
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+exit
diff --git a/bin/v-list-user-stats b/bin/v-list-user-stats
index eac6e9142..c79631d56 100755
--- a/bin/v-list-user-stats
+++ b/bin/v-list-user-stats
@@ -32,6 +32,9 @@ is_object_valid 'user' 'USER' "$user"
# Defining config
conf=$USER_DATA/stats.log
+if [ ! -e "$conf" ]; then
+ touch $conf
+fi
# Defining fileds to select
fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS"
diff --git a/bin/v-list-users-stats b/bin/v-list-users-stats
index 8a6fbf583..95f39ea05 100755
--- a/bin/v-list-users-stats
+++ b/bin/v-list-users-stats
@@ -29,6 +29,9 @@ check_args '0' "$#" '[FORMAT]'
# Defining config
conf=$VESTA/data/users/admin/overall_stats.log
+if [ ! -e "$conf" ]; then
+ touch $conf
+fi
# Defining fileds to select
fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS"
diff --git a/bin/v-rebuild-user b/bin/v-rebuild-user
index 3635fd702..52ece73ae 100755
--- a/bin/v-rebuild-user
+++ b/bin/v-rebuild-user
@@ -143,7 +143,7 @@ fi
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
touch $USER_DATA/db.conf
chmod 660 $USER_DATA/db.conf
- echo "v_update_datbases_disk $user" >> $VESTA/data/queue/disk.pipe
+ echo "v-update-datbases-disk $user" >> $VESTA/data/queue/disk.pipe
fi
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains
index cb1a66307..847efb8a8 100755
--- a/bin/v-rebuild-web-domains
+++ b/bin/v-rebuild-web-domains
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#!/bin/bash
# info: rebuild dns domains
# options: USER [RESTART]
@@ -79,7 +78,7 @@ for domain in $(shell_list) ; do
chmod 551 $HOMEDIR/$user/web/$domain
chmod 771 $HOMEDIR/$user/web/$domain/private
- chmod 771 $HOMEDIR/$user/web/$domain/cgi-bin
+ 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
@@ -311,317 +310,3 @@ 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-restart-cron b/bin/v-restart-cron
index 6e0b02f0f..be1ce97ea 100755
--- a/bin/v-restart-cron
+++ b/bin/v-restart-cron
@@ -12,7 +12,6 @@
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
#----------------------------------------------------------#
@@ -21,11 +20,10 @@ EVENT=${1-$EVENT}
# Parsing config / or just source config
if [ "$CRON_SYSTEM" = 'crond' ]; then
- /etc/init.d/crond 'reload' &>/dev/null
+ /etc/init.d/crond 'reload' >/dev/null 2>&1
if [ $? -ne 0 ]; then
- /etc/init.d/crond 'restart' &>/dev/null
+ /etc/init.d/crond 'restart' >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
fi
diff --git a/bin/v-restart-dns b/bin/v-restart-dns
index a780d29d4..f4cdf7e0c 100755
--- a/bin/v-restart-dns
+++ b/bin/v-restart-dns
@@ -12,18 +12,17 @@
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ "$DNS_SYSTEM" = 'bind' ]; then
- /etc/init.d/named reload &>/dev/null
+ /etc/init.d/named reload >/dev/null 2>&1
if [ $? -ne 0 ]; then
- /etc/init.d/named restart &>/dev/null
+ /etc/init.d/named restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
fi
diff --git a/bin/v-restart-mail b/bin/v-restart-mail
index f66085c95..c0217ee75 100755
--- a/bin/v-restart-mail
+++ b/bin/v-restart-mail
@@ -12,18 +12,17 @@
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ "$MAIL_SYSTEM" = 'exim' ]; then
- /etc/init.d/exim reload &>/dev/null
+ /etc/init.d/exim reload >/dev/null 2>&1
if [ $? -ne 0 ]; then
- /etc/init.d/exim restart &>/dev/null
+ /etc/init.d/exim restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
fi
diff --git a/bin/v-restart-service b/bin/v-restart-service
new file mode 100755
index 000000000..bd72de25b
--- /dev/null
+++ b/bin/v-restart-service
@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: restart service
+# options: service
+#
+# The function restarts system service.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+ /etc/init.d/$service restart >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ exit $E_RESTART
+ fi
+fi
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+exit
diff --git a/bin/v-restart-web b/bin/v-restart-web
index 128cd00ae..d82f40e1c 100755
--- a/bin/v-restart-web
+++ b/bin/v-restart-web
@@ -1,8 +1,8 @@
#!/bin/bash
-# info: restart dns service
+# info: restart web services
# options: NONE
#
-# The function tells BIND service to reload dns zone files.
+# The function reloads web server configuration.
#----------------------------------------------------------#
@@ -12,41 +12,37 @@
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
-EVENT=${1-$EVENT}
+
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ "$WEB_SYSTEM" = 'apache' ]; then
- /etc/init.d/httpd status &>/dev/null
+ /etc/init.d/httpd status >/dev/null 2>&1
if [ $? -eq 0 ]; then
- /etc/init.d/httpd graceful &>/dev/null
+ /etc/init.d/httpd graceful >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
else
- /etc/init.d/httpd start &>/dev/null
+ /etc/init.d/httpd start >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
fi
fi
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
- /etc/init.d/nginx status &>/dev/null
+ /etc/init.d/nginx status >/dev/null 2>&1
if [ $? -eq 0 ]; then
- /etc/init.d/nginx reload &>/dev/null
+ /etc/init.d/nginx reload >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
else
- /etc/init.d/nginx start &>/dev/null
+ /etc/init.d/nginx start >/dev/null 2>&1
if [ $? -ne 0 ]; then
- log_event "$E_RESTART" "$EVENT"
exit $E_RESTART
fi
fi
diff --git a/bin/v-start-service b/bin/v-start-service
new file mode 100755
index 000000000..47434f19c
--- /dev/null
+++ b/bin/v-start-service
@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: start service
+# options: service
+#
+# The function starts system service.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+ /etc/init.d/$service start >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ exit $E_RESTART
+ fi
+fi
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+exit
diff --git a/bin/v-stop-service b/bin/v-stop-service
new file mode 100755
index 000000000..09750db45
--- /dev/null
+++ b/bin/v-stop-service
@@ -0,0 +1,42 @@
+#!/bin/bash
+# info: stop service
+# options: service
+#
+# The function stops system service.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+service=$1
+
+# Includes
+source $VESTA/func/main.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'SERVICE'
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+if [ -x "/etc/init.d/$service" ]; then
+ /etc/init.d/$service stop >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ exit $E_RESTART
+ fi
+fi
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+exit
diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats
index 3410d8583..895359b4b 100755
--- a/bin/v-update-user-stats
+++ b/bin/v-update-user-stats
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#!/bin/bash
# info: update user statistics
# options: USER
@@ -69,7 +68,7 @@ TOTAL_U_BACKUPS=0
for user in $user_list; do
USER_DATA=$VESTA/data/users/$user
source $USER_DATA/user.conf
- next_month=$(date +'%m/01' -d '+ 1 month')
+ next_month=$(date +'%m/01/%y' -d '+ 1 month')
DATE=$(date -d "$next_month -1day" +%F)
# Compiling report string
@@ -168,174 +167,3 @@ 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 738c3f6a7..63f407cea 100644
--- a/func/domain.sh
+++ b/func/domain.sh
@@ -49,9 +49,9 @@ 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)
+ web=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
+ dns=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
+ mail=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
# Check web domain
if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
@@ -101,10 +101,10 @@ is_domain_new() {
# 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 /)
+ c1=$(grep -H "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c2=$(grep -H "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c3=$(grep -H ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
+ c4=$(grep -H ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
diff --git a/func/main.sh b/func/main.sh
index c4a6c1337..98d9bfd29 100644
--- a/func/main.sh
+++ b/func/main.sh
@@ -64,7 +64,7 @@ log_history() {
touch $log
if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then
- tail -n 99 $log > $log.moved
+ tail -n 49 $log > $log.moved
mv -f $log.moved $log
chmod 660 $log
fi
diff --git a/install/0.9.7/rhel/roundcube-driver.php b/install/0.9.7/rhel/roundcube-driver.php
index 9454a9e0c..ecfc85dad 100644
--- a/install/0.9.7/rhel/roundcube-driver.php
+++ b/install/0.9.7/rhel/roundcube-driver.php
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
$_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);
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL,
- 'content' => $request,
- ),
- ));
-
- $result = file_get_contents(
- $file = "https://".$vesta_host.":".$vesta_port."/reset/mail/?",
- $use_include_path = false,
- $context);
-
- if ($result == 'ok'){
+ if(strpos($result, 'ok') && !strpos($html, 'error'))
+ {
return PASSWORD_SUCCESS;
}
else {
@@ -53,65 +58,3 @@ class rcube_vesta_password
}
}
-=======
-
- */
-
-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/0.9.7/rhel/templates/web/apache_phpcgi.stpl b/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl
index 4a4a386c0..f59758936 100755
--- a/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl
+++ b/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl
@@ -1,34 +1,35 @@
-
-
- ServerName %domain_idn%
- %alias_string%
- ServerAdmin %email%
- DocumentRoot %sdocroot%
- %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
- Alias /vstats/ %home%/%user%/web/%domain%/stats/
- Alias /error/ %home%/%user%/web/%domain%/document_errors/
- SuexecUserGroup %user% %group%
- CustomLog /var/log/httpd/domains/%domain%.bytes bytes
- CustomLog /var/log/httpd/domains/%domain%.log combined
- %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
-
- AllowOverride AuthConfig FileInfo Indexes Limit
- SSLRequireSSL
- Options +Includes -Indexes %cgi_option%
- php_admin_flag engine off
- Action phpcgi-script /cgi-bin/php
- AddHandler phpcgi-script .php
-
-
- AllowOverride All
-
- SSLEngine on
- SSLVerifyClient none
- SSLCertificateFile %ssl_crt%
- SSLCertificateKeyFile %ssl_key%
- %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
-
- Include %home%/%user%/conf/web/shttpd.%domain%.conf*
-
-
-
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %sdocroot%
+ %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+ Alias /vstats/ %home%/%user%/web/%domain%/stats/
+ Alias /error/ %home%/%user%/web/%domain%/document_errors/
+ SuexecUserGroup %user% %group%
+ CustomLog /var/log/httpd/domains/%domain%.bytes bytes
+ CustomLog /var/log/httpd/domains/%domain%.log combined
+ %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
+
+ SSLRequireSSL
+ AllowOverride All
+ Options +Includes -Indexes +ExecCGI
+ Action phpcgi-script /cgi-bin/php
+
+ SetHandler phpcgi-script
+
+
+
+ AllowOverride All
+
+ SSLEngine on
+ SSLVerifyClient none
+ SSLCertificateFile %ssl_crt%
+ SSLCertificateKeyFile %ssl_key%
+ %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
+
+ Include %home%/%user%/conf/web/shttpd.%domain%.conf*
+
+
+
diff --git a/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl b/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl
index ce58bf2b8..6bad4c2a1 100755
--- a/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl
+++ b/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl
@@ -1,27 +1,28 @@
-
-
- ServerName %domain_idn%
- %alias_string%
- ServerAdmin %email%
- DocumentRoot %docroot%
- %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
- Alias /vstats/ %home%/%user%/web/%domain%/stats/
- Alias /error/ %home%/%user%/web/%domain%/document_errors/
- SuexecUserGroup %user% %group%
- CustomLog /var/log/httpd/domains/%domain%.bytes bytes
- CustomLog /var/log/httpd/domains/%domain%.log combined
- %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
-
- AllowOverride AuthConfig FileInfo Indexes Limit
- Options +Includes -Indexes %cgi_option%
- php_admin_flag engine off
- Action phpcgi-script /cgi-bin/php
- AddHandler phpcgi-script .php
-
-
- AllowOverride All
-
- Include %home%/%user%/conf/web/httpd.%domain%.conf*
-
-
-
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %docroot%
+ %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+ Alias /vstats/ %home%/%user%/web/%domain%/stats/
+ Alias /error/ %home%/%user%/web/%domain%/document_errors/
+ SuexecUserGroup %user% %group%
+ CustomLog /var/log/httpd/domains/%domain%.bytes bytes
+ CustomLog /var/log/httpd/domains/%domain%.log combined
+ %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
+
+ AllowOverride All
+ Options +Includes -Indexes +ExecCGI
+ Action phpcgi-script /cgi-bin/php
+
+ SetHandler phpcgi-script
+
+
+
+ AllowOverride All
+
+ Include %home%/%user%/conf/web/httpd.%domain%.conf*
+
+
+
diff --git a/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl b/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl
index 1fd9c8cdd..3f67a31d2 100755
--- a/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl
+++ b/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl
@@ -1,35 +1,36 @@
-
-
- ServerName %domain_idn%
- %alias_string%
- ServerAdmin %email%
- DocumentRoot %sdocroot%
- %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
- Alias /vstats/ %home%/%user%/web/%domain%/stats/
- Alias /error/ %home%/%user%/web/%domain%/document_errors/
- SuexecUserGroup %user% %group%
- CustomLog /var/log/httpd/domains/%domain%.bytes bytes
- CustomLog /var/log/httpd/domains/%domain%.log combined
- %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
-
- AllowOverride AuthConfig FileInfo Indexes Limit
- SSLRequireSSL
- Options +Includes -Indexes %cgi_option%
- php_admin_flag engine off
- AddHandler fcgid-script .php
- FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php
-
-
- AllowOverride All
-
- php_admin_value open_basedir none
- SSLEngine on
- SSLVerifyClient none
- SSLCertificateFile %ssl_crt%
- SSLCertificateKeyFile %ssl_key%
- %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
-
- Include %home%/%user%/conf/web/shttpd.%domain%.conf*
-
-
-
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %sdocroot%
+ %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+ Alias /vstats/ %home%/%user%/web/%domain%/stats/
+ Alias /error/ %home%/%user%/web/%domain%/document_errors/
+ SuexecUserGroup %user% %group%
+ CustomLog /var/log/httpd/domains/%domain%.bytes bytes
+ CustomLog /var/log/httpd/domains/%domain%.log combined
+ %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
+
+ SSLRequireSSL
+ AllowOverride All
+ Options +Includes -Indexes +ExecCGI
+
+ SetHandler fcgid-script
+
+ FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php
+
+
+ AllowOverride All
+
+ php_admin_value open_basedir none
+ SSLEngine on
+ SSLVerifyClient none
+ SSLCertificateFile %ssl_crt%
+ SSLCertificateKeyFile %ssl_key%
+ %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
+
+ Include %home%/%user%/conf/web/shttpd.%domain%.conf*
+
+
+
diff --git a/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl b/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl
index 2bca8ac76..1049a590d 100755
--- a/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl
+++ b/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl
@@ -1,27 +1,28 @@
-
-
- ServerName %domain_idn%
- %alias_string%
- ServerAdmin %email%
- DocumentRoot %docroot%
- %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
- Alias /vstats/ %home%/%user%/web/%domain%/stats/
- Alias /error/ %home%/%user%/web/%domain%/document_errors/
- SuexecUserGroup %user% %group%
- CustomLog /var/log/httpd/domains/%domain%.bytes bytes
- CustomLog /var/log/httpd/domains/%domain%.log combined
- %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
-
- AllowOverride AuthConfig FileInfo Indexes Limit
- Options +Includes -Indexes %cgi_option%
- php_admin_flag engine off
- AddHandler fcgid-script .php
- FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php
-
-
- AllowOverride All
-
- Include %home%/%user%/conf/web/httpd.%domain%.conf*
-
-
-
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %docroot%
+ %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+ Alias /vstats/ %home%/%user%/web/%domain%/stats/
+ Alias /error/ %home%/%user%/web/%domain%/document_errors/
+ SuexecUserGroup %user% %group%
+ CustomLog /var/log/httpd/domains/%domain%.bytes bytes
+ CustomLog /var/log/httpd/domains/%domain%.log combined
+ %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log
+
+ AllowOverride All
+ Options +Includes -Indexes +ExecCGI
+
+ SetHandler fcgid-script
+
+ FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php
+
+
+ AllowOverride All
+
+ Include %home%/%user%/conf/web/httpd.%domain%.conf*
+
+
+
diff --git a/install/vst-install.sh b/install/vst-install.sh
index 825400a09..2f678913a 100644
--- a/install/vst-install.sh
+++ b/install/vst-install.sh
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
#!/bin/bash
# Vesta installer
@@ -11,9 +10,9 @@ VERSION='0.9.7'
YUM_REPO='/etc/yum.repos.d/vesta.repo'
arch=$(uname -i)
-tools="screen mc libpng libjpeg curl curl libmcrypt libmcrypt mhash mhash
- freetype openssl flex libxml2 ImageMagick sqlite sqlite pcre pcre sudo bc
- mailx lsof ntp tar whois telnet rsync"
+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
@@ -41,6 +40,7 @@ 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"
@@ -52,6 +52,7 @@ 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="\""
@@ -61,8 +62,9 @@ done
eval set -- "$args"
# Getopt
-while getopts "hfe:" Option; do
+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
@@ -250,8 +252,12 @@ if [ -e '/root/.my.cnf' ]; then
mv -f /root/.my.cnf
fi
-# Vesta packages
-yum -y --enablerepo=remi install $rpms
+# 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
@@ -406,6 +412,9 @@ chmod 640 /var/log/httpd/error_log
chmod 640 /var/log/httpd/suexec.log
chmod 751 /var/log/httpd/domains
+# Enable short_open_tag in php config
+sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini
+
# Nginx
if [ -e '/etc/nginx/nginx.conf' ]; then
mv /etc/nginx/nginx.conf $vst_backups/nginx/
@@ -502,6 +511,8 @@ sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php
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"
@@ -537,7 +548,7 @@ $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"
+$VESTA/bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-sys-rrd'
$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
@@ -637,652 +648,3 @@ 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 834b21c07..1438f9531 100644
--- a/web/add/db/index.php
+++ b/web/add/db/index.php
@@ -1,93 +1,107 @@
- $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
+ $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 {
+ // 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/bulk/service/index.php b/web/bulk/service/index.php
new file mode 100644
index 000000000..36e771eb1
--- /dev/null
+++ b/web/bulk/service/index.php
@@ -0,0 +1,28 @@
+', $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
+', $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= '';
+ $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');
diff --git a/web/images/logo.png b/web/images/logo.png
index bbabeeede..19acb5a43 100644
Binary files a/web/images/logo.png and b/web/images/logo.png differ
diff --git a/web/images/start.png b/web/images/start.png
new file mode 100644
index 000000000..0f0016cba
Binary files /dev/null and b/web/images/start.png differ
diff --git a/web/images/stop.png b/web/images/stop.png
new file mode 100644
index 000000000..808e605b6
Binary files /dev/null and b/web/images/stop.png differ
diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php
index 9ff7dedcd..27092d937 100644
--- a/web/inc/i18n/ru.php
+++ b/web/inc/i18n/ru.php
@@ -17,6 +17,9 @@ $LANG = array(
'minute'=>'минута',
'hour'=>'час',
'day'=>'день',
+ 'days'=>'дня(ей)',
+ 'hours'=>'часа(ов)',
+ 'minutes'=>'минут(ы)',
'month'=>'месяц',
'day of week'=>'день недели',
'cmd'=>'командная строка',
diff --git a/web/inc/main.php b/web/inc/main.php
index 7f80a3279..4772250fd 100644
--- a/web/inc/main.php
+++ b/web/inc/main.php
@@ -1,159 +1,177 @@
-1) { $args[0] = $text;
- return call_user_func_array("sprintf",$args);
- }
- else return $text;
-}
-
-// Check user session
-if ((!isset($_SESSION['user'])) && (!isset($api_mode))&&!defined('NO_AUTH_REQUIRED')) {
- $_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
- header("Location: /login/");
- exit;
-}
-
-if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) {
- $user = $_SESSION['look'];
-} else {
- $user = $_SESSION['user'];
-}
-
-define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/');
-
-$i = 0;
-
-// Define functions
-function check_error($return_var){
- if ( $return_var > 0 ) {
- header("Location: /error/");
- exit;
- }
-}
-
-function top_panel($user, $TAB) {
- global $panel;
- $command = VESTA_CMD."v-list-user '".$user."' 'json'";
- exec ($command, $output, $return_var);
- if ( $return_var > 0 ) {
- header("Location: /error/");
- exit;
- }
- $panel = json_decode(implode('', $output), true);
- unset($output);
- if ( $user == 'admin' ) {
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html');
- } else {
- include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html');
- }
-}
-
-function humanize_time($usage) {
- if ( $usage > 60 ) {
- $usage = $usage / 60;
- $usage = number_format($usage, 2);
- $usage = $usage." Hour.";
- } else {
- $usage = $usage." Min.";
- }
- return $usage;
-}
-
-function humanize_usage($usage) {
- if ( $usage > 1000 ) {
- $usage = $usage / 1000;
- if ( $usage > 1000 ) {
- $usage = $usage / 1000 ;
- if ( $usage > 1000 ) {
- $usage = $usage / 1000 ;
- $usage = number_format($usage, 2);
- $usage = $usage." pb";
- } else {
- $usage = number_format($usage, 2);
- $usage = $usage." tb";
- }
- } else {
- $usage = number_format($usage, 2);
- $usage = $usage." gb";
- }
- } else {
- $usage = $usage." mb";
- }
- return $usage;
-}
-
-function get_percentage($used,$total) {
- if (!isset($total)) $total = 0;
- if (!isset($used)) $used = 0;
- if ( $total == 0 ) {
- $percent = 0;
- } else {
- $percent = $used / $total;
- $percent = $percent * 100;
- $percent = number_format($percent, 0, '', '');
- if ( $percent > 100 ) {
- $percent = 100;
- }
- if ( $percent < 0 ) {
- $percent = 0;
- }
-
- }
- return $percent;
-}
-
-function send_email($to,$subject,$mailtext,$from) {
- $charset = "utf-8";
- $to = '<'.$to.'>';
- $boundary = '--' . md5( uniqid("myboundary") );
- $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
- $priority = $priorities[2];
- $ctencoding = "8bit";
- $sep = chr(13) . chr(10);
- $disposition = "inline";
- $subject = "=?$charset?B?".base64_encode($subject)."?=";
- $header = "From: $from \nX-Priority: $priority\nCC:\n";
- $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n";
- $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n";
- $message = $mailtext;
- mail($to, $subject, $message, $header);
-}
-
-function display_error_block() {
- if (!empty($_SESSION['error_msg'])) {
- echo '
-
-
-
';
- echo $_SESSION['error_msg'];
- echo "
\n
\n";
- unset($_SESSION['error_msg']);
- }
-}
+1) { $args[0] = $text;
+ return call_user_func_array("sprintf",$args);
+ }
+ else return $text;
+}
+
+// Check user session
+if ((!isset($_SESSION['user'])) && (!isset($api_mode))&&!defined('NO_AUTH_REQUIRED')) {
+ $_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
+ header("Location: /login/");
+ exit;
+}
+
+if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) {
+ $user = $_SESSION['look'];
+} else {
+ $user = $_SESSION['user'];
+}
+
+define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/');
+
+$i = 0;
+
+// Define functions
+function check_error($return_var){
+ if ( $return_var > 0 ) {
+ header("Location: /error/");
+ exit;
+ }
+}
+
+function top_panel($user, $TAB) {
+ global $panel;
+ $command = VESTA_CMD."v-list-user '".$user."' 'json'";
+ exec ($command, $output, $return_var);
+ if ( $return_var > 0 ) {
+ header("Location: /error/");
+ exit;
+ }
+ $panel = json_decode(implode('', $output), true);
+ unset($output);
+ if ( $user == 'admin' ) {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html');
+ } else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html');
+ }
+}
+
+function humanize_time($usage) {
+ if ( $usage > 60 ) {
+ $usage = $usage / 60;
+ if ( $usage > 24 ) {
+ $usage = $usage / 24;
+ $usage = number_format($usage, 0);
+ if ( $usage == 1 ) {
+ $usage = $usage." "._('day');
+ } else {
+ $usage = $usage." "._('days');
+ }
+ } else {
+ $usage = number_format($usage, 0);
+ if ( $usage == 1 ) {
+ $usage = $usage." "._('hour');
+ } else {
+ $usage = $usage." "._('hours');
+ }
+ }
+ } else {
+ if ( $usage == 1 ) {
+ $usage = $usage." "._('minute');
+ } else {
+ $usage = $usage." "._('minutes');
+ }
+ }
+ return $usage;
+}
+
+function humanize_usage($usage) {
+ if ( $usage > 1000 ) {
+ $usage = $usage / 1000;
+ if ( $usage > 1000 ) {
+ $usage = $usage / 1000 ;
+ if ( $usage > 1000 ) {
+ $usage = $usage / 1000 ;
+ $usage = number_format($usage, 2);
+ $usage = $usage." "._('pb');
+ } else {
+ $usage = number_format($usage, 2);
+ $usage = $usage." "._('tb');
+ }
+ } else {
+ $usage = number_format($usage, 2);
+ $usage = $usage." "._('gb');
+ }
+ } else {
+ $usage = $usage." "._('mb');
+ }
+ return $usage;
+}
+
+function get_percentage($used,$total) {
+ if (!isset($total)) $total = 0;
+ if (!isset($used)) $used = 0;
+ if ( $total == 0 ) {
+ $percent = 0;
+ } else {
+ $percent = $used / $total;
+ $percent = $percent * 100;
+ $percent = number_format($percent, 0, '', '');
+ if ( $percent > 100 ) {
+ $percent = 100;
+ }
+ if ( $percent < 0 ) {
+ $percent = 0;
+ }
+
+ }
+ return $percent;
+}
+
+function send_email($to,$subject,$mailtext,$from) {
+ $charset = "utf-8";
+ $to = '<'.$to.'>';
+ $boundary = '--' . md5( uniqid("myboundary") );
+ $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
+ $priority = $priorities[2];
+ $ctencoding = "8bit";
+ $sep = chr(13) . chr(10);
+ $disposition = "inline";
+ $subject = "=?$charset?B?".base64_encode($subject)."?=";
+ $header = "From: $from \nX-Priority: $priority\nCC:\n";
+ $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n";
+ $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n";
+ $message = $mailtext;
+ mail($to, $subject, $message, $header);
+}
+
+function display_error_block() {
+ if (!empty($_SESSION['error_msg'])) {
+ echo '
+
+
+
';
+ echo $_SESSION['error_msg'];
+ echo "
\n
\n";
+ unset($_SESSION['error_msg']);
+ }
+}
?>
\ No newline at end of file
diff --git a/web/js/events.js b/web/js/events.js
index ccbf89abf..8749ac523 100644
--- a/web/js/events.js
+++ b/web/js/events.js
@@ -1,124 +1,124 @@
-// Init kinda namespace object
-var VE = { // Vesta Events object
- core: {}, // core functions
- callbacks: { // events callback functions
- click: {},
- mouseover: {},
- mouseout: {},
- keypress: {}
- },
- helpers: {}, // simple handy methods
- tmp: {}
-};
-
-/*
- * Main method that invokes further event processing
- * @param root is root HTML DOM element that. Pass HTML DOM Element or css selector
- * @param event_type (eg: click, mouseover etc..)
- */
-VE.core.register = function(root, event_type) {
- var root = !root ? 'body' : root; // if elm is not passed just bind events to body DOM Element
- var event_type = !event_type ? 'click' : event_type; // set event type to "click" by default
- $(root).bind(event_type, function(evt) {
- var elm = $(evt.target);
- VE.core.dispatch(evt, elm, event_type); // dispatch captured event
- });
-}
-
-/*
- * Dispatch event that was previously registered
- * @param evt related event object
- * @param elm that was catched
- * @param event_type (eg: click, mouseover etc..)
- */
-VE.core.dispatch = function(evt, elm, event_type) {
- if ('undefined' == typeof VE.callbacks[event_type]) {
- return VE.helpers.warn('There is no corresponding object that should contain event callbacks for "'+event_type+'" event type');
- }
- // get class of element
- var classes = $(elm).attr('class');
- // if no classes are attached, then just stop any further processings
- if (!classes) {
- return; // no classes assigned
- }
- // split the classes and check if it related to function
- $(classes.split(/\s/)).each(function(i, key) {
- VE.callbacks[event_type][key] && VE.callbacks[event_type][key](evt, elm);
- });
-}
-
-//
-// CALLBACKS
-//
-
-
-
-/*
- * Suspend action
- */
-VE.callbacks.click.do_suspend = function(evt, elm) {
- var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
- var url = $('input[name="suspend_url"]', ref).val();
- var dialog_elm = ref.find('.confirmation-text-suspention');
- VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm SUSPEND', url);
-}
-
-/*
- * Unsuspend action
- */
-VE.callbacks.click.do_unsuspend = function(evt, elm) {
- var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
- var url = $('input[name="unsuspend_url"]', ref).val();
- var dialog_elm = ref.find('.confirmation-text-suspention');
- VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm UNSUSPEND', url);
-}
-
-/*
- * Delete action
- */
-VE.callbacks.click.do_delete = function(evt, elm) {
- var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
- var url = $('input[name="delete_url"]', ref).val();
- var dialog_elm = ref.find('.confirmation-text-delete');
- VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm DELETE', url);
-}
-
-
-/*
- * Create dialog box on the fly
- * @param elm Element which contains the dialog contents
- * @param dialog_title
- * @param confirmed_location_url URL that will be redirected to if user hit "OK"
- * @param custom_config Custom configuration parameters passed to dialog initialization (optional)
- */
-VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_location_url, custom_config) {
- var custom_config = !custom_config ? {} : custom_config;
- var config = {
- modal: true,
- autoOpen: true,
- width: 360,
- title: dialog_title,
- close: function() {
- $(this).dialog("destroy");
- },
- buttons: {
- "Ok": function(event, ui) {
- location.href = confirmed_location_url;
- },
- "Cancel": function() {
- $(this).dialog("close");
- $(this).dialog("destroy");
- }
- }
- }
- config = $.extend(config, custom_config);
- var reference_copied = $(elm).clone();
- $(reference_copied).dialog(config);
-}
-
-/*
- * Simple debug output
- */
-VE.helpers.warn = function(msg) {
- alert('WARNING: ' + msg);
-}
+// Init kinda namespace object
+var VE = { // Vesta Events object
+ core: {}, // core functions
+ callbacks: { // events callback functions
+ click: {},
+ mouseover: {},
+ mouseout: {},
+ keypress: {}
+ },
+ helpers: {}, // simple handy methods
+ tmp: {}
+};
+
+/*
+ * Main method that invokes further event processing
+ * @param root is root HTML DOM element that. Pass HTML DOM Element or css selector
+ * @param event_type (eg: click, mouseover etc..)
+ */
+VE.core.register = function(root, event_type) {
+ var root = !root ? 'body' : root; // if elm is not passed just bind events to body DOM Element
+ var event_type = !event_type ? 'click' : event_type; // set event type to "click" by default
+ $(root).bind(event_type, function(evt) {
+ var elm = $(evt.target);
+ VE.core.dispatch(evt, elm, event_type); // dispatch captured event
+ });
+}
+
+/*
+ * Dispatch event that was previously registered
+ * @param evt related event object
+ * @param elm that was catched
+ * @param event_type (eg: click, mouseover etc..)
+ */
+VE.core.dispatch = function(evt, elm, event_type) {
+ if ('undefined' == typeof VE.callbacks[event_type]) {
+ return VE.helpers.warn('There is no corresponding object that should contain event callbacks for "'+event_type+'" event type');
+ }
+ // get class of element
+ var classes = $(elm).attr('class');
+ // if no classes are attached, then just stop any further processings
+ if (!classes) {
+ return; // no classes assigned
+ }
+ // split the classes and check if it related to function
+ $(classes.split(/\s/)).each(function(i, key) {
+ VE.callbacks[event_type][key] && VE.callbacks[event_type][key](evt, elm);
+ });
+}
+
+//
+// CALLBACKS
+//
+
+
+
+/*
+ * Suspend action
+ */
+VE.callbacks.click.do_suspend = function(evt, elm) {
+ var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
+ var url = $('input[name="suspend_url"]', ref).val();
+ var dialog_elm = ref.find('.confirmation-text-suspention');
+ VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
+}
+
+/*
+ * Unsuspend action
+ */
+VE.callbacks.click.do_unsuspend = function(evt, elm) {
+ var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
+ var url = $('input[name="unsuspend_url"]', ref).val();
+ var dialog_elm = ref.find('.confirmation-text-suspention');
+ VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
+}
+
+/*
+ * Delete action
+ */
+VE.callbacks.click.do_delete = function(evt, elm) {
+ var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls');
+ var url = $('input[name="delete_url"]', ref).val();
+ var dialog_elm = ref.find('.confirmation-text-delete');
+ VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url);
+}
+
+
+/*
+ * Create dialog box on the fly
+ * @param elm Element which contains the dialog contents
+ * @param dialog_title
+ * @param confirmed_location_url URL that will be redirected to if user hit "OK"
+ * @param custom_config Custom configuration parameters passed to dialog initialization (optional)
+ */
+VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_location_url, custom_config) {
+ var custom_config = !custom_config ? {} : custom_config;
+ var config = {
+ modal: true,
+ autoOpen: true,
+ width: 360,
+ title: dialog_title,
+ close: function() {
+ $(this).dialog("destroy");
+ },
+ buttons: {
+ "Ok": function(event, ui) {
+ location.href = confirmed_location_url;
+ },
+ "Cancel": function() {
+ $(this).dialog("close");
+ $(this).dialog("destroy");
+ }
+ }
+ }
+ config = $.extend(config, custom_config);
+ var reference_copied = $(elm).clone();
+ $(reference_copied).dialog(config);
+}
+
+/*
+ * Simple debug output
+ */
+VE.helpers.warn = function(msg) {
+ alert('WARNING: ' + msg);
+}
diff --git a/web/list/log/index.php b/web/list/log/index.php
index e76e49d7e..1094cba14 100644
--- a/web/list/log/index.php
+++ b/web/list/log/index.php
@@ -1,25 +1,24 @@
-', $output);
+ if (empty($error)) $error = 'Error: service '.$v_service.' restart failed';
+ $_SESSION['error_srv'] = $error;
+ }
+ unset($output);
+}
+
+header("Location: /list/services/");
+exit;
diff --git a/web/start/service/index.php b/web/start/service/index.php
new file mode 100644
index 000000000..ff8589a1d
--- /dev/null
+++ b/web/start/service/index.php
@@ -0,0 +1,22 @@
+', $output);
+ if (empty($error)) $error = 'Error: service '.$v_service.' start failed';
+ $_SESSION['error_srv'] = $error;
+ }
+ unset($output);
+}
+
+header("Location: /list/services/");
+exit;
diff --git a/web/stop/service/index.php b/web/stop/service/index.php
new file mode 100644
index 000000000..f2310ae71
--- /dev/null
+++ b/web/stop/service/index.php
@@ -0,0 +1,22 @@
+', $output);
+ if (empty($error)) $error = 'Error: service '.$v_service.' stop failed';
+ $_SESSION['error_srv'] = $error;
+ }
+ unset($output);
+}
+
+header("Location: /list/services/");
+exit;
diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html
index 35aecc0a4..9ffd78438 100644
--- a/web/templates/admin/add_db.html
+++ b/web/templates/admin/add_db.html
@@ -1,184 +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 143b293db..9ce629e65 100644
--- a/web/templates/admin/list_dns.html
+++ b/web/templates/admin/list_dns.html
@@ -1,146 +1,146 @@
-
-
-
-
-
-
\ 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 eda5e6615..a4ea4a553 100644
--- a/web/templates/admin/list_dns_rec.html
+++ b/web/templates/admin/list_dns_rec.html
@@ -1,115 +1,115 @@
-
-
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend' ;
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend' ;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html
index e12738baf..9b38dd9c5 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';
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+ $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';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html
index 4632ffb29..999b1c821 100644
--- a/web/templates/admin/list_mail_acc.html
+++ b/web/templates/admin/list_mail_acc.html
@@ -1,162 +1,162 @@
-
-
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- if ($data[$key]['SUSPENDED'] == 'yes') {
- $status = 'suspended';
- $spnd_action = 'unsuspend' ;
- } else {
- $status = 'active';
- $spnd_action = 'suspend';
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['SUSPENDED'] == 'yes') {
+ $status = 'suspended';
+ $spnd_action = 'unsuspend' ;
+ } else {
+ $status = 'active';
+ $spnd_action = 'suspend';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html
index df604a20e..e5b7673bf 100644
--- a/web/templates/admin/list_rrd.html
+++ b/web/templates/admin/list_rrd.html
@@ -1,72 +1,72 @@
-
-
-
-
-
-
-
-
- $value) {
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ $value) {
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/templates/admin/list_services.html b/web/templates/admin/list_services.html
new file mode 100644
index 000000000..1834a58d9
--- /dev/null
+++ b/web/templates/admin/list_services.html
@@ -0,0 +1,152 @@
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ if ($data[$key]['STATE'] == 'running') {
+ $status = 'active';
+ $action = 'stop';
+ } else {
+ $status = 'suspended';
+ $action = 'start';
+ }
+
+ $cpu = $data[$key]['CPU'] / 10;
+ $cpu = number_format($cpu, 1);
+ if ($cpu == '0.0') $cpu = 0;
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Memory:
+
+
+ mb
+
+
+
+
+
+
+
+
+ Run Time:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html
index 59a7f1d4b..f8325fc89 100644
--- a/web/templates/admin/list_stats.html
+++ b/web/templates/admin/list_stats.html
@@ -1,221 +1,221 @@
-
-
-
-
-
-
-
-
-
- $value) {
- ++$i;
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- []
-
-
-
-
- : % ()
-
-
-
-
-
- : % ()
-
-
-
-
-
-
-
-
- :
- :
-
-
- :
- :
-
-
-
-
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
- :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ $value) {
+ ++$i;
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ []
+
+
+
+
+ : % ()
+
+
+
+
+
+ : % ()
+
+
+
+
+
+
+
+
+ :
+ :
+
+
+ :
+ :
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html
index b81fd01da..498344688 100644
--- a/web/templates/admin/panel.html
+++ b/web/templates/admin/panel.html
@@ -1,112 +1,112 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
diff --git a/web/templates/footer.html b/web/templates/footer.html
index 8670dd3cb..8fd521c91 100644
--- a/web/templates/footer.html
+++ b/web/templates/footer.html
@@ -1,12 +1,4 @@
-
@@ -16,7 +8,7 @@
VE.core.register($('.main'));
});
-
+