浏览代码

check names

Check for domain name.
Check for tools-site domain.
Cristhian Martínez Ochoa 5 年之前
父节点
当前提交
0c5230c6e5
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 11 2
      lib/sites
  2. 5 0
      plugins/webinoly

+ 11 - 2
lib/sites

@@ -57,7 +57,10 @@ domain_check() {
 
 
 	# Can not contain two points together and can not start or end with a point
 	# Can not contain two points together and can not start or end with a point
 	[[ $din == *..* || $(echo "${din}" | cut -c-1) == "." || $(echo "${din}" | rev | cut -c-1) == "." ]] && domfail="true"
 	[[ $din == *..* || $(echo "${din}" | cut -c-1) == "." || $(echo "${din}" | rev | cut -c-1) == "." ]] && domfail="true"
-
+	
+	# First check if valid TLD
+	[[ $count == 1 ]] && echo "${red}[WARNING] Domain name is not a valid TLD (Top Level Domain).${end}"
+	
 	[[ $domfail == "true" ]] && echo "${red}[WARNING] Domain names can only contain letters, numbers or a hyphen; can not start or end with a hyphen and can be up to 67 characters long.${end}"
 	[[ $domfail == "true" ]] && echo "${red}[WARNING] Domain names can only contain letters, numbers or a hyphen; can not start or end with a hyphen and can be up to 67 characters long.${end}"
 }
 }
 
 
@@ -580,7 +583,13 @@ createsite() {
 	# Check domain and then prevent reserved characters for file names.
 	# Check domain and then prevent reserved characters for file names.
 	domain_check $domain
 	domain_check $domain
 	domain=$(echo $domain | sed "s/[^\.0-9A-Za-z\-]/_/g" | sed "s/^[\.]/_/g" | sed "s/\.\./_/g")
 	domain=$(echo $domain | sed "s/[^\.0-9A-Za-z\-]/_/g" | sed "s/^[\.]/_/g" | sed "s/\.\./_/g")
-
+	
+	# Check for reserved domain names
+	if [[ $domain == "default" ]]; then
+		echo "${red}[ERROR] Domain name reserved!${end}"
+		exit 1
+	fi
+	
 	# Check for duplicate sites
 	# Check for duplicate sites
 	if [[ -a /etc/nginx/sites-available/$domain ]]; then
 	if [[ -a /etc/nginx/sites-available/$domain ]]; then
 		echo "${red}[ERROR] Can not create site${blu} $domain ${red}because already exists!${end}"
 		echo "${red}[ERROR] Can not create site${blu} $domain ${red}because already exists!${end}"

+ 5 - 0
plugins/webinoly

@@ -91,6 +91,11 @@ elif [[ -n $dbpass ]]; then
 	
 	
 	
 	
 elif [[ -n $tools_port ]]; then
 elif [[ -n $tools_port ]]; then
+	if [[ -a /etc/nginx/sites-available/$tools_port ]]; then
+		echo "${red}[ERROR] Port/site '$tools_port' is already in use!${end}"
+		exit 1
+	fi
+	
 	oldport="$(conf_read tools-port)"
 	oldport="$(conf_read tools-port)"
 	[[ $tools_port != true ]] && tools_port $tools_port || tools_port
 	[[ $tools_port != true ]] && tools_port $tools_port || tools_port
 	newport="$(conf_read tools-port)"
 	newport="$(conf_read tools-port)"