Example
- Load some content
- This will time out
- This is a whitelisted external file
- This is another whitelisted external file
- This is non-whitelisted external file
- This triggers a "not found error"
Source Code
PHP
<?php
$url = $_GET['url'];
$allowedurls = array(
'http://developer.yahoo.com',
'http://icant.co.uk'
);
if(in_array($url,$allowedurls)){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$content = preg_replace('/.*<body[^>]*>/msi','',$output);
$content = preg_replace('/<\/body>.*/msi','',$content);
echo $content;
} else {
echo 'Error: URL not allowed to load here.';
}
?>