Project

General

Profile

Bug #10907 » linkval-non200_debug.diff

Philipp Gampe, 2011-01-04 00:13

View differences:

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, 2, FALSE, $report);
t3lib_div::debug($content, $url, "first-content");
$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);
t3lib_div::debug($content, $location[1], "second-content");
}
$tries++;
}
$ret = 1;
t3lib_div::debug($report, $url, "linkvalidator-report");
// analyze the response
if ($report['error']) {
$ret = $GLOBALS['LANG']->getLL('list.report.noresponse');
}
if($report['http_code'] === 404) {
if ($report['http_code'] >= 300) {
$ret = sprintf($GLOBALS['LANG']->getLL('list.report.externalerror'), $report['http_code']);
}
//special handling for more information
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');
}
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']);
}
//debugging
if ($ret == 1) {
$ret = "check passed as ok";
}
$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']);
}
?>
?>
(2-2/4)