<?php 

$from 
"malesca.tumblr.com";
$unto "henrik.nyh.se/tumble";

// Because Dreamhost doesn't do remote fopens, and to get content-type
function fetch($url) {
    
$curl curl_init();
    
$timeout 5// set to zero for no timeout
    
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
    
curl_setopt($curlCURLOPT_URL$url);
    
curl_setopt($curlCURLOPT_CONNECTTIMEOUT$timeout);
    
curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
    
$html curl_exec($curl);
    
$content_type curl_getinfo($curlCURLINFO_CONTENT_TYPE);
    
curl_close($curl);
    return array(
$html$content_type);
}

list(
$html$content_type) = fetch($_GET['url']);

// Fix root-relative links etc.
$html preg_replace('/\b(href|src|rel)="\//''$1="http://'.$unto.'/'$html);
// Replace the old URL with the new
$html str_replace($from$unto$html);

header("Content-type: $content_type");
echo 
$html;

?>