diff options
author | Phil Davis <phil.davis@inf.org> | 2014-11-11 00:16:06 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2014-11-11 00:16:06 +0545 |
commit | 6bcbd862f70d003feb6cd529ed8f606d67f9b3a4 (patch) | |
tree | aa2c8b675c118b03d5a2c31c7dfbcd6883ebd562 | |
parent | 894a0159a011a68df51f3d58df638b7db484899c (diff) | |
download | pfsense-6bcbd862f70d003feb6cd529ed8f606d67f9b3a4.zip pfsense-6bcbd862f70d003feb6cd529ed8f606d67f9b3a4.tar.gz |
Add is_unqualified_hostname function
-rw-r--r-- | etc/inc/util.inc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index c64a5ed..6a2047b 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -670,7 +670,18 @@ function is_subnetoralias($subnet) { return is_subnet($subnet); } -/* returns true if $hostname is a valid hostname */ +/* returns true if $hostname is just a valid hostname (top part without any of the domain part) */ +function is_unqualified_hostname($hostname) { + if (!is_string($hostname)) + return false; + + if (preg_match('/^(?:[a-z0-9_]|[a-z0-9_][a-z0-9_\-]*[a-z0-9_])$/i', $hostname)) + return true; + else + return false; +} + +/* returns true if $hostname is a valid hostname, with or without being a fully-qualified domain name. */ function is_hostname($hostname) { if (!is_string($hostname)) return false; |