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
Superiormic
Forum Newbie
Posts: 1
Joined: Wed Oct 07, 2009 5:25 am

PHP Proxy Help

Post by Superiormic »

Hey, I was wondering if someone could help me with a simple PHP proxy that I am making.
The WiP site is here : http://www.2sharp.exofire.net (use http:// in the text box)

Heres the problem:
I have a index.php page where the user enters the site they wish to navigate to using the proxy.
Once they press the main button a process.php document is ran. This file echo's out the contents of the site, and the website works fine. However when a user goes to navigate by clicking a link on the page they get directed to something like this:
http://2sharp.exofire.net/watch?v=VPKyc ... re=popular
which doesnt work due to the URL.

I was wondering if there was a way to catch this URL before the page redirects and crashes, convert it to 'youtube.com' instead of '2sharp.exofire.net' and then run it back through the process.php file.
Hence echoing out the desired page through proxy.

Thankyou for reading, any help would be much appreciated as I am trying to learn.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP Proxy Help

Post by Eric! »

When you fetch the remote URL page, you have to rewrite the links so they get processed by your site instead linking outside of your domain. For example let's say the user views the following page:

yoursite.com/process.php?target=http://www.cnn.com/oreily_porn_addict.html

You have to parse the links in that page to change from:

http://www.cnn.com/porn_addicts_moreinformation.html
or
porn_addicts_moreinformation.html
to
http://yoursite.com/process.php?target=http://www.cnn.com/porn_addicts_moreinformation.html

That way when a user clicks on a link that has been rendered in their browser, it gets routed back to your process.php page.
Post Reply