View Full Version : Proxy locally
rafiki
05-10-2007, 11:06 AM
hi my friends at college and needs a proxy to access most webpages
how do i make a proxy on my localserver i tried file_get_contents() but the links that were /page were then localhost/page and the page didnt exist and it would just take me to www.codingforums.com/page (example) if they werent /page
defying the point of a proxy i did google "how to make a local proxy" but search results were not very helpful lol
thanks
rafiki
Mwnciau
05-10-2007, 04:16 PM
You'd need to do something like:
$url = $_GET['url'];
$page = file_get_contents($url);
$prefix= 'open.php?url=';
preg_match_all('#<a.*>#isx', $page, $links);
foreach ($links as $key => $linktag){
$link = preg_replace('#<a.*href="(.*?)".*>#isx', '$1', $linktag);
if ( preg_match('#^/', $link) ) {
$page = str_replace($link, $prefix . urlencode($url . $link), $page);
} elseif ( preg_match('#^www\.', $link) ) {
str_replace($link, $prefix . urlencode('http://' . $link), $page);
} else {
str_replace($link, $prefix . urlencode($link), $page);
}
}
echo $page;
You'll have to do the same with images too
rafiki
05-10-2007, 04:24 PM
jus giving a try, if works expect good feedback:)
rafiki
05-10-2007, 04:37 PM
sorry im getting
Warning: preg_match() expects parameter 2 to be string, array given in C:\Program Files\xampp\xampp\htdocs\hana\hana.php on line 11
Warning: preg_match() expects parameter 2 to be string, array given in C:\Program Files\xampp\xampp\htdocs\hana\hana.php on line 13
Warning: urlencode() expects parameter 1 to be string, array given in C:\Program Files\xampp\xampp\htdocs\hana\hana.php on line 16
(hana is my friend btw)
if (isset($_GET['url'])) {
$url = $_GET['url'];
$page = file_get_contents($url);
$prefix= 'open.php?url=';
preg_match_all('#<a.*>#isx', $page, $links);
foreach ($links as $key => $linktag){
$link = preg_replace('#<a.*href="(.*?)".*>#isx', '$1', $linktag);
if ( preg_match('#^/', $link) ) {
$page = str_replace($link, $prefix . urlencode($url . $link), $page);
} elseif ( preg_match('#^www\.', $link) ) {
str_replace($link, $prefix . urlencode('http://' . $link), $page);
} else {
str_replace($link, $prefix . urlencode($link), $page);
}
}
} else {
input for webpage
}
echo $page;
aedrin
05-10-2007, 04:51 PM
Why not install some proxy software?
rafiki
05-10-2007, 04:56 PM
because if i do it with php it keeps me upto scratch lol and i prefer to use php
aedrin
05-10-2007, 04:58 PM
Keeps you up to scratch?
Software is easier. Good luck making this work, you'll need it.
Why would someone at a college need a proxy? Most if not all colleges provide high quality internet.
Of course, they do block/filter some websites out there. You wouldn't be trying to go around those filters, would you?
rafiki
05-10-2007, 05:07 PM
yes i would lol well i wouldnt they would :) im just providing a server :P
why would PHP be extremly hard to make a proxy server?
aedrin
05-10-2007, 05:58 PM
So you get a URL through a PHP file, right?
Are you really going to parse the file and attempt to update all the links? That'll only work for a few websites out there... What about images/CSS/javascript, are you going to update all those links too?
I'm sure there are free HTTP proxies out there...
Though I don't think you should be doing this. It's not hard to get caught. And the "I'm just providing the tools to do the crime" won't convince anyone you're innocent ;)
rafiki
05-10-2007, 06:07 PM
basically she wants to use bebo and it doesnt really matter bout ccs, its just to read comments maybe i could make a function that would get her comments and let her post comments to other people without using a proxy? would this be more legal and easier?
CFMaBiSmAd
05-10-2007, 06:11 PM
You can examine the code in the popular php script PhpProxy - https://sourceforge.net/projects/phpproxy/ to learn how to do this.
Mwnciau
05-10-2007, 11:47 PM
The easiest thing to do is to change your internet settings on your browser to use a free proxy.
http://www.proxy4free.com/page1.html
rafiki
05-10-2007, 11:49 PM
the problem is that her college blocks a lot of proxys which are already out there, the current one shes using is temp blocked for 5-10 mins then is ok again, which is kinda annoying her, im going to try out that script that CFM linked to and see how that works out
thanks for that though
aedrin
05-11-2007, 05:15 PM
Perhaps that is a hint that this person really shouldn't be doing this.
They get free internet. If you want access to everything, then buy your own.
the-dream
05-11-2007, 09:43 PM
there's www.offcampuslunch.com
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.