<?
header('Content-Type: image/jpeg');
function GetURL($URL, $link=false)
{
$h = curl_init($URL);
curl_setopt($h, CURLOPT_REFERER, $URL);
curl_setopt($h, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($h, CURLOPT_TIMEOUT, 10);
curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);
if($link)
{
curl_setopt($h, CURLOPT_HEADER, 1);
curl_setopt($h, CURLOPT_NOBODY, 1);
}
$c = curl_exec($h);
if(curl_getinfo($h, CURLINFO_HTTP_CODE) !== 200)
$c = false;
curl_close($h);
if($link && $c)
return $URL;
return $c;
}
$f = explode('/', $_SERVER['REQUEST_URI']);
if(file_exists('./'.$f[2]))
{
$s = file_get_contents('./'.$f[2]);
echo($s);
}
else
if(GetURL('http://site.ru/images/'.$f[2], 1))
{
$s = GetURL('http://site.ru/images/'.$f[2]);
echo $s;
}
else
{
$s = file_get_contents('./no_picture.jpg');
echo($s);
}
?>