parent
03c1b1d072
commit
d685af74ce
|
@ -22,14 +22,14 @@ function DetectRedirect($url)
|
||||||
{
|
{
|
||||||
if(parse_url($url, PHP_URL_HOST)==FALSE) {
|
if(parse_url($url, PHP_URL_HOST)==FALSE) {
|
||||||
//die('Not a URL');
|
//die('Not a URL');
|
||||||
return array( 'error' => 'Not a URL: '. escape ($url) );
|
throw new Exception('Not a URL: '. escape ($url) );
|
||||||
}
|
}
|
||||||
$response = get_headers($url, 1);
|
$response = get_headers($url, 1);
|
||||||
if(!empty($response['Location'])) {
|
if(!empty($response['Location'])) {
|
||||||
$response2 = get_headers($response['Location'], 1);
|
$response2 = get_headers($response['Location'], 1);
|
||||||
if(!empty($response2['Location'])) {
|
if(!empty($response2['Location'])) {
|
||||||
//die('too much redirection');
|
//die('too much redirection');
|
||||||
return array( 'error' => 'too much redirection: '. escape ($url) );
|
throw new Exception('too much redirection: '. escape ($url) );
|
||||||
}
|
}
|
||||||
else { return $response['Location']; }
|
else { return $response['Location']; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue