PHP Proxy help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ner0
Forum Newbie
Posts: 1
Joined: Thu Feb 21, 2008 10:45 am

PHP Proxy help

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: PHP Proxy help

Post 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;
?>
Post Reply