Determines if an external URL points to this Drupal installation.
$url: A string containing an external URL, such as "http://example.com/foo".
TRUE if the URL has the same domain and base path.
function _external_url_is_local($url) {
$url_parts = parse_url($url);
$base_host = parse_url($GLOBALS['base_url'], PHP_URL_HOST);
if (!isset($url_parts['path'])) {
return $url_parts['host'] == $base_host;
}
else {
// 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;
}
}