Project

General

Profile

Bug #10907 » redirect-detection-working.diff

working patch, might have whitespace issue ... please double check - Philipp Gampe, 2011-01-04 01:51

View differences:

modfunc1/locallang.xml (Arbeitskopie)
<label index="list.report.noresponse">External Link not reachable.</label>
<label index="list.report.pagenotfound404">The requested url was not found (404).</label>
<label index="list.report.pageforbidden403">Accessing this address is not allowed (403).</label>
<label index="list.report.redirectloop">A redirect loop occurred. (%s: %s) </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.msg.lastRun">%1$s %2$s</label>
classes/linktypes/class.tx_linkvalidator_linktypes_external.php (Arbeitskopie)
* @param string $url: url to check
* @param array $softRefEntry: the softref entry which builds the context of that url
* @param object $reference: parent instance of tx_linkvalidator_processing
* @return string validation error message or succes code
* @return string validation error message or success code
*/
public function checkLink($url, $softRefEntry, $reference) {
if ($this->url_reports[$url]) {
......
// 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, 2, 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], 2, FALSE, $report);
}
$tries++;
}
$ret = 1;
// analyze the response
if ($report['error']) {
$ret = $GLOBALS['LANG']->getLL('list.report.noresponse');
}
if ($report['http_code'] >= 300) {
$ret = sprintf($GLOBALS['LANG']->getLL('list.report.externalerror'), $report['http_code']);
}
if($report['http_code'] === 404) {
// special handling for more information
if (($report['http_code'] == 301) || ($report['http_code'] == 302) || ($report['http_code'] == 303) || ($report['http_code'] == 307)) {
$ret = sprintf($GLOBALS['LANG']->getLL('list.report.redirectloop'), $report['http_code'], $location[1]);
}
if ($report['http_code'] == 404) {
$ret = $GLOBALS['LANG']->getLL('list.report.pagenotfound404');
}
else if($report['http_code'] === 403) {
if ($report['http_code'] == 403) {
$ret = $GLOBALS['LANG']->getLL('list.report.pageforbidden403');
}
else if ($report['http_code'] >= 400) {
$ret = sprintf($GLOBALS['LANG']->getLL('list.report.externalerror'), $report['http_code']);
}
$this->url_reports[$url] = $ret;
return $ret;
......
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/linktypes/class.tx_linkvalidator_linktypes_external.php']);
}
?>
?>
(4-4/4)