ASP Download anti-theft chain code
First Type:
Finally to download the system to do a security chain measures, in the download of the page head did the following code, the relevant code is as follows:
Copy Code code as follows:
<%
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 "You download the software from the IT Learning Network, please download directly from the homepage, thank you <br>" ' Prevent hotlinking
Response.Write "<a href=http://www.itstudy.cn>it Learning Network http://www.itstudy.cn</a>" to prevent hotlinking
Response.End
End If
%>
The second type:
Copy Code code as follows:
<%
' Define function, read binary data with 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" ' filename
Response.ContentType = "Image/gif" setting (1)
Response. BinaryWrite Readbinaryfile (Server.MapPath ("2.gif")) ' is that you read the presence of local files to prevent being
Others know that the real path is stolen.
%>
(1) The following example sets the ContentType property to another common value.
Text/html, I won't tell you this.
Image/gif GIF Pictures
image/jpeg jpg Pictures
APPLICATION/X-CDF CDF Documentation
Application/wma is the watermelon which music type
You can refer to a Web browser document or the current HTTP specification
In this way, the use of ASP storage session,cookies, and read HTTP first-class special features can be completely real implementation of the Anti-Theft company, here
There is no cache set, if the traffic is huge, I think it would be better to set it.
The third type:
Easiest to submit forms, cross-station submission forms, burglar-proof chains with active Server pages outside the site ...
Method: Request.severvariables ("Http_referer")
Explanation: When someone links to up to the current page, Http_referer saves the user's source (routing)
For example, this example is very simple, just a matter of words, we can add more functions.
For example, you can see the contents of a file only if you log in first from "http://www.ITstudy.cn".
Source: index.asp
Copy Code code as follows:
<body>
<%
Option.explicit
Response.buffer=ture
%>
<%
Checkurl ("http://ITstudy.cn/index.jsp")
%>
<%
Function checkurl (URL)
Dim where:where=request.severvariables ("Http_referer")
If Where=url Then
Call Main ()
Else
Response.Write ("I'm sorry, you have to visit &url&" to get in!) ")
End If
End Function
%>
<%
Sub Main ()
Response.Write ("Here's the page you want to show")
End Sub
%>
</body>
This method is more effective to prevent hotlinking articles, outbound submission forms and Cross station submission forms, and it is not useful for software hotlinking such as. Rar.zip.exe.
I do not know whether you readers have a good idea, hehe.
Another way to do this is to judge the server and the address of the previous page.
Copy Code code as follows:
<%
dim from, local
from = request. ServerVariables ("Http_referer")
Local = request. ServerVariables ("SERVER_NAME")
If mid (from, 8, local) <>len (local) then
response.write "Do not submit data from outside"
else
call main ()
end if
Sub main ()
' your main content & nbsp
end sub
%>