asp download anti-theft link code
The first type:
Finally, an anti-theft link was taken to the download system. The following code was made at the head of the download page, and the relevant codes were as follows:
The code copy is as follows:
<% From_url=Cstr(Request.ServerVariables("HTTP_REFERER"))
Serv_url=Cstr(Request.ServerVariables("SERVER_NAME"))
ifmid(From_url,8,len(Serv_url))<>Serv_urlandmid(From_url,8,len(Serv_url))<>"ITstudy.cn"andmid(From_url,8,len(Serv_url))<>"www.ITstudy.cn"then
response.write "The software you downloaded is from IT Learning Network, please download it directly from the homepage, thank you<br>"'Prevent link theft
response.write"<ahref=http://www.ITstudy.cn>IT Learning Network http://www.ITstudy.cn</a>"'Prevent link theft
response.end
endif
%>
The second type:
The code copy is as follows:
<% 'Define the function and read binary data with ADODB.Stream
FunctionReadBinaryFile(FileName)
ConstadTypeBinary=1
DimBinaryStream
SetBinaryStream=CreateObject("ADODB.Stream")
BinaryStream.Type=adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFileFileName
ReadBinaryFile=BinaryStream.Read
EndFunction
Response.AddHeader"Content-Disposition","attachment;filename=2.gif"' file name
Response.ContentType="image/GIF"' Settings (1)
response.BinarywriteReadBinaryFile(server.mappath("2.gif"))' is to read files that exist locally to prevent them from being
Others know the real path to steal.
%>
(1) The following example sets the ContentType property to other common values.
I won't talk about text/HTML
image/GIFgif pictures
image/JPEGjpg picture
application/x-cdfcdf documentation
What kind of music type is application/wma?
For details, please refer to the web browser documentation or the current HTTP specification description.
In this way, using the asp storage session, cookies, and reading HTTP header special functions can completely realize theft protection.
There is no cache set, if the number of visits is huge, I would like to set it up.