Page 1 of 1

PHP Proxy help

Posted: Thu Feb 21, 2008 10:50 am
by ner0
I'm new to php and trying to write a proxy using it. I believe I've been able to request a url but I'm not sure how to write the data back to the browser. So far I have

Code: Select all

 
<?php
 
$address = "http://www.google.com/"; //will eventually be passed from some other source
 
$instream = fopen($address, "r");
 
$data = fread($instream, filesize($instream));
fclose($instream);
 
fwrite($this,$data,filesize($data));
?>
 
But nothing is returned but a blank page.

Re: PHP Proxy help

Posted: Thu Feb 21, 2008 11:21 am
by JayBird

Code: Select all

<?php
  
$handle = fopen("http://www.google.com/", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
  
echo $contents;
?>