diff --git a/bin/v_add_dns_domain b/bin/v_add_dns_domain
index 3ba05d1f..08d65d2d 100755
--- a/bin/v_add_dns_domain
+++ b/bin/v_add_dns_domain
@@ -19,7 +19,7 @@ domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
-template=${4-default}
+template=$4
next_year=$(date +%F -d "+ 1 year")
exp=${5-$next_year}
soa=$6
@@ -36,13 +36,19 @@ source $VESTA/func/domain.sh
#----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]'
-validate_format 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
+validate_format 'user' 'domain' 'ip' 'exp' 'ttl'
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'dns'
is_package_full 'DNS_DOMAINS'
-is_dns_template_valid
+if [ ! -z "$template" ]; then
+ validate_format 'template'
+ is_dns_template_valid
+else
+ template=$(get_user_value '$TEMPLATE')
+ is_dns_template_valid
+fi
#----------------------------------------------------------#
diff --git a/bin/v_add_web_domain b/bin/v_add_web_domain
index 432e0257..d6dd98df 100755
--- a/bin/v_add_web_domain
+++ b/bin/v_add_web_domain
@@ -20,7 +20,7 @@ domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
-template=${4-default}
+template=$4
restart=$5
# Includes
@@ -35,7 +35,7 @@ source $VESTA/func/ip.sh
#----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [template] [restart]'
-validate_format 'user' 'domain' 'ip' 'template'
+validate_format 'user' 'domain' 'ip'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@@ -43,7 +43,13 @@ is_domain_new 'web'
is_ip_valid
is_ip_avalable
is_package_full 'WEB_DOMAINS'
-is_apache_template_valid
+if [ ! -z "$template" ]; then
+ validate_format 'template'
+ is_apache_template_valid
+else
+ template=$(get_user_value '$TEMPLATE')
+ is_apache_template_valid
+fi
#----------------------------------------------------------#
@@ -74,28 +80,9 @@ email="$user@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl"
-
-# Parsing template keys
-template_data=$(cat $WEBTPL/apache_$template.descr|grep -v '#')
-for keys in $template_data; do
- eval ${keys%%=*}=${keys#*=}
-done
-
-# Checking error log status
-if [ "$ELOG" = 'no' ]; then
- elog='#'
-else
- elog=''
-fi
-
-# Checking cgi
-if [ "$CGI" != 'yes' ]; then
- cgi='#'
- cgi_option='-ExecCGI'
-else
- cgi=''
- cgi_option='+ExecCGI'
-fi
+elog=''
+cgi=''
+cgi_option='+ExecCGI'
# Adding domain to the httpd.conf
add_web_config
@@ -181,9 +168,9 @@ increase_user_value "$user" '$U_WEB_ALIASES'
# Defining domain variables
str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'"
-str="$str $template_data SSL='no' SSL_HOME='single' NGINX='' NGINX_EXT=''"
-str="$str STATS='' STATS_USER='' STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0'"
-str="$str SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
+str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='single' NGINX=''"
+str="$str NGINX_EXT='' STATS='' STATS_USER='' STATS_CRYPT='' U_DISK='0'"
+str="$str U_BANDWIDTH='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
# Registering domain
echo "$str" >> $USER_DATA/web.conf
diff --git a/bin/v_add_web_domain_alias b/bin/v_add_web_domain_alias
index 5a5c695a..a778416f 100755
--- a/bin/v_add_web_domain_alias
+++ b/bin/v_add_web_domain_alias
@@ -73,13 +73,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/bin/v_add_web_domain_elog b/bin/v_add_web_domain_elog
index d1a72f73..1ae44fe3 100755
--- a/bin/v_add_web_domain_elog
+++ b/bin/v_add_web_domain_elog
@@ -66,13 +66,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/bin/v_add_web_domain_nginx b/bin/v_add_web_domain_nginx
index df4ad367..f96b8c09 100755
--- a/bin/v_add_web_domain_nginx
+++ b/bin/v_add_web_domain_nginx
@@ -14,7 +14,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
-template=${3-default}
+template=$3
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
extentions=${4-$default_extentions}
@@ -31,14 +31,20 @@ source $VESTA/func/domain.sh
#----------------------------------------------------------#
check_args '2' "$#" 'user domain [template] [extentions] [restart]'
-validate_format 'user' 'domain' 'template' 'extentions'
+validate_format 'user' 'domain' 'extentions'
is_system_enabled "$PROXY_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"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX'
-is_nginx_template_valid
+if [ ! -z "$template" ]; then
+ validate_format 'template'
+ is_nginx_template_valid
+else
+ template=$(get_user_value '$TEMPLATE')
+ is_nginx_template_valid
+fi
#----------------------------------------------------------#
@@ -49,7 +55,7 @@ is_nginx_template_valid
get_domain_values 'web'
NGINX="$template"
NGINX_EXT="$extentions"
-tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Preparing domain values for the template substitution
@@ -69,7 +75,7 @@ fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config
diff --git a/bin/v_add_web_domain_ssl b/bin/v_add_web_domain_ssl
index b42ae06c..4be41a40 100755
--- a/bin/v_add_web_domain_ssl
+++ b/bin/v_add_web_domain_ssl
@@ -98,7 +98,7 @@ fi
if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf
conf="$HOMEDIR/$user/conf/web/snginx.conf"
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
add_web_config
chown root:nginx $conf
diff --git a/bin/v_backup_user b/bin/v_backup_user
index 1593d3b9..a0f4b995 100755
--- a/bin/v_backup_user
+++ b/bin/v_backup_user
@@ -163,14 +163,14 @@ then
# Nginx config
if [ ! -z "$NGINX" ] ; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
# SSL check
if [ "$SSL" = 'yes' ] ; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf
diff --git a/bin/v_change_user_package b/bin/v_change_user_package
index e83e6b90..d21bf586 100755
--- a/bin/v_change_user_package
+++ b/bin/v_change_user_package
@@ -59,9 +59,9 @@ change_user_package() {
echo "FNAME='$FNAME'
LNAME='$LNAME'
PACKAGE='$package'
+TEMPLATE='$TEMPLATE'
WEB_DOMAINS='$WEB_DOMAINS'
WEB_ALIASES='$WEB_ALIASES'
-WEB_TPL='$WEB_TPL'
DNS_DOMAINS='$DNS_DOMAINS'
DNS_RECORDS='$DNS_RECORDS'
MAIL_DOMAINS='$MAIL_DOMAINS'
diff --git a/bin/v_change_user_template b/bin/v_change_user_template
new file mode 100755
index 00000000..2bf96080
--- /dev/null
+++ b/bin/v_change_user_template
@@ -0,0 +1,48 @@
+#!/bin/bash
+# info: change user default template
+# options: user template
+#
+# The function changes default user web template.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+template=$2
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'user template'
+validate_format 'user' 'template'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_apache_template_valid
+
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Changing user shell
+update_user_value "$user" '$TEMPLATE' "$template"
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit
diff --git a/bin/v_change_web_domain_ip b/bin/v_change_web_domain_ip
index 6b56cd56..059724fe 100755
--- a/bin/v_change_web_domain_ip
+++ b/bin/v_change_web_domain_ip
@@ -60,14 +60,14 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
replace_web_config
fi
# Checking nginx
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config
fi
diff --git a/bin/v_change_web_domain_nginx_tpl b/bin/v_change_web_domain_nginx_tpl
index 0764c28b..47282c7f 100755
--- a/bin/v_change_web_domain_nginx_tpl
+++ b/bin/v_change_web_domain_nginx_tpl
@@ -48,7 +48,7 @@ is_nginx_template_valid
# Parsing domain values
get_domain_values 'web'
-tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Delete old vhost
@@ -56,7 +56,7 @@ del_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
@@ -64,7 +64,7 @@ fi
# Add new vhost
NGINX="$template"
NGINX_EXT="$extentions"
-tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
upd_web_domain_values
add_web_config
@@ -73,7 +73,7 @@ chmod 640 $conf
# Checking ssl
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config
chown root:nginx $conf
diff --git a/bin/v_change_web_domain_sslhome b/bin/v_change_web_domain_sslhome
index e68908c7..0808778f 100755
--- a/bin/v_change_web_domain_sslhome
+++ b/bin/v_change_web_domain_sslhome
@@ -56,7 +56,7 @@ replace_web_config
# Checking nginx config
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web//snginx.conf"
replace_web_config
fi
diff --git a/bin/v_change_web_domain_tpl b/bin/v_change_web_domain_tpl
index 8c9be97c..b303ba9b 100755
--- a/bin/v_change_web_domain_tpl
+++ b/bin/v_change_web_domain_tpl
@@ -61,12 +61,6 @@ fi
upd_web_domain_values
tpl_file="$WEBTPL/apache_$template.tpl"
-# Parsing new template
-template_data=$(cat $WEBTPL/apache_$template.descr | grep -v '#')
-for keys in $template_data; do
- eval ${keys%%=*}=${keys#*=}
-done
-
# Checking error log
if [ "$ELOG" = 'no' ]; then
elog='#'
@@ -104,13 +98,6 @@ fi
# Changing tpl in config
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
-# Updating db keys
-for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
- key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g")
- value=$(echo "$keys" |cut -f 2 -d \')
- update_object_value 'web' 'DOMAIN' "$domain" "$key" "$value"
-done
-
# Restart web
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
diff --git a/bin/v_delete_web_domain b/bin/v_delete_web_domain
index 2e80932e..ba481881 100755
--- a/bin/v_delete_web_domain
+++ b/bin/v_delete_web_domain
@@ -70,12 +70,12 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
diff --git a/bin/v_delete_web_domain_alias b/bin/v_delete_web_domain_alias
index fe18ffe2..57160800 100755
--- a/bin/v_delete_web_domain_alias
+++ b/bin/v_delete_web_domain_alias
@@ -72,13 +72,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/bin/v_delete_web_domain_elog b/bin/v_delete_web_domain_elog
index 48b89d47..341a8496 100755
--- a/bin/v_delete_web_domain_elog
+++ b/bin/v_delete_web_domain_elog
@@ -64,13 +64,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/bin/v_delete_web_domain_nginx b/bin/v_delete_web_domain_nginx
index c4122ac6..1a8b2da4 100755
--- a/bin/v_delete_web_domain_nginx
+++ b/bin/v_delete_web_domain_nginx
@@ -41,13 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
# Defining domain parameters
get_domain_values 'web'
-tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
diff --git a/bin/v_delete_web_domain_ssl b/bin/v_delete_web_domain_ssl
index 78df805b..31dc8277 100755
--- a/bin/v_delete_web_domain_ssl
+++ b/bin/v_delete_web_domain_ssl
@@ -49,7 +49,7 @@ del_web_config
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
diff --git a/bin/v_list_dns_templates b/bin/v_list_dns_templates
index 895614c7..a837fc44 100755
--- a/bin/v_list_dns_templates
+++ b/bin/v_list_dns_templates
@@ -17,36 +17,30 @@ source $VESTA/func/main.sh
# Json function
json_list_dnstpl() {
- echo '{'
- for template in $(ls $DNSTPL/| grep '.descr'); do
- if [ -n "$data" ]; then
- echo -e ' },'
+ templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.')
+ t_counter=$(echo "$templates" | wc -w)
+ i=1
+ echo '['
+ for template in $templates; do
+ if [ "$i" -lt "$t_counter" ]; then
+ echo -e "\t\"$template\","
+ else
+ echo -e "\t\"$template\""
fi
- tpl_descr=$(cat $DNSTPL/$template |grep '#'|tr -d '\n')
- tpl_name="${template//.descr/}"
- echo -e "\t\"$tpl_name\": {"
- echo -e "\t\t\"DESCR\": \"${tpl_descr//# /}\""
- data=1
+ (( ++i))
done
- if [ -n "$data" ]; then
- echo -e ' }'
- fi
- echo -e '}'
+ echo "]"
}
# Shell function
shell_list_dnstpl() {
- for template in $(ls $DNSTPL/| grep '.descr'); do
- tpl_name="${template//.descr/}"
- tpl_descr=$(cat $DNSTPL/$template |grep '#')
- if [ -z "$nohead" ] ; then
- echo "----------"
- fi
- echo "TEMPLATE: $tpl_name"
- echo "DESCRIPTION: ${tpl_descr//# /}"
- if [ -z "$nohead" ] ; then
- echo
- fi
+ templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.')
+ if [ -z "$nohead" ]; then
+ echo "Templates"
+ echo "----------"
+ fi
+ for template in $templates; do
+ echo "$template"
done
}
diff --git a/bin/v_list_user b/bin/v_list_user
index c808d6a8..3b56d380 100755
--- a/bin/v_list_user
+++ b/bin/v_list_user
@@ -72,7 +72,7 @@ is_object_valid 'user' 'USER' "$user"
conf=$USER_DATA/user.conf
# Defining fileds to select
-fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_ALIASES $WEB_TPL
+fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES
$DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES
$CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT
$CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB
diff --git a/bin/v_list_user_packages b/bin/v_list_user_packages
index 3c6e7201..20370068 100755
--- a/bin/v_list_user_packages
+++ b/bin/v_list_user_packages
@@ -71,9 +71,9 @@ shell_list_pkgs() {
#----------------------------------------------------------#
# Defining fields
-fields='$PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES $MAIL_DOMAINS
- $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA $BANDWIDTH $NS
- $SHELL $BACKUPS $WEB_TPL'
+fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES
+ $MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA
+ $BANDWIDTH $NS $SHELL $BACKUPS'
# Listing domains
case $format in
diff --git a/bin/v_list_users b/bin/v_list_users
index ea29cea6..1aa67ea6 100755
--- a/bin/v_list_users
+++ b/bin/v_list_users
@@ -73,17 +73,18 @@ shell_list_users() {
#----------------------------------------------------------#
# Defining fileds to select
-fields="\$USER \$FNAME \$LNAME \$PACKAGE \$WEB_DOMAINS \$WEB_ALIASES \$WEB_TPL"
-fields="$fields \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS \$MAIL_ACCOUNTS"
-fields="$fields \$DATABASES \$CRON_JOBS \$DISK_QUOTA \$BANDWIDTH \$NS \$SHELL"
-fields="$fields \$BACKUPS \$CONTACT \$CRON_REPORTS \$RKEY \$SUSPENDED"
-fields="$fields \$SUSPENDED_USERS \$SUSPENDED_WEB \$SUSPENDED_DNS"
-fields="$fields \$SUSPENDED_MAIL \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL"
-fields="$fields \$IP_OWNED \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB"
-fields="$fields \$U_DISK_MAIL \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS"
-fields="$fields \$U_WEB_SSL \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS"
-fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS \$U_DATABASES"
-fields="$fields \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE"
+fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS"
+fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS"
+fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA"
+fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT"
+fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS"
+fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL"
+fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED"
+fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL"
+fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL"
+fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS"
+fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS"
+fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE"
# Listing domains
case $format in
diff --git a/bin/v_list_web_domain b/bin/v_list_web_domain
index e1b806bc..5d085d77 100755
--- a/bin/v_list_web_domain
+++ b/bin/v_list_web_domain
@@ -75,8 +75,8 @@ is_object_valid 'web' 'DOMAIN' "$domain"
conf=$USER_DATA/web.conf
# Defining fileds to select
-fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG
- $STATS $STATS_USER $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE'
+fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS
+ $STATS_USER $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE'
# Listing domains
case $format in
diff --git a/bin/v_list_web_domains b/bin/v_list_web_domains
index c6deaf93..cec97383 100755
--- a/bin/v_list_web_domains
+++ b/bin/v_list_web_domains
@@ -34,7 +34,7 @@ is_object_valid 'user' 'USER' "$user"
conf=$USER_DATA/web.conf
# Defining fileds to select
-fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI"
+fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI"
fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$NGINX"
fields="$fields \$NGINX_EXT \$SUSPENDED \$TIME \$DATE"
diff --git a/bin/v_list_web_templates b/bin/v_list_web_templates
index 4e199fb0..f3009dc3 100755
--- a/bin/v_list_web_templates
+++ b/bin/v_list_web_templates
@@ -10,65 +10,48 @@
#----------------------------------------------------------#
# Argument defenition
-user=$1
-format=${2-shell}
+format=${1-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_wtpl() {
+ templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
+ |cut -f 1 -d '.')
+ t_counter=$(echo "$templates" | wc -w)
i=1
- echo '{'
- for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
- if [ -e "$WEBTPL/apache_$template.descr" ]; then
- descr=$(cat $WEBTPL/apache_$template.descr | grep '#'|\
- sed -e ':a;N;$!ba;s/\n/ /g')
- if [ $i -ne 1 ]; then
- echo -e "\t},"
- fi
- echo -e "\t\"$template\": {"
- echo -e "\t\t\"DESCR\": \"${descr//# /}\""
- (( ++i))
+ echo '['
+ for template in $templates; do
+ if [ "$i" -lt "$t_counter" ]; then
+ echo -e "\t\"$template\","
+ else
+ echo -e "\t\"$template\""
fi
+ (( ++i))
done
- if [ -n "$template" ]; then
- echo -e "\t}"
- fi
- echo '}'
+ echo "]"
}
# Shell function
shell_list_wtpl() {
- for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
- if [ -e "$WEBTPL/apache_$template.descr" ]; then
- tpl_descr=$(cat $WEBTPL/apache_$template.descr |grep '#')
- if [ -z "$nohead" ]; then
- echo "----------"
- fi
- echo "TEMPLATE: $template"
- echo "DESCRIPTION: ${tpl_descr//# /}"
- fi
+ templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
+ |cut -f 1 -d '.')
+ if [ -z "$nohead" ]; then
+ echo "Templates"
+ echo "----------"
+ fi
+ for template in $templates; do
+ echo "$template"
done
}
-#----------------------------------------------------------#
-# Verifications #
-#----------------------------------------------------------#
-
-check_args '1' "$#" 'user'
-validate_format 'user'
-is_object_valid 'user' 'USER' "$user"
-
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
-# Get user package package
-templates=$(get_user_value '$WEB_TPL')
-
# Listing domains
case $format in
json) json_list_wtpl ;;
diff --git a/bin/v_list_web_templates_nginx b/bin/v_list_web_templates_nginx
index 2b0d68c3..aa4993dd 100755
--- a/bin/v_list_web_templates_nginx
+++ b/bin/v_list_web_templates_nginx
@@ -1,6 +1,6 @@
#!/bin/bash
# info: listing nginx templates
-# options: user [format]
+# options: [format]
#
# The function for obtaining the list of nginx templates available to a user.
@@ -10,66 +10,47 @@
#----------------------------------------------------------#
# Argument defenition
-user=$1
-format=${2-shell}
+format=${1-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_wtpl() {
- i='1' # iterator
- echo '{'
- for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
- if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
- descr=$(cat $WEBTPL/ngingx_$template.descr | grep '#'|\
- sed -e ':a;N;$!ba;s/\n/ /g')
- if [ $i -ne 1 ]; then
- echo -e "\t},"
- fi
- echo -e "\t\"$template\": {"
- echo -e "\t\t\"DESCR\": \"${descr//# /}\""
- (( ++i))
+ templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
+ |cut -f 1 -d '.')
+ t_counter=$(echo "$templates" | wc -w)
+ i=1
+ echo '['
+ for template in $templates; do
+ if [ "$i" -lt "$t_counter" ]; then
+ echo -e "\t\"$template\","
+ else
+ echo -e "\t\"$template\""
fi
+ (( ++i))
done
-
- if [ -n "$template" ]; then
- echo -e "\t}"
- fi
- echo '}'
+ echo "]"
}
# Shell function
shell_list_wtpl() {
- for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
- if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
- tpl_descr=$(cat $WEBTPL/ngingx_$template.descr |grep '#')
- if [ -z "$nohead" ]; then
- echo "----------"
- fi
- echo "TEMPLATE: $template"
- echo "DESCRIPTION: ${tpl_descr//# /}"
- fi
+ templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
+ |cut -f 1 -d '.')
+ if [ -z "$nohead" ]; then
+ echo "Templates"
+ echo "----------"
+ fi
+ for template in $templates; do
+ echo "$template"
done
}
-#----------------------------------------------------------#
-# Verifications #
-#----------------------------------------------------------#
-
-check_args '1' "$#" 'user'
-validate_format 'user'
-is_object_valid 'user' 'USER' "$user"
-
-
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
-# Get user package package
-templates=$(get_user_value '$WEB_TPL')
-
# Listing domains
case $format in
json) json_list_wtpl ;;
diff --git a/bin/v_rebuild_web_domains b/bin/v_rebuild_web_domains
index cc23726f..315cdee9 100755
--- a/bin/v_rebuild_web_domains
+++ b/bin/v_rebuild_web_domains
@@ -185,14 +185,14 @@ for domain in $(shell_list) ; do
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ 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/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
add_web_config
chown root:nginx $conf
diff --git a/bin/v_suspend_web_domain b/bin/v_suspend_web_domain
index 49b8c21d..7953e2c9 100755
--- a/bin/v_suspend_web_domain
+++ b/bin/v_suspend_web_domain
@@ -63,13 +63,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/bin/v_unsuspend_web_domain b/bin/v_unsuspend_web_domain
index 98c83bac..4f2a3882 100755
--- a/bin/v_unsuspend_web_domain
+++ b/bin/v_unsuspend_web_domain
@@ -60,13 +60,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
- tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
+ tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
diff --git a/data/packages/default.pkg b/data/packages/default.pkg
index d89deafe..0399cabe 100644
--- a/data/packages/default.pkg
+++ b/data/packages/default.pkg
@@ -1,6 +1,6 @@
+TEMPLATE='default'
WEB_DOMAINS='100'
WEB_ALIASES='100'
-WEB_TPL='default,phpfcgid,unlim'
DNS_DOMAINS='100'
DNS_RECORDS='100'
MAIL_DOMAINS='100'
diff --git a/data/packages/gainsboro.pkg b/data/packages/gainsboro.pkg
index 6318f871..4529b9cc 100644
--- a/data/packages/gainsboro.pkg
+++ b/data/packages/gainsboro.pkg
@@ -1,6 +1,6 @@
+TEMPLATE='default'
WEB_DOMAINS='10'
WEB_ALIASES='10'
-WEB_TPL='default'
DNS_DOMAINS='10'
DNS_RECORDS='10'
MAIL_DOMAINS='10'
diff --git a/data/packages/palegreen.pkg b/data/packages/palegreen.pkg
index 5a100dfe..7c3200ca 100644
--- a/data/packages/palegreen.pkg
+++ b/data/packages/palegreen.pkg
@@ -1,6 +1,6 @@
+TEMPLATE='unlim'
WEB_DOMAINS='50'
WEB_ALIASES='50'
-WEB_TPL='default'
DNS_DOMAINS='50'
DNS_RECORDS='50'
MAIL_DOMAINS='50'
diff --git a/data/packages/slategrey.pkg b/data/packages/slategrey.pkg
new file mode 100644
index 00000000..0399cabe
--- /dev/null
+++ b/data/packages/slategrey.pkg
@@ -0,0 +1,14 @@
+TEMPLATE='default'
+WEB_DOMAINS='100'
+WEB_ALIASES='100'
+DNS_DOMAINS='100'
+DNS_RECORDS='100'
+MAIL_DOMAINS='100'
+MAIL_ACCOUNTS='100'
+DATABASES='100'
+CRON_JOBS='100'
+DISK_QUOTA='10000'
+BANDWIDTH='100000'
+NS='ns1.localhost,ns2.localhost'
+SHELL='nologin'
+BACKUPS='3'
diff --git a/data/templates/web/nginx_default.stpl b/data/templates/web/nginx_default.stpl
new file mode 100755
index 00000000..2af43134
--- /dev/null
+++ b/data/templates/web/nginx_default.stpl
@@ -0,0 +1,36 @@
+server {
+ listen %ip%:%proxy_ssl_port%;
+ server_name %domain_idn% %alias_idn%;
+ ssl on;
+ ssl_certificate %ssl_pem%;
+ ssl_certificate_key %ssl_key%;
+ %elog%error_log /var/log/httpd/domains/%domain%.error.log error;
+
+ location / {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ location ~* ^.+\.(%nginx_extentions%)$ {
+ root %sdocroot%;
+ access_log /var/log/httpd/domains/%domain%.log combined;
+ access_log /var/log/httpd/domains/%domain%.bytes bytes;
+ expires max;
+ try_files $uri @fallback;
+ }
+ }
+
+ location /error/ {
+ alias %home%/%user%/web/%domain%/document_errors/;
+ }
+
+ location @fallback {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ }
+
+ location ~ /\.ht {return 404;}
+ location ~ /\.svn/ {return 404;}
+ location ~ /\.git/ {return 404;}
+ location ~ /\.hg/ {return 404;}
+ location ~ /\.bzr/ {return 404;}
+
+ include %home%/%user%/conf/snginx.%domain%.conf*;
+}
+
diff --git a/data/templates/web/nginx_default.tpl b/data/templates/web/nginx_default.tpl
new file mode 100755
index 00000000..a3535419
--- /dev/null
+++ b/data/templates/web/nginx_default.tpl
@@ -0,0 +1,33 @@
+server {
+ listen %ip%:%proxy_port%;
+ server_name %domain_idn% %alias_idn%;
+ %elog%error_log /var/log/httpd/domains/%domain%.error.log error;
+
+ location / {
+ proxy_pass http://%ip%:%web_port%;
+ location ~* ^.+\.(%nginx_extentions%)$ {
+ root %docroot%;
+ access_log /var/log/httpd/domains/%domain%.log combined;
+ access_log /var/log/httpd/domains/%domain%.bytes bytes;
+ expires max;
+ try_files $uri @fallback;
+ }
+ }
+
+ location /error/ {
+ alias %home%/%user%/web/%domain%/document_errors/;
+ }
+
+ location @fallback {
+ proxy_pass http://%ip%:%web_port%;
+ }
+
+ location ~ /\.ht {return 404;}
+ location ~ /\.svn/ {return 404;}
+ location ~ /\.git/ {return 404;}
+ location ~ /\.hg/ {return 404;}
+ location ~ /\.bzr/ {return 404;}
+
+ include %home%/%user%/conf/nginx.%domain%.conf*;
+}
+
diff --git a/func/domain.sh b/func/domain.sh
index 22b2f463..0eb17f5c 100755
--- a/func/domain.sh
+++ b/func/domain.sh
@@ -1,36 +1,46 @@
# Web template check
is_apache_template_valid() {
- c=$(echo "$(get_user_value '$WEB_TPL')" | grep -w "$template")
t="$WEBTPL/apache_$template.tpl"
- d="$WEBTPL/apache_$template.descr"
s="$WEBTPL/apache_$template.stpl"
- if [ -z "$c" ] || [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
- echo "Error: template $template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ template='default'
+ t="$WEBTPL/apache_$template.tpl"
+ s="$WEBTPL/apache_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ echo "Error: template $template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
fi
}
# Nginx template check
is_nginx_template_valid() {
- t="$WEBTPL/ngingx_$template.tpl"
- d="$WEBTPL/ngingx_$template.descr"
- s="$WEBTPL/ngingx_$template.stpl"
- if [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
- echo "Error: nginx $template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
+ t="$WEBTPL/nginx_$template.tpl"
+ s="$WEBTPL/nginx_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ template='default'
+ t="$WEBTPL/nginx_$template.tpl"
+ s="$WEBTPL/nginx_$template.stpl"
+ if [ ! -e $t ] || [ ! -e $s ]; then
+ echo "Error: nginx $template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
fi
}
# DNS template check
is_dns_template_valid() {
tpl="$DNSTPL/$template.tpl"
- descr="$DNSTPL/$template.descr"
- if [ ! -e $tpl ] || [ ! -e $descr ]; then
- echo "Error: template not found"
- log_event "$E_NOTEXIST" "$EVENT"
- exit $E_NOTEXIST
+ if [ ! -e $tpl ]; then
+ template='default'
+ tpl="$DNSTPL/$template.tpl"
+ if [ ! -e $tpl ]; then
+ echo "Error: template not found"
+ log_event "$E_NOTEXIST" "$EVENT"
+ exit $E_NOTEXIST
+ fi
fi
}
diff --git a/web/add/dns/index.php b/web/add/dns/index.php
index c392649f..c333b23b 100644
--- a/web/add/dns/index.php
+++ b/web/add/dns/index.php
@@ -18,7 +18,6 @@ top_panel($user,$TAB);
// Check input
if (empty($_POST['v_domain'])) $errors[] = 'domain';
if (empty($_POST['v_ip'])) $errors[] = 'ip';
- if (empty($_POST['v_template'])) $errors[] = 'template';
if (empty($_POST['v_exp'])) $errors[] = 'expiriation date';
if (empty($_POST['v_soa'])) $errors[] = 'SOA';
if (empty($_POST['v_ttl'])) $errors[] = 'TTL';
@@ -27,7 +26,11 @@ top_panel($user,$TAB);
$v_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
$v_domain = escapeshellarg($v_domain);
$v_ip = escapeshellarg($_POST['v_ip']);
- $v_template = escapeshellarg($_POST['v_template']);
+ if ($_SESSION['user'] == 'admin') {
+ $v_template = escapeshellarg($_POST['v_template']);
+ } else {
+ $v_template = "''";
+ }
$v_exp = escapeshellarg($_POST['v_exp']);
$v_soa = escapeshellarg($_POST['v_soa']);
$v_ttl = escapeshellarg($_POST['v_ttl']);
@@ -120,8 +123,13 @@ top_panel($user,$TAB);
$v_ttl = 14400;
$v_exp = date('Y-m-d', strtotime('+1 year'));
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html');
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
+ if ($_SESSION['user'] == 'admin') {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
+ } else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_dns.html');
+ }
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
} else {
diff --git a/web/add/web/index.php b/web/add/web/index.php
index 6cb03aa2..27fcbf2f 100644
--- a/web/add/web/index.php
+++ b/web/add/web/index.php
@@ -12,13 +12,10 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
// Panel
top_panel($user,$TAB);
-// Are you admin?
-//if ($_SESSION['user'] == 'admin') {
if (!empty($_POST['ok'])) {
// Check input
if (empty($_POST['v_domain'])) $errors[] = 'domain';
if (empty($_POST['v_ip'])) $errors[] = 'ip';
- if (empty($_POST['v_template'])) $errors[] = 'template';
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_aliases'])) || (!empty($_POST['v_elog'])) || (!empty($_POST['v_ssl'])) || (!empty($_POST['v_ssl_crt'])) || (!empty($_POST['v_ssl_key'])) || (!empty($_POST['v_ssl_ca'])) || ($_POST['v_stats'] != 'none') || (empty($_POST['v_nginx']))) $v_adv = 'yes';
@@ -27,7 +24,11 @@ top_panel($user,$TAB);
$v_domain = preg_replace("/^www./i", "", $_POST['v_domain']);
$v_domain = escapeshellarg($v_domain);
$v_ip = escapeshellarg($_POST['v_ip']);
- $v_template = escapeshellarg($_POST['v_template']);
+ if ($_SESSION['user'] == 'admin') {
+ $v_template = escapeshellarg($_POST['v_template']);
+ } else {
+ $v_template = "''";
+ }
if (empty($_POST['v_dns'])) $v_dns = 'off';
if (empty($_POST['v_mail'])) $v_mail = 'off';
if (empty($_POST['v_nginx'])) $v_nginx = 'off';
@@ -204,7 +205,7 @@ top_panel($user,$TAB);
$ips = json_decode(implode('', $output), true);
unset($output);
- exec (VESTA_CMD."v_list_web_templates ".$user." json", $output, $return_var);
+ exec (VESTA_CMD."v_list_web_templates json", $output, $return_var);
$templates = json_decode(implode('', $output), true);
unset($output);
@@ -212,8 +213,14 @@ top_panel($user,$TAB);
$stats = json_decode(implode('', $output), true);
unset($output);
+// Are you admin?
+if ($_SESSION['user'] == 'admin') {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_web.html');
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html');
+} else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_web.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_web.html');
+}
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
//}
diff --git a/web/edit/dns/index.php b/web/edit/dns/index.php
index 04f0a18c..c2b69c55 100644
--- a/web/edit/dns/index.php
+++ b/web/edit/dns/index.php
@@ -73,7 +73,7 @@ top_panel($user,$TAB);
}
// Template
- if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
+ if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
$v_template = escapeshellarg($_POST['v_template']);
exec (VESTA_CMD."v_change_dns_domain_tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var);
if ($return_var != 0) {
@@ -139,8 +139,13 @@ top_panel($user,$TAB);
}
}
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html');
- include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html');
+ if ($_SESSION['user'] == 'admin') {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html');
+ } else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_dns.html');
+ }
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
} else {
diff --git a/web/edit/user/index.php b/web/edit/user/index.php
index 26eb34d6..3468fce8 100644
--- a/web/edit/user/index.php
+++ b/web/edit/user/index.php
@@ -35,6 +35,7 @@ if ($_SESSION['user'] == 'admin') {
$v_username = $_GET['user'];
$v_password = "••••••••";
$v_email = $data[$v_username]['CONTACT'];
+ $v_template = $data[$v_username]['TEMPLATE'];
$v_package = $data[$v_username]['PACKAGE'];
$v_fname = $data[$v_username]['FNAME'];
$v_lname = $data[$v_username]['LNAME'];
@@ -58,6 +59,10 @@ if ($_SESSION['user'] == 'admin') {
$packages = 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_sys_shells json", $output, $return_var);
$shells = json_decode(implode('', $output), true);
unset($output);
@@ -92,6 +97,18 @@ if ($_SESSION['user'] == 'admin') {
unset($output);
}
+ // Change template
+ if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
+ $v_template = escapeshellarg($_POST['v_template']);
+ exec (VESTA_CMD."v_change_user_template ".$v_username." ".$v_template, $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);
+ }
+
// Change shell
if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) {
$v_shell = escapeshellarg($_POST['v_shell']);
@@ -258,7 +275,7 @@ if ($_SESSION['user'] == 'admin') {
$_SESSION['ok_msg'] = "OK: changes has been saved.";
}
}
- include($_SERVER['DOCUMENT_ROOT'].'/templates/user/menu_edit_user.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_user.html');
include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html');
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
diff --git a/web/edit/web/index.php b/web/edit/web/index.php
index c0a15a4b..16f05373 100644
--- a/web/edit/web/index.php
+++ b/web/edit/web/index.php
@@ -69,7 +69,7 @@ top_panel($user,$TAB);
$ips = json_decode(implode('', $output), true);
unset($output);
- exec (VESTA_CMD."v_list_web_templates ".$user." json", $output, $return_var);
+ exec (VESTA_CMD."v_list_web_templates json", $output, $return_var);
$templates = json_decode(implode('', $output), true);
unset($output);
@@ -120,7 +120,7 @@ top_panel($user,$TAB);
}
// Template
- if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
+ 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) {
@@ -509,8 +509,13 @@ top_panel($user,$TAB);
}
}
+if ($_SESSION['user'] == 'admin') {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_web.html');
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html');
+} else {
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_web.html');
+ include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html');
+}
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
//}
diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html
index b825def3..e19b6d7f 100644
--- a/web/templates/admin/add_dns.html
+++ b/web/templates/admin/add_dns.html
@@ -28,22 +28,23 @@
Template |
Domain Expiriation |
> |
SOA |