From 72a23db0b8b74e47f74ab25d80975f4ce40b3471 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 22 Aug 2024 11:21:04 +0200 Subject: [PATCH] First commit --- web/lib/validhostname.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 web/lib/validhostname.php diff --git a/web/lib/validhostname.php b/web/lib/validhostname.php new file mode 100644 index 0000000..3d215d8 --- /dev/null +++ b/web/lib/validhostname.php @@ -0,0 +1,18 @@ +$c) ? $multibyte=true : $multibyte=false; + if ($multibyte) $hostname=idn_to_ascii($hostname,IDNA_DEFAULT,INTL_IDNA_VARIANT_UTS46); + if (strlen($hostname)>253) + return false; + $labs=explode('.',$hostname); + foreach ($labs as $lab) { + $len=strlen($lab); + if ($len==0 || $len>63) + return false; + if (preg_match('#^[a-z0-9]([a-z0-9-]*[a-z0-9])?$#i'.$pattmods,$lab)!==1) + return false; + } + return true; +} +?>