ASP防盗链一个新思路
cnbruce的防盗链方法是采用了不定期修改文件夹的方法,而我想的是不定期修改文件名的方法,也算异曲同工之妙。
方法实现就是采用每个文件单独的文件夹,比如file/mp3_1/0711.mp3,当然在网站中下载的时候需要把文件夹名称存入数据库,采用download.asp?id=xxx读取文件夹名称,然后遍历文件夹里的文件,由于每个文件都有单独的文件夹,所以找到1个文件就可以开始下载了。
不定期的把文件夹都遍历一下,然后把里面的唯一文件重命名。
该过程也可以在用户下载开始前判断该文件上次修改时间决定是否应该重命名完成再开始下载过程。
附:
ASP重命名文件函数
<%
'==================================================
'FSO重命名文件
'by fisker http://ifisker.com lionkay@gmail.com
'==================================================
function ren(oldFile,newFile)
on Error Resume Next
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
oldFile = Server.MapPath(oldFile)
newFile = Server.MapPath(newFile)
objFSO.MoveFile oldFile, newFile
if err>0 then
err.clear
ren = False
else
ren = True
end if
set objFSO = nothing
end function
%>
'==================================================
'FSO重命名文件
'by fisker http://ifisker.com lionkay@gmail.com
'==================================================
function ren(oldFile,newFile)
on Error Resume Next
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
oldFile = Server.MapPath(oldFile)
newFile = Server.MapPath(newFile)
objFSO.MoveFile oldFile, newFile
if err>0 then
err.clear
ren = False
else
ren = True
end if
set objFSO = nothing
end function
%>
评论Feed: http://ifisker.com/blog/feed.asp?q=comment&id=1079
引用链接: loading...
浏览模式: 显示全部 |评论: 1 |引用: 0 | 排序 | 浏览: 0
[ 2008-03-13 00:42:41 ]
我去试下

