阳光越强烈
阴影就越是深邃

PHP网页代理源代码

把以下代码保持为Php的文件,上传到服务器就可以了!



<?
$ver = "1.0.0";
$copy="

                 ";
if(!$_GET['address']){
die("
nsT web proxy $ver
PHP Web proxy :: nst.e-nex.com
Address:
Expl: nst.e-nex.com or some_web.net/cmd.php?cmd=ls -la
nsTWP v$ver
\n
$copy
");
}else{
$address = $_GET['address'];
$php_self= $_SERVER['PHP_SELF'];
# v1.1 #
$x=$address;
$c=strlen($x);
if($x{0}.$x{1}.$x{2}.$x{3}.$x{4}.$x{5}.$x{6}=="http://"){
for($i=7; $i$c; $i++){
        $total.=$x{$i};
        }
$address=$total;
}
# end of v1.1 #
$get_add = explode("/",$address,2);
if($_GET['address']){
$fp = @fsockopen($get_add[0], 80);
$out = "GET /$get_add[1] HTTP/1.0\r\n";
$out .= "Host: $get_add[0]\r\n";
$out .= "\r\n";
$out .= "Connection: Close\r\n\r\n";
for(fwrite($fp, $out);trim(fgets($fp)););
while (!feof($fp)) {
$info.=fgets($fp, 128);
}
fclose($fp);
$script_url=$php_self;
$web=$info;
preg_match_all("#\s(href|src|action|codebase|url)=([\"\'])?(.*?)([\"\'])?([\s\>])#i", $web, $matches, PREG_SET_ORDER);
foreach ($matches as $match)
{
$uri = trim($match[3]);
$fragment = ($hash_pos = strpos($uri, '#') !== false) ? '#' . substr($uri, $hash_pos) : '';
$addr=parse_url("http://".$address."/");
$path=pathinfo($addr['path']);
$path=$path['dirname'];
$path=str_replace("\\","",$path);
if(!eregi("$address",$uri) and !eregi("http://",$uri)){$uri="http://".$addr['host']."/$path/$uri";}
if(substr_count($uri, "http://".$addr['host']."/")>1){$uri=str_replace("http://".$addr['host']."/","",$uri); $uri="http://".$addr['host']."/$uri";}
$url=$uri;
$c=strlen($url);
for($i=0; $i$c; $i++){
$cp=substr($url, $i, $i+1);
if(substr($url,$i-2,2)=="//" and substr($url,$i-3,3)!="://"){
$url=substr_replace($url, '', $i-2, 1);
}
}
$uri=$url;
$replace = ' ' . $match[1] . '=' . $match[2] . $script_url . '?address=' . $uri . $fragment . $match[4] . $match[5];
$web = str_replace($match[0], $replace, $web);
}
print $web;
} #end of go
}
?>

 

赞(0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址