Several tricks to protect your website from collection

Source: Internet
Author: User
Tags servervariables blank page
Today's collection system is more than an Nb. The content of websites that Webmasters have worked hard to collect and produce is always displayed on another website. One website is easily copied and copied. Is there a way to not affect the normal income of search engines, but to solve the pain point of website collection? The answer is yes.

The most common anti-collection methods are as follows:

1. the name of each article should not be regular. For example, your article is <% = ID %>. if HTM is used, generate a date before or after it, for example, 20070911-1234.htm. The date is before it, which is very effective for new users.

2. Do not place all articles in a directory. You can use the date to generate different directory names.

3. do not use one template for all articles. Make as many templates as possible. You can select which template to use when adding an article. Generally, the collector's collection program is targeted, he will analyze your page before collection. If you have irregular page layout, he will give up.

The above three methods can defend against primary collection, but they are useless for experts.

The following three methods use the IP address or session of the collector to prevent collection.

Method 1: (ASP code ):

<%
Dim appealnum, appealcount
Appealnum = 10' the same ip60 s request limit is 10 times
Appealcount = request. Cookies ("appealcount ")
If appealcount = "" then
Response. Cookies ("appealcount") = 1
Appealcount = 1
Response. Cookies ("appealcount"). expires = dateadd ("S", 60, now ())
Else
Response. Cookies ("appealcount") = appealcount + 1
Response. Cookies ("appealcount"). expires = dateadd ("S", 60, now ())
End if
If int (appealcount)> int (appealnum) then
Response. Write "web effects http://www.qpsh.com reminds you: capture tired, take a rest! "
Response. End
End if
%>

Method 2 (ASP ):

<%
User_agent = request. servervariables ("http_user_agent ")
Http_reffer = request. servervariables ("http_referer ")
SERVER_NAME = request. servervariables ("SERVER_NAME ")
'Check whether the current user is a spider.
Function check (user_agent)
Allow_agent = Split ("baiduspider, Scooter, ia_archiver, googlebot, fast-webcrawler, msnbot, slurp ",",")
Check_agent = false
For agenti = lbound (allow_agent) to ubound (allow_agent)
If instr (user_agent, allow_agent (agenti)> 0 then
Check_agent = true
Exit
End if
Next
Check = check_agent
End Function
If check (user_agent) = false then
If http_reffer = "" or left (http_reffer, Len ("http: //" & SERVER_NAME) + 1) <> "http: //" & SERVER_NAME & "/" then
%>
<HTML> <body>
<Form action = ''name = checkrefer id = checkrefer method = post>
</Form>
<SCRIPT>
Document. All. checkrefer. Action = Document. url;
Document. All. checkrefer. Submit ();
</SCRIPT>
</Body> <% Response. End
End if
End if
%>

Method 3:

Use persistence to add the session function for static pages

Generally, only the CGI programs (Asp, PHP, and JSP) on the server have the session function, which is used to save the activity data of the user during the website (session, for a large number of static pages (HTML), only client cookies can be used to store temporary activity data. However, cookies are a very cumbersome process, it is far from as simple as session operations. Therefore, this article recommends a solution "persistence technology" in DHTML to allow users to use session functions on static pages.

Both Microsoft Internet Explorer 5 and later versions support the persistence technology, allowing us to save some data objects to the client during the current session, reduces access requests to the server, makes full use of the client computer's data processing capabilities, and improves the overall page display efficiency.

Persistence technology has the following actions available for calling:

· Savefavorite-Save the Page Status and information when the page is added to favorites
· Savehistory-Save the Page Status and information in the current session
· Savesnapshot-when the page is saved to the hard disk, the page status and information are saved.
· Userdata-Saves Page Status and information in XML format in the current session
Persistence technology breaks the tradition of using cookies and sessions, inherits some security policies of cookies, and also increases the ability to store and manage data. Each page has a user data storage capacity of 64 KB, and each site has a total storage capacity of kb.

The data format stored by persistence technology complies with XML standards. Therefore, you can use the getattribute and setattribute methods in DOM technology to access data.

The following is a typical application of persistence technology. By analyzing the stored data of persistence, the static page has the verification function.

The actual judgment process is as follows:

1. There are three objects: Visitor V, navigation page A, and Content Page C.
2. Visitor V can only see Content Page C through the link of navigation page;
3. if the visitor v accesses the Content Page C through other means (for example, through a hyperlink from another website or directly entering the URL in the IE address bar), the Content Page C will automatically prompt the copyright information, A blank page is displayed.
Specific steps:

· Add a style to the navigation page to define the persistent class, and add the storage function fnsave for authorization.
<Style>
. Userdata {behavior: URL (# default # userdata );}
</Style>
<Script language = JavaScript>
Function fnsave (){
Opersistdiv. setattribute ("bisvalid", "true ");
Opersistdiv. Save ("oxmlstore ");
}
</SCRIPT>

· Define a layer in the <body> and </body> areas of the "navigation page" to identify the persistence object
<Div class = userdata id = "opersistdiv"> </div>

· Add a statement to the hyperlink attribute of the "navigation page" to call the function fnsave:
<A hrefpolic'redhat2.htm' onmousedown = "fnsave ()">

Next, add the verification function to the "content page.

· Add a style to the "content page" to define the persistent class, and add the storage function fnload to determine the validity.
<Style>
. Userdata {behavior: URL (# default # userdata );}
</Style>
<SCRIPT>
VaR bpagevalid = false;
Function fnload (){
Opersistdiv. Load ("oxmlstore ");
If (opersistdiv. getattribute ("bisvalid "))&&
(Opersistdiv. getattribute ("bisvalid") = "true ")){
Bpass = true;
}
Else {
Bpass = false;
}
Opersistdiv. setattribute ("bisvalid", "false ");
Opersistdiv. Save ("oxmlstore ");
If (bpass = false ){
VaR serror = "the source is unknown. Please authorize the website to visit us .";
Alert (serror );
Location. href = "about: blank ";
}
} </SCRIPT>

· Modify the "content page" area as follows:
<Body onload = "fnload ()">
<Div class = userdata id = "opersistdiv"> </div>

* ** The page for inserting the above Code must be in the same folder; otherwise, an error will occur.
From the above example, we can see that the use of persistence makes normal static content pages have the session function, and general non-sensitive information can be stored on the client through session.

Multiple Static pages with the session function can be used to complete many complex tasks, such as virtual shopping cart and advanced search engine. At the same time, the transfer of some session tasks previously undertaken by the server to the client reduces the amount of data interaction and greatly reduces the burden on the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.