防盜鏈|下載 第一種:
終於對下載系統做了個防盜鏈措施,在下載的頁面頭部做了如下代碼,相關代碼如下:
<%
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))<>"ITstudy.cn" and mid(From_url,8,len(Serv_url))<>"www.ITstudy.cn" then
response.write "您下載的軟體來自IT學習網,請直接從首頁下載,謝謝<br>" ’防止盜鏈
response.write "<a href=http://www.ITstudy.cn>IT學習網http://www.ITstudy.cn</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
<%
Function CheckUrl(url)
Dim Where:Where=Request.SeverVariables("HTTP_REFERER")
If Where=url Then
Call main()
Else
Response.write("很抱歉,您必須從"&url&"訪問才能進來!")
End if
End Function
%>
<%
Sub main()
Response.write("這兒是你要顯示的網頁內容")
End sub
%>
</body>
</html>
還有一種方法就是用判斷伺服器及上一頁的地址來完成。
<%
dim from, local
from = request.ServerVariables("HTTP_REFERER")
local = request.ServerVariables("SERVER_NAME")
If mid(from, 8, local)<>Len(local) Then
response.write "不要從外部提交資料"
else
call main()
end if
sub main()
’你的主體內容
end sub
%>