- <%@LANGUAGE="JavaSCRIPT" CODEPAGE="65001"%>
8 G5 l- O/ G. M7 r - <%Response.Charset = "utf-8"%> , ]/ r2 S4 Y( u: p. c2 \7 U' D1 y
- <%
, l$ X# b0 i3 l1 j! d# r2 v) ^ - Server.ScriptTimeout=9999999;
- U0 x" N, L/ t: s+ f& h5 g+ m - var Surl = String(Request.QueryString("url")); 2 m" s$ k6 T- o) X h9 Y8 Z
- if(Surl == "undefined"){
9 K( R1 W! V# q, l* s- } - Response.Write("<p style="font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;">金光論壇 ASP WEB 在線代理程序 1.0 版</p>"); : O% d) c7 p' z- I
- Response.Write("<div style="font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;">"); , J [1 J: o* H: p! }& D
- Response.Write("<form action="#" method="get" >"); 5 P1 z4 }5 V4 l8 C- v' n
- Response.Write("<p style="font-size:9pt;margin:5px;text-align:center;">請鍵入網址</p>");
& n, l/ z- _6 L3 i: z# M" D - Response.Write("<p><input style="background-color: #FFCCCC;border: 1px solid #999999;" type="text" name="url"></p>"); S8 [5 K( v$ P S0 |. I
- Response.Write("<p><input style="background-color: #FFCCCC;border: 1px solid #999999;" type="submit" value="GoWeb"></p>"); 1 b" c9 Z) x( f) M
- Response.Write("</div>");
( H, @. f: m0 c& _ - } 1 C: i8 _! j- e0 p
- else if(Surl == ""){ - e: H6 c" B1 ]! j% \& y+ Q
- Response.Write("<p style="font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;">金光論壇 ASP WEB 在線代理程序 1.0 版</p>"); " x/ d! j) a3 H9 t, Q( `( l4 H0 S
- Response.Write("<div style="font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;">");
3 A' p6 d4 t9 o2 c9 ` - Response.Write("<p>您需要鍵入一個網址!例如: bbs.jgwy.net </p>");
i( p2 H. m! k+ J' }5 a- ~2 \+ ^& K - Response.Write("</div>"); 2 _* F1 \* n- e2 {- l: u- D4 _8 s" x
- }
8 i( Y+ r. j( H1 l" T4 M - else{
2 d$ ]; s n$ \4 k - Surl = (Surl.substr(0,7) != "http://") ? "http://"+Surl : Surl;
" D1 e. Z0 [% l M$ O& c; g! U - Response.Write(send_request(Surl));
$ _, A; Y, X# j* D/ N8 G/ M( Q - } * w$ S+ b) d* _0 e! I; Q/ s' ?
- function send_request(url) { 9 K+ q" H" M- _! Y8 J/ l3 y% d9 {
- var codedtext; . r$ E& ?' F! K9 t
- http_request = Server.CreateObject("Microsoft.XmlHTTP");
! B+ V- A( @9 R8 B7 O* z0 G - try{
0 L/ S g ~5 W1 c$ B0 W# o - http_request.Open("GET",url,false); , V, d. z* T/ m i
- http_request.Send(null);
3 G$ g$ J+ T0 ]$ b/ w - } # G! _# j" E& `, ~) X/ h. M
- catch(e)
% t" [6 O9 g* ] - { + ~" z8 ], \, L# u2 B! h9 f) J
- Response.Write(e.description); ' L/ F9 |5 A7 m2 ]9 V1 v
- }
; c# m3 A# f; n2 G; B' e" c - if (http_request.ReadyState == 4){ - I: x0 j8 E+ g; Z2 F6 d
- //自動判斷編碼開始
3 G9 h5 S S- {' h3 G1 f$ o - var charresult = http_request.ResponseText.match(/CharSet=(\S+)"/i);
. Q1 b6 E7 E. n - if (charresult != null){ * s- s2 _- f/ v9 e' J5 I
- var Cset = charresult[1];
0 _' ~* e/ \3 p$ ~) _& [ - }else{Cset = "utf-8"} " @' i4 E6 X# x$ {3 y0 c; [1 r
- //自動判斷編碼結束
) F6 u) j* N: K: p: v) T - codedtext = bytesToBSTR(http_request.Responsebody,Cset);
8 ^4 _: t8 c0 o - }else{
0 v4 d2 v5 h! w! `7 p: D5 ? - codedtext = "Erro"; * i* @$ Z! `3 B/ s
- }
4 y7 }4 M$ G Y" \( C8 C* g0 i - //替換超連接
$ k8 E, _, ^! ^6 F! h( Q, p - codedtext = codedtext.replace(/href="\/?/ig,"href=""+url+"/");
. c8 b5 S& R7 a# Y8 t8 r - codedtext = codedtext.replace(/(<a.*href=")/ig,"$1index.asp?url="); / K/ `$ |$ p7 v& ]0 I
- return(codedtext);
" L3 I+ B* R+ b5 W6 q - }
+ |+ ?. e) u# y# Q: y - function bytesToBSTR(body,Cset){ # B+ v9 ]0 s6 ^; ~4 N
- var objstream; $ s, ?, g1 Z- J) g2 c% x0 k
- objstream = Server.CreateObject("Adodb.Stream"); 3 d4 k, n, G: }1 g' I/ m/ D( Z ~
- objstream.Type = 1; 3 y! P* X6 w8 V+ k. y# d% e8 _2 h
- objstream.Mode = 3; " q2 ]" C$ x! B- H$ u5 Q
- objstream.Open();
2 R( U- E$ Z) b' ? - objstream.Write(body); + [, m; j& x6 i% W" h6 {) B9 F
- objstream.Position = 0; ( u# L' w. e# E
- objstream.Type = 2; 1 O, G3 V6 R# K4 p4 Z7 v9 I7 e& K
- objstream.Charset = Cset;
0 }3 z) w* j: i( Z5 ~ - bytesToBSTR = objstream.Readtext; 4 s" I& a$ b" ~* z- @
- objstream.Close; . H4 u: x' g* R0 J) l
- return(bytesToBSTR);
+ A# X+ T1 n \/ v: j - }
9 `; r: X% J a3 ~, [4 I% l5 h( y - function SaveRemoteFile(LocalFileName,RemoteFileUrl){
- Y+ g- n3 o- K1 n) m - var Retrieval,Ads;
# X, p8 y( I8 J t) S3 k. I. @7 L - Retrieval = Server.CreateObject("Microsoft.XmlHTTP"); + s" B$ j: r+ u! {, q% j5 G
- Retrieval.Open("GET",RemoteFileUrl,false); / O% y0 U3 x8 T/ K
- Retrieval.Send(null);
. ?3 A, `9 p5 c+ _5 E - if (Retrieval.ReadyState == 4){ 4 `- H% j3 @, g7 `
- Ads = Server.CreateObject("Adodb.Stream"); ! Y; O2 C4 `+ m$ H1 ]
- Ads.Type = 1;
: _ O3 Z0 y1 v$ W: ^. u - Ads.Open(); 8 `8 C8 N% b" S& E# n$ S
- Ads.Write(Retrieval.Responsebody); 8 J6 d& B ^; H# H7 F* }. T* J
- Ads.SaveToFile(Server.MapPath(LocalFileName),2); ; l$ |0 F' l9 i$ M: C: q. q
- Ads.Cancel; ! x( @6 P C2 J& q
- Ads.Close;
% p2 L8 F/ O% P5 l6 D - } + P" {! p ^- Y0 O" b
- } 0 m3 q8 J7 s4 P9 L3 A" P% ~& A
- //SaveRemoteFile("aa.gif","/XrssFile/2007-1/12/2007112124640411.gif"); 8 I, B. k+ q7 ~! \
- %>
複製代碼 |
|