Eg. "www.google.com" becomes "proxy.php?http://www.google.com"
Heres my script so far:
PROXY.PHP:
Code: Select all
<?php
//requesting the page
$source_data = @file_get_contents($_SERVER['QUERY_STRING'], FALSE);
$url_parsed = parse_url($_SERVER['QUERY_STRING']);
//Deep Link eg. http://google.com
$source_data = preg_replace('/(?<!type)=(["\']?)([a-zA-Z]{3,5}:\/\/[a-zA-Z0-9_.]{2,}\.[a-zA-Z]{2,5}[\/]?)\1/', "=$1".$_SERVER['PHP_SELF']."?$2$1",$source_data);
//Relative link eg. pic.jpg
$source_data = preg_replace('/(?<!type)=(["\']?)([a-zA-Z0-9\/%_-]+\.[a-zA-Z0-9]{2,5})[\/]?\1/', "=$1".$_SERVER['PHP_SELF']."?".$url_parsed['scheme']."://".$url_parsed['host']."/".$dir."$2$1", $source_data);
//Relative path eg. /pics/userpics
$source_data = preg_replace('/(?<!type)=(["\']?)[\/]?([a-zA-Z0-9%_-]+[\/]?)+\1/',
"=$1".$_SERVER['PHP_SELF']."?".$url_parsed['scheme']."://".$url_parsed['host']."/".$dir."$2$1",$source_data);
echo $source_data;
?>You can try it like this PROXY.PHP?http://google.com (remember http://)
I have used a test page you can try it on: http://glbyvej.dk/links.htm
Btw (?<!type) is there to make sure the regex doesnt regard <script type="text/javascript"> or <link type="text/css"> as links.
I really hope some one can help, thanks.