A New Method for ASP dynamic page anti-collection

Source: Internet
Author: User
Tags servervariables

I saw an anti-collection software on the internet yesterday, saying that the collection only accesses the current web page, but does not access the images and Js of the Web page. Today, I suddenly think that through dynamicProgramAnd JS access respectively record the visitor's IP address, and then judge the IP address, because the collection process does not access JS, only the IP address recorded with dynamic programs will be found during the collection, instead, there will be no IPS recorded through js to prevent collection of web programs.
The anti-collection principle is very simple. First, place a dynamic statement, add the visitor's IP address to a table in the database, and then add a JS at the bottom of the page. js directly accesses the dynamic page, add the visitor's IP address to another table in the database. When you access the IP address again, read the IP address data from the two tables and then judge the time difference. If the IP address is found only in the first table, the IP address cannot be found in the second table, or the time difference exceeds 10 seconds, it is regarded as collection.
Advantages
1. Simple deployment. It can be easily implemented as long as it is a dynamic language.
2. high lethality, which can block almost all collection processes
Disadvantages
1. The first disadvantage is that it is highly lethal. If you need to use it, consider some special cases to avoid mistaken killing of search crawlers that have already been killed.
2. Static pages cannot be used only for dynamic webpages
The Process Writing is messy, but the principle itself is not very complicated. The program example is attached below, which should be quickly understood by understanding ASP.
Program example (ASP + ACCESS) (download Test Program ):
1. Create a database
Table 1: IP1, field ip1_adderss (text), ip1_time (date/time, default value = now ())
Table 2: ip2, field ip2_adderss (text), ip2_time (date/time, default value = now ())
2. index. asp (Dynamic onlyCode, See the test program for all the code)

Copy code The Code is as follows: <% @ Language = "VBScript" codePage = "936" %>
<%
Dim Conn, RS, sqlstr, IP, iptime, iptime2, newuser
Newuser = 0
Set conn = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("data. mdb ")
Conn. Open connstr
IP = request. servervariables ("remote_addr ")
Sqlstr = "select * from [IP1] Where ip1_address = '" & IP & "'order by ip1_id DESC"
Rs. Open sqlstr, Conn, 1, 3
If Rs. EOF then
Newuser = 1
Application. Lock ()
Rs. addnew ()
RS ("ipdomainaddress") = IP
Rs. Update ()
Application. Unlock ()
Else
Iptime = RS ("ip1_time ")
Application. Lock ()
Rs. addnew ()
RS ("ipdomainaddress") = IP
Rs. Update ()
Application. Unlock ()
End if
Rs. Close
If newuser = 0 then
Sqlstr = "select * from [ip2] Where ip2_address = '" & IP & "'order by ip2_id DESC"
Rs. Open sqlstr, Conn, 1, 3
If Rs. EOF then
Rs. Close
Response. Write ("do not collect! ")
Response. End ()
Else
Iptime2 = RS ("ip2_time ")
If datediff ("S", iptime2, iptime)> 10 then
Rs. Close
Response. Write ("do not collect! ")
Response. End ()
End if
End if
Rs. Close
End if
%>

3. js. aspCopy codeThe Code is as follows: <%
Dim Conn, RS, sqlstr, IP
Set conn = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("data. mdb ")
Conn. Open connstr
IP = request. servervariables ("remote_addr ")
Sqlstr = "select * from [ip2]"
Rs. Open sqlstr, Conn, 1, 3
Application. Lock ()
Rs. addnew ()
RS ("ip2_address") = IP
Rs. Update ()
Application. Unlock ()
Rs. Close
%>

4. Get. asp Copy code The Code is as follows: <% @ Language = "VBScript" codePage = "936" %>
<%
Response. Write (server. htmlencode (gethttppage ("http: // localhost/index. asp", "gb2312 ")))
'====================================
'Function name: gethttppage
'Usage: Get the page Source code Function
'Parameter: URL httpurl
'====================================
Function gethttppage (httpurl, code)
If isnull (httpurl) = true or httpurl = "" then
Gethttppage = "Site A is under maintenance! "
Exit Function
End if
On Error resume next
Dim HTTP
Set HTTP = server. Createobject ("MSX" & "ml2.xml" & "HTTP ")
HTTP. Open "get", httpurl, false
HTTP. Send ()
If HTTP. readystate <> 4 then
Set HTTP = nothing
Gethttppage = "Site B is under maintenance! "
Exit Function
End if
Gethttppage = bytestobstr (HTTP. responsebody, code)
Set HTTP = nothing
If err. Number <> 0 then
Err. Clear
Gethttppage = "C site maintenance in progress! "
Exit Function
End if
End Function
'====================================
'Function name: bytestobstr
'Usage: conversion encoding function
'Parameter: String body, encoding cset
'====================================
Function bytestobstr (body, cset)
Dim objstream
Set objstream = server. Createobject ("Ado" & "D" & "B. St" & "re" & "am ")
Objstream. type = 1
Objstream. mode = 3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. type = 2
Objstream. charset = cset
Bytestobstr = objstream. readtext
Objstream. Close
Set objstream = nothing
End Function
%>

This article is original from fanka online. For more information, see the source. If there are similarities, it is a coincidence!

Related Article

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.