I have this code which getting html code of page and than replace all the HREF attributes of the A' tag to redirect it to my site , than my site load the page and again redirect the links and so on...
<?php
libxml_use_internal_errors(true); // hide the parsing errors
$dom = new DOMDocument; // init new DOMDocument
if($_GET){
$dom->loadHtmlFile($_GET['open']); // getting link to redirect to
}else{
$dom->loadHtmlFile('http://www.stackoverflow.com'); // getting default site
}
$dom->loadHtmlFile('http://www.stackoverflow.com'); // load HTML into it
$xpath = new DOMXPath($dom); // create a new XPath
$nodes = $xpath->query('//a[@href]'); // Find all A elements with a href attribute
foreach($nodes as $node) { // Iterate over found elements
$node->setAttribute('href', 'index.php?open=http://www.stackoverflow.com'.$node->getAttribute('href')); // Change href attribute
}
echo $dom->saveXml(); // output cleaned HTML
?>
the code is perfectly running , the only problem is that it won't load CSS files somehow.. you're more than welcome to test this code and see what's the problems!
here is online version: http://browser.breet.co.il
thank you in advance!