domain name check

Now we check and have a WARNING messagge for domain names.
This commit is contained in:
Cristhian Martínez Ochoa 2018-04-25 19:59:40 -06:00
parent 5faece155d
commit 7c90bad146
2 changed files with 16 additions and 0 deletions

View file

@ -40,6 +40,20 @@ wp_cache_plugins() {
fi
}
domain_check() {
local din="$1"
# Only numerals 0-9, basic Latin letters, both lowercase and uppercase, hyphen.
[[ $din =~ ^[\.0-9A-Za-z\-]+$ ]] || domfail="true"
# Check Lenght
[[ ${#din} -gt 67 ]] && domfail="true"
# Can not start or end with a hyphen
[[ $(echo "${din}" | cut -c-1) == "-" || $(echo "${din}" | rev | cut -c-1) == "-" ]] && domfail="true"
[[ $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}"
}
dbword_check() {
local win="$1"
@ -449,6 +463,7 @@ deletesite() {
createsite() {
domain_check $domain
if [[ $(conf_read php) != "true" && ("$wp" == [123] || "$type" == "-php") ]]; then
echo "${red}"
echo " [ERROR] PHP must be installed before you can create a WP site!"

View file

@ -210,6 +210,7 @@ elif [ "$type" == "-wpsubdom" ]; then
# Parked Domain
elif [ "$type" == "-parked" ]; then
domain_check $domain
# Check for duplicate sites
if [[ -a /etc/nginx/sites-available/$domain ]]; then
echo "${red}Site $domain could not be created because already exists!${end}"