Project

General

Profile

Bug #10907 » linkvalidator-redirect.diff

Philipp Gampe, 2011-01-02 01:43

View differences:

modfunc1/locallang.xml (Arbeitskopie)
<label index="list.report.pageforbidden403">Accessing this address is not allowed (403).</label>
<label index="list.report.externalerror">External Link returned HTTP error code (%s).</label>
<label index="list.report.filenotexisting">File doesn't exist.</label>
<label index="list.report.redirectloop">Too many redirects.</label>
<label index="list.msg.lastRun">%1$s %2$s</label>
</languageKey>
</data>
classes/linktypes/class.tx_linkvalidator_linktypes_external.php (Arbeitskopie)
// try to fetch the content of the URL (just fetching of headers doesn't work!)
$report = array();
t3lib_div::getURL($url, 1, FALSE, $report);
// get the full content
$content = '';
$content = t3lib_div::getURL($url, 1, FALSE, $report);
$ret = 1;
$tries = 0;
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], 1, FALSE, $report);
}
$tries++;
}
$ret = 1;
// analyze the response
if ($report['error']) {
$ret = $GLOBALS['LANG']->getLL('list.report.noresponse');
}
if($report['http_code'] == 301 || $report['http_code'] == 302 || $report['http_code'] == 303 || $report['http_code'] == 307) {
$ret = $GLOBALS['LANG']->getLL('list.report.redirectloop');
}
if($report['http_code'] === 404) {
$ret = $GLOBALS['LANG']->getLL('list.report.pagenotfound404');
}
......
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/linktypes/class.tx_linkvalidator_linktypes_external.php']);
}
?>
?>
(1-1/4)