function _external_url_is_local

Determines if an external URL points to this Drupal installation.

Parameters

$url: A string containing an external URL, such as "http://example.com/foo".

Return value

TRUE if the URL has the same domain and base path.

Related topics

1 call to _external_url_is_local()
drupal_goto in drupal/core/includes/common.inc
Sends the user to a different Drupal page.

File

drupal/core/includes/common.inc, line 724
Common functions that many Drupal modules will need to reference.

Code

function _external_url_is_local($url) {
  $url_parts = parse_url($url);
  $base_host = parse_url($GLOBALS['base_url'], PHP_URL_HOST);

  // When comparing base paths, we need a trailing slash to make sure a
  // partial URL match isn't occuring. Since base_path() always returns with
  // a trailing slash, we don't need to add the trailing slash here.
  return $url_parts['host'] == $base_host && stripos($url_parts['path'], base_path()) === 0;
}