Closed Thread Icon

Topic awaiting preservation: PHP Web Proxying Pages that link to <a href="https://ozoneasylum.com/backlink?for=26387" title="Pages that link to Topic awaiting preservation: PHP Web Proxying" rel="nofollow" >Topic awaiting preservation: PHP Web Proxying\

 
Author Thread
Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-05-2005 02:16

I've been doing some reasearch into this lately, trying to find out how it works and how I can build my own proxying script with PHP, if at all possible. I know that sites like anonymizer.com and so on exist and that I can use them, but my problem is that the proxy-protected environment I need to work in not only blocks sites I need to access (at one ponit they even blocked this place and, for some reason, google) but also any sites that can help me get around them. So it comes to hiding a proxying script on my own website and hoping that it's possible. The way I can see it working is that my script requests and loads the page whilst still on the server, then serves that to me, thus making the proxy on this end think that everything is flowing from my domain. Is this actually possible? and, if so, how?


Justice 4 Pat Richard

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-05-2005 05:12

Sure you just need to use fopen

code:
$wp=fopen($url,"r");
// here you receive content of page
while(!feof($wp)) {
 echo  fread($wp,4096);
}
fclose($wp);



Now you want to validate the URL because you're probably going to pass in the URL you want to use in the query string and you don't want someone to be able to pass in a file path.

I'd use something like:

code:
ini_set('open_basedir','.');



put that in front of the code and it will set the basedir for this script to the directory this script runs. Also put this script in it's own directory

Then just do http://www.skarjj.com?url=http://www.google.com



.:[ Never resist a perfect moment ]:.

(Edited by bitdamaged on 08-05-2005 05:15)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-05-2005 05:18

oh to make this a little easier to use you could also do something like make a frameset with an input field on the top that opens the page in a frame underneath. Then use the input as a psuedo address bar



.:[ Never resist a perfect moment ]:.

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-05-2005 09:54

Indeed... thanks much bit, that's exactly what I was looking for


Justice 4 Pat Richard

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-05-2005 17:20

Actually that's not going to work that well because your browser is still going to pull in all the images etc from the external site. Not to mention all the links will be outside your frame.

You could do something like put output a base href statement at the top

echo <base href="http://www.skaarj.com/?url=$url" />

Which should make all the images come from your site (well all relative images).

Then parse for links and replace them with the above as well. (this is harder than it looks).



.:[ Never resist a perfect moment ]:.

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 08-05-2005 19:28

Here is a proxy written in Perl. I know you said you wanted to write one in PHP, but, I think the techniques used in this article could be transferd over to PHP and you could use it as an example of how an anonymizing proxy works.



-- not necessarily stoned... just beautiful.


(Edited by hyperbole on 08-05-2005 19:30)

« BackwardsOnwards »

Show Forum Drop Down Menu