| 1 |
<?
|
| 2 |
|
| 3 |
// this file under the public domain
|
| 4 |
|
| 5 |
// turn off all error reporting
|
| 6 |
error_reporting(0);
|
| 7 |
|
| 8 |
$url = $_GET['url'];
|
| 9 |
|
| 10 |
// only http and https supported
|
| 11 |
if(preg_match("/^https?\:.*/", $url)){
|
| 12 |
$html = file_get_contents($url);
|
| 13 |
|
| 14 |
// TODO: make sure we have XML and not some other
|
| 15 |
// content type or an error message
|
| 16 |
|
| 17 |
// get the status code of the response
|
| 18 |
list($version, $status_code, $msg) = explode(' ', $http_response_header[0], 3);
|
| 19 |
switch($status_code){
|
| 20 |
case 200: case 304:
|
| 21 |
header('Content-type: text/html');
|
| 22 |
echo($html);
|
| 23 |
break;
|
| 24 |
default:
|
| 25 |
header($http_response_header[0]);
|
| 26 |
break;
|
| 27 |
}
|
| 28 |
}else{
|
| 29 |
header('HTTP/1.1 403 Forbidden');
|
| 30 |
header('Content-type: text/html');
|
| 31 |
echo("You are not allowed to retrieve this resource");
|
| 32 |
}
|
| 33 |
?>
|
| 34 |
|