Bug #12225 ยป linkvalidator.patch
class.tx_linkvalidator_linktype_external.php 2011-03-11 19:21:25.000000000 +0100 | ||
---|---|---|
// try to fetch the content of the URL (headers only)
|
||
$report = array();
|
||
// try fetching the content of the URL (just fetching the headers does not work correctly)
|
||
$content = '';
|
||
$content = t3lib_div::getURL($url, 1, FALSE, $report);
|
||
$content = t3lib_div::getURL($url, 2, FALSE, $report);
|
||
$tries = 0;
|
||
$lastUrl = $url;
|
||
while (($report['http_code'] == 301 || $report['http_code'] == 302
|
||
|| $report['http_code'] == 303 || $report['http_code'] == 307)
|
||
&& ($tries < 5)) {
|
||
$isCodeRedirect = preg_match('/Location: (.*)/', $content, $location);
|
||
if (isset($location[1])) {
|
||
$content = t3lib_div::getURL($location[1], 2, FALSE, $report);
|
||
$isCodeRedirect = preg_match('/Location: ([^\r\n]+)/', $content, $location);
|
||
if ($isCodeRedirect && isset($location[1])) {
|
||
$parsedUrl = parse_url($location[1]);
|
||
if (!isset($parsedUrl['host'])) {
|
||
// the location did not contain a complete URI, build it!
|
||
$parsedUrl = parse_url($lastUrl);
|
||
$lastUrl = $parsedUrl['scheme'].'://'.(isset($parsedUrl['user'])?$parsedUrl['user'].(isset($parsedUrl['pass'])?':'.$parsedUrl['pass']:''):'').$parsedUrl['host'].(isset($parsedUrl['port'])?':'.$parsedUrl['port']:'').$location[1];
|
||
}
|
||
else {
|
||
$lastUrl = $location[1];
|
||
}
|
||
$content = t3lib_div::getURL($lastUrl, 2, FALSE, $report);
|
||
$tries++;
|
||
}
|
||
else {
|
||
// treat non-existing or wrong Location as indefinite loop
|
||
$tries = 5;
|
||
}
|
||
$tries++;
|
||
}
|
||
$response = TRUE;
|