X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=inc%2Fpoche%2FTools.class.php;h=7bc8830a5cdbb69eba3324d5b5856431027ab5ad;hb=55821e04c188997d258645975220828e195d0df4;hp=834940ffb4ec98359a53bd753f173d3a621e2bbb;hpb=b161295d0b53a5ae194e236b0a7c662e9ac2ff9a;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 834940ff..7bc8830a 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -210,4 +210,15 @@ class Tools { return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); } + + public static function getDomain($url) + { + $pieces = parse_url($url); + $domain = isset($pieces['host']) ? $pieces['host'] : ''; + if (preg_match('/(?P[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { + return $regs['domain']; + } + + return FALSE; + } } \ No newline at end of file