| VB 源码 | VC 源码 | ASP源码 | JSP源码 | PHP源码 | CGI源码 | FLASH源码 | 素材模板 | C 源程序 | 站长工具 | 站长教程 |

ASP技术

ASP技术
PHP技术
JSP技术
VB技术
.NET技术

本类阅读TOP10

·ASP如何获取真实IP地址
·Asp中五种连接数据库的方法
·解密ASP源代码
·ASP编程技巧大全[1]
·快速打造留言本教程[1]
·ASP中也能解压缩rar文件
·浅谈如何建立三层体系结构的ASP应用程序(2)
·用ASP发送邮件
·浅谈如何建立三层体系结构的ASP应用程序(1)
·使ACCESS数据库保持同步

站内搜索

远程获取内容,并将内容存在本地电脑上,包括任何文件
<%
'------------------------------------------------------------------------
'-------------------无垠网域:http://www.5inet.net/ ---------------------
'-------------------作者:嘻哈呵嘿 ,[email protected] -----------------
'----------远程获取内容,并将内容存在本地电脑上,包括任何文件!----------
'---------------利用xmlhttp和adodb.stream,酷!绝对原创!-----------------
'On Error Resume Next
'Set the content type to the specific type that you are sending.
'Response.ContentType = "IMAGE/JPEG"
'-------------------------------定义输出格式-----------------------------

Path=request.querystring("p")
sPath = Path
if left(lcase(path),7) <> "http://" then
'-------------如果前面没有http就是本地文件,交给LocalFile处理------------
LocalFile(path)
else
'--------------------否则为远程文件,交给RemoteFile处理------------------
RemoteFile(Path)
end if
'Response.Write err.Description

sub LocalFile(Path)
'-------------------如果为本地文件则简单的跳转到该页面-------------------
Response.Redirect Path
End Sub

Sub RemoteFile(sPath)
'-------------------------处理远程文件函数------------------------------
FileName = GetFileName(sPath)
'-------------GetFileName为把地址转换为合格的文件名过程-------------
FileName = Server.MapPath("/UploadFile/Cache/" & FileName)
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
'Response.Write fileName
if objFso.FileExists(FileName) Then
'--------------检查文件是否是已经访问过,如是,则简单跳转------------
Response.Redirect "/uploadfile/cache/" & GetFileName(path)
Else
'----------------否则的话就先用GetBody函数读取----------------------
'Response.Write Path
t = GetBody(Path)
'-----------------用二进制方法写到浏览器上--------------------------
Response.BinaryWrite t
Response.Flush
'-----------------输出缓冲------------------------------------------
SaveFile t,GetFileName(path)
'------------------将文件内容缓存到本地路径,以待下次访问-----------
End if
Set objFso = Nothing
End Sub

Function GetBody(url)
'-----------------------本函数为远程获取内容的函数---------------------
'on error resume next
'Response.Write url
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
'----------------------建立XMLHTTP对象-----------------------------
With Retrieval
.Open "Get", url, False, "", ""
'------------------用Get,异步的方法发送-----------------------
.Send
'GetBody = .ResponseText
GetBody = .ResponseBody
'------------------函数返回获取的内容--------------------------
End With
Set Retrieval = Nothing
'response.Write err.Description
End Function

Function GetFileName(str)
'-------------------------本函数为合格化的文件名函数-------------------
str = Replace(lcase(str),"http://","")
str = Replace(lcase(str),"//","/")
str = Replace(str,"/","")
str = replace(str,vbcrlf,"")
GetFileName = str
End Function

sub SaveFile(str,fName)
'-------------------------本函数为将流内容存盘的函数-------------------
'on error resume next
Set objStream = Server.CreateObject("ADODB.Stream")
'--------------建立ADODB.Stream对象,必须要ADO 2.5以上版本---------
objStream.Type = adTypeBinary
'-------------以二进制模式打开-------------------------------------
objStream.Open
objstream.write str
'--------------------将字符串内容写入缓冲--------------------------
'response.Write fname
objstream.SaveToFile "c:\inetpub\myweb\uploadfile\cache\" & fName,adSaveCreateOverWrite
'--------------------将缓冲的内容写入文件--------------------------
'response.BinaryWrite objstream.Read
objstream.Close()
set objstream = nothing
'-----------------------关闭对象,释放资源-------------------------
'response.Write err.Description
End sub
%>


相关文章
  • 远程复制更省力 用CuteFTP实现FXP
  • 不需要任何工具,远程屏蔽telnet服务的ntlm认证
  • ActivePerl PerlIS.dll 远程缓冲区
  • 远程破OICQ密码给工具QQExplorer ver 1.25介绍
  • 微软"帮助和支持中心"远程代码执行漏洞
  • 用ASP实现远程批量文件改名
  • 用ASP实现远程批量文件改名(一)
  • 用ASP实现远程批量文件改名(二)
  • 相关软件

  • 用Winsock实现远程聊天  
  • 远程文件管理系统 2.0
  • 远程桌面客户端
  • 远程注册程序  
  • 一个远程控制软件  
  • 远程注册  

  • 下载首页关于我们广告服务联系方式常见问题隐私声明法律条款本站声明下载帮助发布软件站点地图谷歌卫星地图