文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>PHP网页代理源代码

PHP网页代理源代码

时间:2007-03-15  来源:snowtty

 

<?
$ver = "1.0.0";
$copy="<!-- nsTWP v$ver :: nst.void.ru -->
              <!-- Network security team -->
                 <!-- Public version -->";
if(!$_GET['address']){
die("
<title>nsT web proxy $ver</title>
<body bgcolor=black>
<center>
<form method=get>
<font face=verdana size=1 color=silver>
PHP Web proxy :: <a href=http://nst.e-nex.com style='text-decoration:none'><font color=red>nst.e-nex.com</font></a><br>
Address: <input name=address size=50 style='border: 1px; background-color: #1A1A1A; color: green;' autocomplete=off>
<br>
Expl: <b>nst.e-nex.com</b> or <b>some_web.net/cmd.php?cmd=ls -la</b>
<br>
nsTWP v$ver
</form></font></center>\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


}
?>

相关阅读 更多 +
排行榜 更多 +
兵人放置战争

兵人放置战争

音乐节奏 下载
新豪足球

新豪足球

浏览阅读 下载
会玩

会玩

游戏工具 下载