Version: 1.0
Type: Function
Category: HTTP
License: GNU General Public License
Description: Fopen() normally does not support a proxy server. This function replaces the fopen() of an url via a proxy server. All comments welcome!
function pfopen($url) {
$proxy_server = "MYPROXYSERVER";
$proxy_port = 8080;
if (substr($url, 0,7) <> 'http://') {
return false;
}
$proxycon = fsockopen($proxy_server, $proxy_port, $errno, $errstr);
fputs($proxycon,"GET ".$url." HTTP/1.0 \r\n\r\n");
$reading_headers = true;
while (!feof ($proxycon)) {
$curline = fgets($proxycon, 4096);
if ($curline=="\r\n") {
$reading_headers = false;
}
if (!$reading_headers) {
$filecontent .= $curline;
}
}
fclose($proxycon);
return $filecontent;
}