#native_company# #native_desc#
#native_cta#

fopen() via proxy server

By NightOwl
on August 26, 2003

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 rnrn");

	$reading_headers = true;
	while (!feof ($proxycon)) {
		$curline = fgets($proxycon, 4096);

		if ($curline=="rn") {
			$reading_headers = false;
		}
		if (!$reading_headers) {
			$filecontent .= $curline;
		}
	}

	fclose($proxycon);
	return $filecontent;


}