61 lines
2.0 KiB
Plaintext
61 lines
2.0 KiB
Plaintext
<% @Language="VBScript" CODEPAGE="65001" %>
|
|
<%
|
|
Set objwinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
|
|
url = "http://knas.kric.com/webapi/" & Request("call")
|
|
objwinHttp.Open "GET", url, false
|
|
objwinHttp.Send()
|
|
if Request("type") = "thumb" Then
|
|
Response.ContentType="image/jpg"
|
|
Response.BinaryWrite objWinHttp.ResponseBody
|
|
elseif Request("type") = "down" Then
|
|
Response.ContentType="application/unknown"
|
|
Response.CodePage = 949
|
|
Response.AddHeader "Content-Disposition", "attachment; filename=" & getFileName(url)
|
|
Response.BinaryWrite objWinHttp.ResponseBody
|
|
else
|
|
returnMsg = fnStreamBinaryToString(objWinHttp.ResponseBody, "UTF-8")
|
|
Response.ContentType="application/javascript;charset=utf-8"
|
|
Response.Write "[{""url"":"""
|
|
Response.Write url & """, ""req"":""" & Request("call") & """},"
|
|
Response.Write returnMsg
|
|
Response.Write "]"
|
|
end if
|
|
set objWinHttp = nothing
|
|
|
|
Function fnStreamBinaryToString(Binary, CharSet)
|
|
Const adTypeText = 2
|
|
Const adTypeBinary = 1
|
|
|
|
Dim BinaryStream
|
|
Set BinaryStream = CreateObject("ADODB.Stream")
|
|
|
|
BinaryStream.Type = adTypeBinary
|
|
|
|
BinaryStream.Open
|
|
BinaryStream.Write Binary
|
|
|
|
BinaryStream.Position = 0
|
|
BinaryStream.Type = adTypeText
|
|
|
|
If Len(CharSet) > 0 Then
|
|
BinaryStream.CharSet = CharSet
|
|
Else
|
|
BinaryStream.CharSet = "us-ascii"
|
|
End If
|
|
fnStreamBinaryToString = BinaryStream.ReadText
|
|
End Function
|
|
|
|
Function URLDecode(str)
|
|
Dim objScript
|
|
Set objScript = Server.CreateObject("ScriptControl")
|
|
objScript.Language = "JavaScript"
|
|
URLDecode = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))")
|
|
Set objScript = Nothing
|
|
End Function
|
|
|
|
Function getFileName(url)
|
|
Dim fullUrl : fullUrl = URLDecode(url)
|
|
Dim splitUrl : splitUrl = split(fullUrl, "/")
|
|
getFileName = splitUrl(UBound(splitUrl))
|
|
End Function
|
|
%> |