From 55821e04c188997d258645975220828e195d0df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 5 Aug 2013 15:54:37 +0200 Subject: share email +twitter / class messages --- inc/poche/Tools.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'inc/poche/Tools.class.php') 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 -- cgit v1.2.3