![]() |
|
Help - PHP Proxy - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: Help - PHP Proxy (/Thread-Help-PHP-Proxy) |
Help - PHP Proxy - zosoftnet - 07-30-2013 PHP Code: <?php
$url = 'http://www.someblockedsite.com'; //Assume that this site is blocked by your ISP
$content = file_get_contents($url);
header('Content-type: text/xml');
echo $content;
?>Well, this code has done what I want to by pass. But my problem is: Quote: When there are some link say Login.php, register.php, etc link in the page, when I click that those links should still open with the file_get_contents($url); Sorry for my Bad English! RE: Help - PHP Proxy - Anizeb - 07-30-2013 You might have to perform a str_replace, replacing all instances of "http://www.someblockedsite.com" with your proxy script set to point the blocked domain. Of course you'll also need to change Code: $url = 'http://www.someblockedsite.com';Code: $url = $_GET['url']RE: Help - PHP Proxy - zosoftnet - 07-31-2013 Yes, of course that is what I do if I use GET or POST method..... The question is in a page we have a link, say http://www.blockedsite.com/login.php, so I want this to be http://localhost/?u=http:////www.blocksite.com/login.php !!!!!!!!!! RE: Help - PHP Proxy - nikey646 - 08-04-2013 Well, this will hurt it if they show their entire url on the page, but a simple str_replace("http://www.blockedsite.com/", "http://localhost/?u=http:////www.blocksite.com/", $url); should work... There are a few problems with this, it assumes every link starts with "http://www.", and as i said earlier, it will replace anything on the HTML shown...The solution to this would be running a RegEx or XML on it, looking for <a href="*"></a>, and replacing the contents...I'll make something with RegEx (Preg_Replace) in a few for ya...Won't be the best tho ![]() Edit: Here is a quick RegEx that i made, I really recommend improving on it, as it's still not fool proof (For example, if there is a class in the Anchor link, then it'll skip over it..., same with id etc etc), I'll make an another version, which uses a function instead of replacing expected stuff, still RegEx with the same problems again.... I highly recommend looking into a HTML/XML Parser to do what you want to do... PHP Code: <?php
$url = "http://google.com";
$page = file_get_contents($url);
$page = preg_replace("#\<a href=\"(.+)\">(.+)</a>#iUs", "<a href=\"http://localhost/?u=$1\">$2 - [Changed]</a>", $page);
echo $page;
?>RE: Help - PHP Proxy - zosoftnet - 08-04-2013 (08-04-2013, 01:01 PM)nikey646 Wrote: Well, this will hurt it if they show their entire url on the page, but a simple str_replace("http://www.blockedsite.com/", "http://localhost/?u=http:////www.blocksite.com/", $url); should work... This resolved my problem..You are really food in RegExp.........! Thanks.. |