ado|stream|xml| Original <%
'------------------------------------------------------------------------
'-------------------boundless domain: http://www.5inet.net/---------------------
'-------------------Author: Hip Hop Hey, webmaster@5inet.net-----------------
'----------get content remotely and have the content on the local computer, including any files! ----------
'---------------use XMLHTTP and adodb.stream, cool! Absolutely original! -----------------
' On Error Resume Next
' Set ' the content type to the specific type of you are sending.
' Response.ContentType = ' image/jpeg '
'-------------------------------defines the output format-----------------------------
Path=request.querystring ("P")
spath = Path
If left (LCase (path), 7) <> "http://" then
'-------------if HTTP is not in front of the local file, give LocalFile processing------------
LocalFile (PATH)
Else
'--------------------Otherwise for remote files, to RemoteFile processing------------------
RemoteFile (Path)
End If
' Response.Write Err. Description
Sub LocalFile (Path)
'-------------------simply jump to the page if it is a local file-------------------
Response.Redirect Path
End Sub
Sub RemoteFile (spath)
'-------------------------processing remote file Functions------------------------------
FileName = GetFileName (spath)
'-------------GetFileName the process of converting addresses to qualified file names-------------
filename = Server.MapPath ("/uploadfile/cache/" & filename)
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
' Response.Write FileName
If Objfso.fileexists (FileName) Then
'--------------Check to see if the file is already visited, and if so, simply jump------------
Response.Redirect "/uploadfile/cache/" & GetFileName (Path)
Else
'----------------Otherwise, read the GetBody function First----------------------
' Response.Write Path
t = GetBody (Path)
'-----------------is written to the browser using the binary method--------------------------
Response.BinaryWrite T
Response.Flush
'-----------------Output buffer------------------------------------------
SaveFile T,getfilename (PATH)
'------------------cache the contents of the file to the local path for the next visit-----------
End If
Set objFSO = Nothing
End Sub
Function getbody (URL)
'-----------------------function for remote fetch of content---------------------
' On Error Resume Next
' Response.Write URL
Set retrieval = CreateObject ("Microsoft.XMLHTTP")
'----------------------set up the XMLHTTP object-----------------------------
With retrieval
. Open "Get", url, False, "", ""
'------------------send-----------------------with Get, asynchronous method
. Send
' GetBody =. ResponseText
GetBody =. Responsebody
'------------------function returns the contents of the Fetch--------------------------
End With
Set retrieval = Nothing
' Response. Write Err. Description
End Function
Function GetFileName (str)
'-------------------------This function is a qualified filename function-------------------
str = Replace (LCase (str), "http://", "")
str = Replace (LCase (str), "//", "/")
str = Replace (str, "/", "")
str = replace (STR,VBCRLF, "")
GetFileName = str
End Function
Sub SaveFile (Str,fname)
'-------------------------this function to save the contents of the stream-------------------
' On Error Resume Next
Set objstream = Server.CreateObject ("ADODB. Stream ")
'--------------set up the ADODB.stream object, you must have more than ADO 2.5 version---------
objStream.Type = adTypeBinary
'-------------open in binary mode-------------------------------------
objStream.Open
Objstream.write Str
&nb