<codePage = 936%>
<html>
<head>
<Title> Untitled Document </Title>
<meta http-equiv = content-type content = text/html; charset = gb2312>
</head>
<body>
<%
dim FinishGetip, Showip, Allip
'' ////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Gestman
'' The program is not very streamlined, and then modify it later
'' The database used in this program is- "Feng Zhihong"-written- "Hacquent"-IP database and
The author of "Guohua Software Guohua Soft "-" Feng Guohua "— the" Global IP address allocation table.chm "written by the two
'' Thanks to the data provided by "Feng Zhihong" and "Feng Guohua"
There are many duplicate IP addresses in the database, I hope someone who is interested can delete it and reduce the database
'' My program is very clumsy. I hope everyone can give more opinions and communicate more, thank you!
'' ////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Gestman
'' Solution:
'' The client IP obtained is generally 202.11.25.1, and the IP format in the database is 202.011.025.001, which needs to be obtained.
'' The client IP is converted to the same format as IP in the database
'' Because the current IP we use is divided into 4 segments, each section of 3 places, and the middle is separated by "."
'' So my idea is to divide the client IP into 4 segments from "."
'' Then check each paragraph separately, if it is 3 bits, it will not change; if there are less than 3, it is 2 places, and 1 0 before this paragraph, 1, the same reason, then 2 0
After the formatting IP, the last section of the IP is removed, that is, the first 11 bits including "." Compared with the top 11 bits in the Startip field in the database, find the same value to find the same value
'' Because you can see from the database, the first three paragraphs of Startip and Endip are the same, and the last paragraph is just the internal subnet address, which can be removed
'' So as long as you take the first 11 digits of any field of Startip or Endip, compared with the top 11 of the client IP, you can find the correct location
'' ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Gons
Function Checkip_trueip ()
'' Take the client real IP
getclientip = request.servervariables (http_x_Forwarded_FOR) '' If the client uses the proxy server, use Request.Servervariables (Remote_addr) method. P_X_FORWARDED_FOR) method
If getclientip = then
GetClientip = Equest.servervariables (Remote_addr) '' If the client does not use the proxy, then Request.Servervariables (http_x_Forwardededded_For) is empty value. MOTE_ADDR) method
end if
checkip_trueip = getClientip
end function
'' ////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////
Function GetaccessRecordSet (DB, SQL, Mark, Read) ''
set conn = getaccessconn (DB) '' '' The relative path of the input parameter is DB-database, SQL-SQL statement, MARK, Read is a database reading method, 1,1 is read only, 1,3 is read and write for reading and writing is read and write.
'' constr = provider = microsoft.jet.oledb.4.0; & data source = & server.mAppath (db)
'Conn.open Constr
Set GetAccessRecordSet = Server.CreateObject (Adodb.oldSet)
GetaccessRecordSet.open SQL, Conn, Mark, Read
end function
'' ////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////
Function getaccessconn (db) '' 'to get the Connection object
Set GetAccessconn = Server.CreateObject (Adodb.Connection)
'' constr = driver = {microSoft Access Driver (*.mdb)}; dbq = & server.mAppath (allcon/#bbsall.mdb)
constr = provider = microsoft.jet.OLEDB.4.0; & Data Source = & Server.MAPPATH (DB)
getaccessconn.open constr
end function
'' ////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////
dim getip
'' Getip = (trim (Request.servervariables (Remote_addr))) ''
'' Getip = (trim (Request.querystring (Comes))) '' Input IP test by myself
'Response.write (Getip & <br>)
'' ////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////
Function Checkip_Locations (Checkstring) ''
Checkip_lock_Locations = Instr (Checkstring ,.) '' to give the value to the function
end function
'' ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////
'' The following functions are the division IP, and the IP remaining string of the IP on the right after each segmentation is obtained
Function Checkip_left (Checkstring)
locations_Left = Checkip_Locations (Checkstring) '' ''
iPlength_Left = Len (Checkstring) '' The length of the remaining string of the IP
Divide_locations_Left = iPlength_Left-Locations_Left '' to get the first place where the first appeared in the IP string "."
ipStr_Left = Right (Checkstring, Divide_locations_left) '' 'After the division is obtained, the remaining string of the IP remaining on the right of the "."
Checkip_left = ipstr_left '' to give the string obtained above to the function
end function
'' ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////
'' The following functions are the IP, and the IP string on the left side of the "." Symbol after each segmentation is obtained.
Function Checkip_right (Checkstring)
Locations_right = Checkip_Locations (Checkstring) ''
iPlength_right = Len (Checkstring) '' 'Get the IP string length
Divide_locations_right = iPlength_right-LOCATIONS_RIGHT '' 'to get the first place where the first appeared in the IP string, how many bits are from right to left
ipstr11 = Trim (REFT (Left (CheckString, Locations_right),.,) '' '' The "." on the left of the "."
'' If the IP is divided into 4 paragraphs, each paragraph is less than 3 digits, and 0
If Len (IPSTR11) = 2 then IPSTR11 = 0 & ipstr11
if len (ipstr11) = 3 then ipstr11 = ipstr11
If Len (IPSTR11) = 1 TheN IPSTR11 = 00 & ipstr11
Checkip_right = iPStr11 '' 'Before the "." Symbol, the IP score obtained after this segmentation