Pure ASP (VBscript) Write a global IP Address search procedures
<% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936"%>
<html>
<head>
<title> Untitled Document </ title>
<meta Http-equiv="Content-Type" content="text/html; charset=gb2312">
</ Head>
<body>
<%
Dim finishgetip, showip, allip
'///////////////////////////////////////////////// ///////////////////////////////////////
'This paper information
'This procedure from the original Arrow, to reprint please specify original author Arrow
Look at the source code and database and download Script56.CHM IP (including JScript all grammar, syntax VBscript all, the regular expression syntax) of a friend, please leave E-Mail!
'Copyright by Arrow mailto: E-Mail: Arrowy@163.net QQ: 9791769
'Procedure is not very concise, after further amendments
'This procedure used by the database - "FENG Zhi-hong" - written - "chase" - arising in the software database and IP
' "Guohong Guohua Soft software," the author - "Fengguohua" - written by the "global IP Address Allocation Table. Chm" by combining the
'Gratitude "FENG Zhi-hong" and "Fengguohua" provided by the data
'There is still a lot of database duplicate IP address, that effort can be removed, reducing the database
'I wrote the procedure is very clumsy, hope that we can provide more suggestions, and carry out more exchanges, thank you!
'///////////////////////////////////////////////// ///////////////////////////////////////
'Solutions:
'The client is generally 202.11.25.1 this IP, and IP data in the format 202.011.025.001, which will need the
'Client database and IP switch to IP in the same format
'This is because we use the IP is divided into four paragraphs, each three, in the middle "." Separation
'So my idea is to the client IP "." Symbols divided into four paragraphs, 202/11/25/1
'And then check every section, respectively, if it is three, will remain unchanged, if less than three, two, the paragraph before the meeting a 0, 1, empathy, 0-2
'Formatted by the IP, IP removed from the final section, including the admission that "." The former 11, and the data in the field in the first 11 startip phase comparison, the value of the same View
'Because we can see from the database, and endip startip the first three paragraphs are the same, and while the final section is internal subnet address, you can remove
'Therefore, as long as the admission startip endip or any of a field of 11 with former client IP phase of the first 11 correct comparison can be found on the location of
'///////////////////////////////////////////////// ////////////////////////////////////////
Function checkip_trueip ()
'Client from the real IP
Getclientip = Request.ServerVariables ( "HTTP_X_FORWARDED_FOR") 'If the client has a proxy server, used Request.ServerVariables ( "REMOTE_ADDR") method can only be null value, they should be used ServerVariables ( "HTTP_X_FORWARDED_FOR") method
If getclientip = "" Then
Getclientip = Request.ServerVariables ( "REMOTE_ADDR") 'If the client is useless agent, Request.ServerVariables ( "HTTP_X_FORWARDED_FOR") by the null value, we should use Request.ServerVariables ( "REMOTE_ADDR") method
End if
Checkip_trueip = getclientip
End function
'///////////////////////////////////////////////// ////////////////////////////
Function getaccessrecordset (db, sql, mark, and read) 'made Recordset object
Set conn = getaccessconn (db) 'input parameters for the database db-the relative path, sql-SQL statements mark, read the database read, for read-only 1,1, 1,3 for literacy
'Constr = "Provider = microsoft.jet.oledb.4.0;" & "data Source =" & Server.MapPath (db)
'Conn.open constr
Set getaccessrecordset = server.CreateObject ( "ADODB.Recordset")
Getaccessrecordset.open sql, conn, mark, read
End function
'///////////////////////////////////////////////// /////////////////////////
Function getaccessconn (db) 'in 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 ")))' from the client access to IP
'= Getip (trim (request.QueryString ( "comes")))' own input IP test
'Response.Write (getip & "<br>")
'///////////////////////////////////////////////// ///////////////////////
Function checkip_locations (checkstring) 'Back to the IP position in separate characters function
Checkip_locations = Instr (checkstring ,".") 'value will be given to the location of the function
End function
'///////////////////////////////////////////////// //////////////////////
'IP division for the following functions, in each segment "." Symbol of the right of the remaining string IP
Function checkip_left (checkstring)
Locations_left = checkip_locations (checkstring) 'get in the IP remaining string "." The first time the location of
Len iplength_left = (checkstring) 'IP remaining in the length of the string
Divide_locations_left = iplength_left-locations_left 'made in the remaining string IP "." The first time in the position, left from right is the number of how many
Ipstr_left = Right (checkstring, divide_locations_left) 'in this division, "." Symbol of the right of the remaining string IP
Checkip_left = ipstr_left 'will be the string above assign function
End function
'///////////////////////////////////////////////// //////////////////////
'IP division for the following functions, in each segment "." Symbol string left IP, IP will be divided into four paragraphs, each section of the string
Function checkip_right (checkstring)
Locations_right = checkip_locations (checkstring) 'made in the IP "." The first time the location of
Len iplength_right = (checkstring) 'length of the string IP
Divide_locations_right = iplength_right-locations_right 'made in the remaining string IP "." The first time in the position, left from right is the number of how many
Ipstr11 = Trim (Replace (Left (checkstring, locations_right ),".","")) 'will be the "." Removed from the left side of the strings "." Symbol
'If IP divided into four each paragraph after paragraph, less than three-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 'get "." Symbol before the string, that is, this segment of the IP be divided into four paragraphs of the section after
End function
'///////////////////////////////////////////////// /////////////////////
'IP check whether the internal network IP
'I wrote the judgement is :127.0.0.0-127. XXX.XXX.255 and 192.0.0.0-192. XXX.XXX.255 basis, if these two, it is the internal network IP, contrary to the external network
'Judgement internal IP is the basis for what I do not know, a lot here to the guidance of experts, and be amended to contact me
Function checkiplocal (checkstring)
Dim re1
Set re1 = new RegExp 'is a regular expression object
'Re1.pattern expression for the internal network IP 127 or 192 should be the beginning, middle arbitrary 1-3 to 0-9 in a Digital "." Section of
Re1.pattern = "^ (127 \. [0-9] (1,3) \. [0-9] (1,3) \. [0-9] (1,3)) | (192 \. [0-9] (1,3) \. [0-9] (1,3) \. [0-9] (1,3)) $ "
Re1.global = false
Re1.Ignorecase = false
Checkiplocal = re1.test (checkstring)
Set re1 = nothing
End function
'///////////////////////////////////////////////// /////////////////////
Function checkip_remote (checkstring)
Dim iplength 'string the length of IP
Dim locations' "." Characters in the location
Len iplength = (checksting)
Instr locations = (checkstring ,".") 'from left to right Retrieval "." Symbols in IP string the first time in the position
'To "." Characters will be divided into 4 of IP
Locations2 = iplength-locations
Ipstring1 = Left (checkstring, locations)
Ipstring2 = Right (checkstring, locations2)
End function
'///////////////////////////////////////////////// /////////////////////
'///////////////////////////////////////////////// //////////////////////
Ipinfo_local = "Your IP is the internal network IP!"
Ipinfo_remote = "external IP network."
Checkip_trueip = getip ()
Currentip = checkiplocal (getip) 'call checkiplocal () function to get the IP inspection to determine the network address internal or external network address
'If currentip = true then' test code
'Response.Write (ipinfo_local)
If currentip = true then 'to leave
Response.Write (ipinfo_local) 'for the internal network IP
Else
'Conversion
'The following is extracted by-cycle-0 IP will be divided into four paragraphs
Checkip_locations locations = (getip) 'achieved "." In the first division before IP in the first place
Len iplength = (getip) 'in the length of the client IP
Divide_locations = iplength-locations' in the client IP right to left few left to the right IP few first "." Position
Ipstr1 = Trim (Replace (Left (getip, locations ),".",""))
Ipstr2 = Right (getip, divide_locations) 'after the first split the remaining client Numerical right
'If IP divided into four each paragraph after paragraph, less than three-0
If Len (ipstr1) = "2" then ipstr1 = "0" & ipstr1 'length of 2, less than three, before meeting in a string 0
If Len (ipstr1) = "3" then ipstr1 = ipstr1 'According to the analogy
If Len (ipstr1) = "1" then ipstr1 = "00" & ipstr1 'At that moment, the IP for the first ipstr1
Ipstr12 = checkip_right (ipstr2) 'This time, in the second paragraph of ipstr12 for IP
Ipstr122 = checkip_left (ipstr2)
Ipstr13 = checkip_right (ipstr122) 'This time, in the third paragraph of ipstr13 for IP
Ipstr14 = checkip_left (ipstr122) 'This time, in the fourth paragraph of ipstr14 for IP
If Len (ipstr14) = "1" then ipstr14 = "00" & ipstr14 'to be carried out in the fourth paragraph of the IP-0, this step can not
If Len (ipstr14) = "2" then ipstr14 = "0" & ipstr14
If Len (ipstr14) = "3" then ipstr14 = ipstr14
'Response.write ipstr1 & "<br>"' write IP segmentation of the value of each
'Response.write ipstr12 & "<br>"
'Response.write ipstr13 & "<br>"
'Response.write ipstr14
Allip = ipstr1 &"."& ipstr12 &"."& ipstr13 &"."& ipstr14
Finishgetip = left (allip, 11)
Dim ipaddr, iplocal, sqls
'The following SQL statement to extract startip left field value equivalent to 11 IP client to the left of the value of the 11
Sqls = "SELECT country_state, areauser FROM ip WHERE Left (startip, 11 )='"& finishgetip &" ' "
Getaccessrecordset set rs = ( "# worldip.mdb" sqls, "1", "1") 'value by enquiries
If rs.eof then, 'If you do not find the same with the client the value of IP
Checkip_trueip showip = () 'to the client IP showip
Ipaddr = "unknown territory" 'countries or provinces
Iplocal = "unknown location" 'specific places
Else
Checkip_trueip showip = ()
Ipaddr = rs ( "country_state")
Iplocal = rs ( "areauser")
End if
'Response.write ( "Your IP is:" showip & & "")
'Response.write ( "You come from:" & ipaddr & "")
'Response.write ( "You is:" & iplocal)
Rs.close
Set rs = nothing
%>
<% = "Your IP is:" & & showip ""%>
<% = "You come from:" & & ipaddr ""%>
<% = "You are:" & & iplocal "<br>"%>
If the IP address is wrong, please contact me, or download the database corrections, Thank you! <br>
<table Width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td Width="203"> <a href="Script56.rar"> download Script56.CHM </ a> -> 1.34M </ td>
<td Width="548"> Description: Microsoft's help files, VBscript grammar, syntax JScript, the regular expression </ td>
<td Width="3"> </ td>
<td Width="6"> </ td>
</ Tr>
<tr>
<td> </ Td>
<td> </ Td>
<td> </ Td>
<td> </ Td>
</ Tr>
<tr>
<td> <a Href="ipsearch.rar"> download ASP global IP Address search procedures </ a> </ td>
<td> ASP + ACCESS size of 401 K; format rar </ td>
<td> </ Td>
<td> </ Td>
</ Tr>
<tr>
<td> </ Td>
<td> <font Color="#000099"> </ font> <font color="#0000FF"> </ font> </ td>
<td> </ Td>
<td> </ Td>
</ Tr>
<tr>
<td> If your IP is unknown, and if you wish, please submit your Location: </ td>
<td>
<form Name="form1" method="post" action="postip.asp">
<table Width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td Width="21%"> provinces: </ td>
<td Width="44%">
<input Type="text" name="country_state">
</ Td>
<td Width="35%"> </ td>
</ Tr>
<tr>
<td Width="21%"> specific location or what network users: </ td>
<td Width="44%">
<input Type="text" name="areauser">
</ Td>
<td Width="35%"> For example: Qinghua University, Beijing or Beijing Netcom users </ td>
</ Tr>
<tr>
<td Width="21%"> </ td>
<td Width="44%">
<Input type = "hidden" name = "startip" value ="<%= finishgetip & ".000 "%>">
<Input type = "hidden" name = "endip" value ="<%= finishgetip & ".255 "%>">
</ Td>
<td Width="35%"> </ td>
</ Tr>
<tr>
<td Width="21%"> </ td>
<td Width="44%">
<input Type="submit" name="Submit" value="æäº¤">
</ Td>
<td Width="35%"> </ td>
</ Tr>
</ Table>
</ Form>
</ Td>
<td> </ Td>
<td> </ Td>
</ Tr>
</ Table>
<%
End if
%>
</ Body>
</ Html>
Tags: ip, IP address, vbscript








0 Comments to “Pure ASP (VBscript) Write a global IP Address search procedures”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.