function _linkchecker_absolute_content_path in Link checker 6.2
Same name and namespace in other branches
- 5.2 linkchecker.module \_linkchecker_absolute_content_path()
- 7 linkchecker.module \_linkchecker_absolute_content_path()
Get the path of an URL.
Parameters
string $url: The http/https URL to parse.
Return value
string Full qualified URL with absolute path of the URL.
1 call to _linkchecker_absolute_content_path()
- _linkchecker_extract_links in ./
linkchecker.module - Extract links from content.
File
- ./
linkchecker.module, line 1739 - This module periodically check links in given node types, blocks, cck fields, etc.
Code
function _linkchecker_absolute_content_path($url) {
// Parse the URL and make sure we can handle the schema.
$uri = @parse_url($url);
if ($uri == FALSE) {
return NULL;
}
if (!isset($uri['scheme'])) {
return NULL;
}
// Break if the schema is not supported.
if (!in_array($uri['scheme'], array(
'http',
'https',
))) {
return NULL;
}
$scheme = isset($uri['scheme']) ? $uri['scheme'] . '://' : '';
$user = isset($uri['user']) ? $uri['user'] . ($uri['pass'] ? ':' . $uri['pass'] : '') . '@' : '';
$port = isset($uri['port']) ? $uri['port'] : 80;
$host = $uri['host'] . ($port != 80 ? ':' . $port : '');
$path = isset($uri['path']) ? $uri['path'] : '/';
// Glue the URL variables.
$absolute_url = $scheme . $user . $host . $path;
// Find the last slash and remove all after the last slash to get the path.
$last_slash = strrpos($absolute_url, '/');
$absolute_content_url = drupal_substr($absolute_url, 0, $last_slash + 1);
return $absolute_content_url;
}