André
André

Reputation: 25554

There are any open-soure PHP Web Proxy ready to use?

I need a PHP Web Proxy that read html, show to the user and rewrite all the links for when the user click in the next link the proxy will handle the request again, just like this code, but with additionaly sould make the rewrite of all the links.

<?php
// Set your return content type
header('Content-type: text/html');

// Website url to open
$daurl = 'http://www.yahoo.com';

// Get that website's content
$handle = fopen($daurl, "r");

// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

I hope I have explained well. This question is for not reinventing the wheel.

Another additional question. This kind of proxies will deal with contents like Flash?

Upvotes: 0

Views: 5587

Answers (2)

mfonda
mfonda

Reputation: 8003

For an open source solution, check out PHProxy. I've used it in the past and it seemed to work quite well from what I can remember.

Upvotes: 1

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

It will sort of work, you need to rewrite any relative path to apsolute, and I think cookies won't work in this case. Use cURL for this operations...

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    return curl_exec($ch);
    curl_close ($ch);
}

$url = "http://www.yahoo.com";

echo curl($url);

Upvotes: 0

Related Questions