- <%@LANGUAGE="JavaSCRIPT" CODEPAGE="65001"%>
9 I% Y7 z+ x& ?( C0 l6 { - <%Response.Charset = "utf-8"%>
c* I( J X) C. o3 Y1 B2 G - <% % H! Z. Y/ V6 ^4 q3 [! d. J9 U+ s
- Server.ScriptTimeout=9999999; - q( c8 M- _7 {- k( {* |/ i9 X4 ]0 z: a
- var Surl = String(Request.QueryString("url")); 5 a8 H. r5 v. \' h! A1 h4 |
- if(Surl == "undefined"){ " R4 x' B$ M: G2 r
- 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>");
" S# ? O; f' Q' t/ e) w; v5 |$ F - Response.Write("<div style="font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;">");
$ X0 k7 b. E1 P- ? - Response.Write("<form action="#" method="get" >"); - i( N3 s7 w0 [( j" P
- Response.Write("<p style="font-size:9pt;margin:5px;text-align:center;">請鍵入網址</p>");
$ W. n+ ~# c3 E3 ^ - Response.Write("<p><input style="background-color: #FFCCCC;border: 1px solid #999999;" type="text" name="url"></p>");
9 G- u4 w2 Z8 w* K- n8 F% M - Response.Write("<p><input style="background-color: #FFCCCC;border: 1px solid #999999;" type="submit" value="GoWeb"></p>"); 3 D" I# K' Y# T
- Response.Write("</div>"); ! Z! b$ j5 ]9 ]9 [8 l( q& `
- } " t6 j- }& ?+ ?0 C
- else if(Surl == ""){
6 }# a" F0 L k+ Y - 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>");
# I9 I2 y* d# i# i5 d1 \4 p2 N - Response.Write("<div style="font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;">");
* _; ]% b, @' N8 v" e6 w' ^1 w - Response.Write("<p>您需要鍵入一個網址!例如: bbs.jgwy.net </p>");
- ^/ H) ~' @5 y0 F' _ - Response.Write("</div>"); 2 s' s) H& o5 y' B0 I/ b+ }
- }
; @* u- }6 l1 n - else{
* I. j% ?9 \5 k: S& o5 p - Surl = (Surl.substr(0,7) != "http://") ? "http://"+Surl : Surl;
) `5 k7 f, e( p" [/ h, e3 J. M - Response.Write(send_request(Surl)); ?% f6 Z; |* M% D
- }
' p' {% {! r2 x - function send_request(url) {
0 {' u5 U% V3 W' N5 p7 F$ F z' D - var codedtext;
( ~: P$ @7 @% q9 @ m! g* ]6 d - http_request = Server.CreateObject("Microsoft.XmlHTTP");
0 ~2 d: y9 ?# G$ @+ j3 y8 A - try{
3 @" ~* |( U1 x7 D% [! ] - http_request.Open("GET",url,false); - O2 Q2 A( N5 `% U0 f
- http_request.Send(null);
$ U6 e# |1 Y4 E, ~3 C6 g3 Z - }
( M6 o$ O+ m3 e/ _% b6 K5 v - catch(e)
' z, r' H) N7 ~8 x) J+ K/ K3 `3 B - { " E5 l6 V6 v* W
- Response.Write(e.description);
z9 E# n# I3 H: I) T - } 2 V7 r4 ~% o# X8 A* _* @& ~! t2 s
- if (http_request.ReadyState == 4){ 9 G4 U9 V+ r# P+ ~
- //自動判斷編碼開始 % _0 e7 d' G' _( j3 C6 q
- var charresult = http_request.ResponseText.match(/CharSet=(\S+)"/i); : O: B% C% t9 j! }& A1 ]( y7 X
- if (charresult != null){
4 ^" p, O9 _+ U/ K3 K - var Cset = charresult[1];
9 [ |3 E" V# F6 q6 @ - }else{Cset = "utf-8"} 4 W* T6 I) e" E% j5 e0 }# R
- //自動判斷編碼結束
1 k0 x& x$ @; ^) {8 J - codedtext = bytesToBSTR(http_request.Responsebody,Cset); 5 s: ~$ u6 T) c8 Y6 h2 T. _, j5 O# Z0 G
- }else{
# _3 \9 A& g: @& u! I - codedtext = "Erro";
@" W) g# ^% U( O* z$ o* o; x e) N - }
* h0 W2 N8 g" v - //替換超連接
, c* C9 h" x- `+ Q - codedtext = codedtext.replace(/href="\/?/ig,"href=""+url+"/"); Q% e2 [4 Q, t# S f$ p
- codedtext = codedtext.replace(/(<a.*href=")/ig,"$1index.asp?url="); 5 d% g8 m- l* h
- return(codedtext); 6 y) _! C% z( \, U. h+ q3 h
- }
& ~2 i$ x5 k4 Y, R - function bytesToBSTR(body,Cset){ * \5 b% Y5 D% Z' V
- var objstream;
0 F0 y$ H* F2 {' u8 U - objstream = Server.CreateObject("Adodb.Stream"); # b( b4 {, u+ Z: i2 P7 `, |& B# W
- objstream.Type = 1; ) h6 C, M# C1 v7 t/ q. y8 A/ y* b
- objstream.Mode = 3;
9 h7 p t& n | - objstream.Open(); . q3 B j* ^5 O3 [
- objstream.Write(body);
4 P# b- O* Y6 [( K( m( B( x - objstream.Position = 0;
$ o2 N Q% o1 u: ^- u - objstream.Type = 2; 5 E1 ^3 u2 I9 ?) d; O
- objstream.Charset = Cset; " q+ g" }( Y5 ^% x
- bytesToBSTR = objstream.Readtext; 4 ]8 V# Q: P3 p7 L1 j2 z9 q
- objstream.Close;
4 w7 N) g) T4 E" ` - return(bytesToBSTR);
* r X. c! N. L* L - }
9 q5 v! T/ D) S2 g/ x - function SaveRemoteFile(LocalFileName,RemoteFileUrl){ # I( h1 E) Y1 A7 ~ v' N n
- var Retrieval,Ads; 2 J; x) P8 @9 R, @/ K
- Retrieval = Server.CreateObject("Microsoft.XmlHTTP"); , z3 _4 ~9 C) x# {5 ]
- Retrieval.Open("GET",RemoteFileUrl,false);
7 B9 T1 w$ o5 @0 \+ w+ U! p! z - Retrieval.Send(null); ; l1 K! M$ \& y. U' e* q
- if (Retrieval.ReadyState == 4){ " ]2 k9 a) E" {; R+ T6 C; l5 h
- Ads = Server.CreateObject("Adodb.Stream"); 9 H2 ^ a$ h& ^" c
- Ads.Type = 1; 2 n# K9 P, R: N
- Ads.Open();
7 `9 Y& {- p& {6 \* g: @7 g8 p - Ads.Write(Retrieval.Responsebody); " e# y3 V; m7 R4 r, A! F* x# T
- Ads.SaveToFile(Server.MapPath(LocalFileName),2);
0 C! c' t$ ~- Y2 T, D: R - Ads.Cancel; % X6 ?# y. g, T) F* \8 a
- Ads.Close; p9 b& }# }6 q6 h2 x0 Z5 t" W
- } / F- ~0 `2 u" W! o+ W
- }
! v7 d' P) s1 D - //SaveRemoteFile("aa.gif","/XrssFile/2007-1/12/2007112124640411.gif"); 2 L3 f5 R9 h. f8 U
- %>
複製代碼 |
|