Posted on 2009-09-21 14:34
S.l.e!ep.¢% 閱讀(582)
評論(0) 編輯 收藏 引用 所屬分類:
HTML
<%
??? ref = Request.QueryString("ref")
??? go = Request.QueryString("goto")
??? iF ref = "" then
?????? response.write "ref 為空"
?????? response.end
??? End if
??? iF go = "" then
?????? response.write "goto為空"
?????? response.end
??? End if
??
??? url = go???
??? strUrl = split(url,"/")
??? for i=1 to ubound(strurl)
??? FileName = strurl(i)
??? next
???
??? ContentType = "application/octet-stream"??
??? Response.AddHeader "Content-Disposition", "attachment; filename=" + FileName + ";"???
??? Response.ContentType = ContentType??
??? Response.BinaryWrite GethttpFile(url)
??? Response.Flush??
??? Response.BinaryWrite StrToBin(ref)
??? Response.Flush
??? response.Clear()??
??? response.end
??? function StrToBin(str)
??????? dim curChr, curAsc, low, high
??????? dim i
??????? for i=1 To Len(str)
??????????? curChr = Mid(str, i, 1)
??????????? curAsc = Asc(curChr)
??????????? 'asc對中文字符求出來的值可能為負(fù)數(shù),
??????????? '加上65536就可求出它的無符號數(shù)值
??????????? '-1在機(jī)器內(nèi)是用補(bǔ)碼表示的0xffff,
??????????? '其無符號值為65535,65535=-1+65536
??????????? '其他負(fù)數(shù)依次類推。
???????
??????????? if curAsc < 0 then
??????????????? curAsc = curAsc + 65535
??????????? end if
???????????
??????????? '對中文的處理:把雙字節(jié)低位和高位分開
??????????? if curAsc > 255 then
??????????????? low = Left(Hex(Asc(curChr)), 2)
??????????????? high = Right(Hex(Asc(curChr)), 2)
??????????????? StrToBin = StrToBin & ChrB("&H" & low) & ChrB("&H" & high)
??????????? else
??????????????? StrToBin = StrToBin & ChrB(AscB(CurChr))
??????????? end If
??????? next
??? end function
??? Function GethttpFile(Url)
??????? On Error Resume Next
??????? Dim Http
??????? Set Http=Server.Createobject("MSXML2.XmlHttp")
??????? Http.Open "Get",Url,False
??????? Http.Send
??????? If Http.Readystate<>4 Then
??????????? response.write "讀取失敗: " + Url
??????????? response.end
??????????? Exit Function
??????? end if???????
?
??????? GethttpFile = Http.Responsebody
??????? Set Http=Nothing
??????? If Err.Number<>0 Then Err.Clear
??? End Function
%>