My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.
PHP CODE EXAMPLE created on Sunday, May 02, 2010 permalink
How to use fopen() to create a proxy site to read any website content into AJAX
If your provider allows fopen() on your hosting server, here is a script that allows you to get data from any website into AJAX, Silverlight, Flash, etc. If your provider doesn't support fopen() you can try this curl version.
<?php
$url = filter_input(INPUT_GET, 'url',FILTER_SANITIZE_STRING);

$validUrlPrefixes[] = "http://tanguay.info";
$validUrlPrefixes[] = "http://www.tanguay.info";

if(beginsWithOneOfThese($url, $validUrlPrefixes)) {
    echo loadFile($url);
} else
    echo "invalid url";

function loadFile($sFilename) {
    if (floatval(phpversion()) >= 4.3) {
        $sData = file_get_contents($sFilename);
    } else {
        if (!file_exists($sFilename)) return -3;                
        
        $rHandle = fopen($sFilename, 'r');
        if (!$rHandle) return -2;

        $sData = '';
        while(!feof($rHandle))
            $sData .= fread($rHandle, filesize($sFilename));
        fclose($rHandle);
    }
    return $sData;
}

function beginsWithOneOfThese($main, $prefixes) {
    foreach($prefixes as $prefix) {
    if(beginsWith($main, $prefix))
        return true;
    }
    return false;
}

function beginsWith($main, $prefix) {
    return strpos($main, $prefix) === 0;
}
?>
need markup?