当前位置: 首页 > 胡说八道 > 正文

Web 在线代理的 ASP 版!(开源)

[code]
<%@LANGUAGE="JavaSCRIPT" CODEPAGE="65001"%>
<%Response.Charset = "utf-8"%>
<%
Server.ScriptTimeout=9999999;
var Surl = String(Request.QueryString("url"));
if(Surl == "undefined"){
Response.Write("<p style=\"font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;\">ASP WEB 在线代理程序</p>");
Response.Write("<div style=\"font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;\">");
Response.Write("<form action=\"#\" method=\"get\" >");
Response.Write("<p style=\"font-size:9pt;margin:5px;text-align:center;\">请键入网址</p>");
Response.Write("<p><input style=\"background-color: #FFCCCC;border: 1px solid #999999;\" type=\"text\" name=\"url\"></p>");
Response.Write("<p><input style=\"background-color: #FFCCCC;border: 1px solid #999999;\" type=\"submit\"  value=\"GoWeb\"></p>");
Response.Write("</div>");
}
else if(Surl == ""){
Response.Write("<p style=\"font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;\">ASP WEB 在线代理程序</p>");
Response.Write("<div style=\"font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;\">");
Response.Write("<p>您需要键入一个网址!例如: zhzx.phpok.com </p>");
Response.Write("</div>");
}
else{
Surl = (Surl.substr(0,7) != "http://") ? "http://"+Surl : Surl;
Response.Write(send_request(Surl));
}
function send_request(url) {
    var codedtext;
    http_request = Server.CreateObject("Microsoft.XmlHTTP");
    try{
    http_request.Open("GET",url,false);
    http_request.Send(null);
    }
    catch(e)
    {
    Response.Write(e.description);
    }
    if (http_request.ReadyState == 4){
        //自动判断编码开始
        var charresult = http_request.ResponseText.match(/CharSet=(\S+)"/i);
        if (charresult != null){
        var Cset = charresult[1];
        }else{Cset = "utf-8"}
        //自动判断编码结束
        codedtext = bytesToBSTR(http_request.Responsebody,Cset);
        }else{
        codedtext = "Erro";
        }
        //替换超连接
        codedtext = codedtext.replace(/href="\/?/ig,"href=\""+url+"/");
        codedtext = codedtext.replace(/(<a.*href=")/ig,"$1servergate.asp?url=");
    return(codedtext);
}
function bytesToBSTR(body,Cset){
    var objstream;
    objstream = Server.CreateObject("Adodb.Stream");
    objstream.Type = 1;
    objstream.Mode = 3;
    objstream.Open();
    objstream.Write(body);
    objstream.Position = 0;
    objstream.Type = 2;
    objstream.Charset = Cset;
    bytesToBSTR = objstream.Readtext;
    objstream.Close;
    return(bytesToBSTR);
}
function SaveRemoteFile(LocalFileName,RemoteFileUrl){
    var Retrieval,Ads;
    Retrieval = Server.CreateObject("Microsoft.XmlHTTP");
    Retrieval.Open("GET",RemoteFileUrl,false);
    Retrieval.Send(null);
    if (Retrieval.ReadyState == 4){
    Ads = Server.CreateObject("Adodb.Stream");
    Ads.Type = 1;
    Ads.Open();
    Ads.Write(Retrieval.Responsebody);
    Ads.SaveToFile(Server.MapPath(LocalFileName),2);
    Ads.Cancel;
    Ads.Close;
    }
}
//SaveRemoteFile("aa.gif","/XrssFile/2007-1/12/2007112124640411.gif");
%>
[/code]

本文固定链接: http://www.zhzx.info/archives/145 | 赵泽鑫'S Blog

该日志由 赵泽鑫 于2008年10月01日发表在 胡说八道 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: Web 在线代理的 ASP 版!(开源) | 赵泽鑫'S Blog

Web 在线代理的 ASP 版!(开源):等您坐沙发呢!

发表评论

您必须 [ 登录 ] 才能发表留言!