网络编程
位置:首页>> 网络编程>> Asp编程>> ASP防盗链及防下载的方法(3)

ASP防盗链及防下载的方法(3)

 来源:51windows 发布时间:2007-09-19 12:22:00 

标签:防盗链,防下载,盗链,asp

 asp下载防盗链代码

第一种:

终于对下载系统做了个防盗链措施,在下载的页面头部做了如下代码,相关代码如下:


<%  
From_url = Cstr(Request.ServerVariables("HTTP_REFERER"))  
Serv_url = Cstr(Request.ServerVariables("SERVER_NAME"))  
if mid(From_url,8,len(Serv_url)) <> Serv_url and mid(From_url,8,len(Serv_url))<>"aspxhome.com" and mid(From_url,8,len(Serv_url))<>"www.aspxhome.com" then  
response.write "您下载的软件来自asp之家,请直接从主页下载,谢谢<br>" ’防止盗链  
response.write "<a href=http://www.aspxhome.com>asp之家http://www.aspxhome.com</a>" ’防止盗链  
response.end  
end if  
%>  

 


第二种:


<%   
  ’定义函数,用ADODB.Stream读取二进制数据   
  Function ReadBinaryFile(FileName)   
   Const adTypeBinary = 1   
   Dim BinaryStream   
   Set BinaryStream = CreateObject("ADODB.Stream")   
   BinaryStream.Type = adTypeBinary   
   BinaryStream.Open   
   BinaryStream.LoadFromFile FileName   
   ReadBinaryFile = BinaryStream.Read   
  End Function   
     
  Response.AddHeader "Content-Disposition", "attachment;filename=2.gif"’文件名   
  Response.ContentType = "image/GIF" ’设置(1)   
  response.Binarywrite ReadBinaryFile(server.mappath("2.gif"))’就是你读取存在本地的文件,防止被  
别人知道真实路径盗连的。   
     
  %> 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com