]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Tools.class.php
share email +twitter / class messages
[github/wallabag/wallabag.git] / inc / poche / Tools.class.php
index 834940ffb4ec98359a53bd753f173d3a621e2bbb..7bc8830a5cdbb69eba3324d5b5856431027ab5ad 100644 (file)
@@ -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<domain>[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