You are here

function elf_url_external in External Links Filter 5.3

Same name and namespace in other branches
  1. 6.3 elf.module \elf_url_external()
  2. 7.3 elf.module \elf_url_external()

Test if a URL is external

Parameters

$url string:

1 call to elf_url_external()
elf_replace in ./elf.module
Add classes to external or mailto links in a text.

File

./elf.module, line 147

Code

function elf_url_external($url) {
  $protocols = array(
    'http',
    'https',
    'ftp',
  );
  $protocol = drupal_substr($url, 0, strpos($url, ':'));
  if (in_array($protocol, $protocols)) {
    $external = TRUE;
    $domains = elf_domains();
    foreach ($domains as $domain) {
      if (strpos($url, $domain) !== FALSE) {
        $external = FALSE;
      }
    }
    return $external;
  }
  return FALSE;
}