Using “validhostname” from “lib/validhostname.php”
This commit is contained in:
parent
72a23db0b8
commit
74bc9caa7e
1 changed files with 1 additions and 25 deletions
|
@ -25,6 +25,7 @@ require __DIR__.'/../lib/ghs.php';
|
||||||
require __DIR__.'/../lib/ght.php';
|
require __DIR__.'/../lib/ght.php';
|
||||||
require __DIR__.'/../lib/grace.php';
|
require __DIR__.'/../lib/grace.php';
|
||||||
require __DIR__.'/../lib/parsetime.php';
|
require __DIR__.'/../lib/parsetime.php';
|
||||||
|
require __DIR__.'/../lib/validhostname.php';
|
||||||
|
|
||||||
use function mysqli_real_escape_string as myesc;
|
use function mysqli_real_escape_string as myesc;
|
||||||
|
|
||||||
|
@ -467,29 +468,4 @@ function ckexarr($inst) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ismultibyte($s) {
|
|
||||||
preg_replace('/./u','.',$s,-1,$c);
|
|
||||||
(strlen($s)>$c) ? $r=true : $r=false;
|
|
||||||
return($r);
|
|
||||||
}
|
|
||||||
|
|
||||||
function validhostname($hostname) {
|
|
||||||
//$hostname=preg_replace('#/.*#','',$hostname);
|
|
||||||
//$hostname=preg_replace('#:[0-9]+$#','',$hostname);
|
|
||||||
if (ismultibyte($hostname)) $hostname=idn_to_ascii($hostname,IDNA_DEFAULT,INTL_IDNA_VARIANT_UTS46);
|
|
||||||
//echo($hostname.N);
|
|
||||||
if (strlen($hostname)>253) return(false);
|
|
||||||
$labels=explode('.',$hostname);
|
|
||||||
foreach($labels as $label) {
|
|
||||||
$len=strlen($label);
|
|
||||||
if ($len<1 || $len>63) return(false);
|
|
||||||
if (preg_match('#^-#',$label)==1) return(false);
|
|
||||||
if (preg_match('#-$#',$label)==1) return(false);
|
|
||||||
//if (preg_match('#--#',$label)==1) return(false);
|
|
||||||
if (preg_match('#^[a-zA-Z0-9-]+$#',$label)!==1) return(false);
|
|
||||||
}
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
//$url='www.team.starschlep.com/'; if (validhostname($url)) echo('OK: '.$url.N); else echo('KO: '.$url.N); die();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue