ASP writes a complete search class for IP location
<%
'Author: Xiao Hanxue (.)
'QQ number: 410000
= &HE10 '&H3C
= ("." = ".")
Dim IpSearch
'Create an object
Set IpSearch = New clsIpSearch
'This sentence establishes a connection to the SQL Server IP address library. You can use the default connection, but it must be guaranteed to exist.
= "DRIVER={SQL Server};SERVER=hostname:UID=sa;PWD=;DATABASE=Ip"
' Set the IP to be query, the default value is available, here is 127.0.0.1
= &H7F & "." & &H00 & "." & &H00 & "." & &H01
If ("IP")<>"" Then
If IpSearch.Valid_IP(("IP")) Then
= Trim(("IP"))
End If
End If
' Get the IP location, there are three feedback values, divided by commas
'The format is: the country or region, the local Internet area, the user name that provides the correct IP address information
("Site:" & () & "<br/>")
' Get out the IP address
("IP:" & & "<br/>")
' Convert IP address to numeric value
("IP converted to numeric value:" & () & "<br/>")
' Convert the IP address to a numeric value and restore it to an IP string
("Restore to IP:" & (()) & "<br/>")
("<hr>")
'Here is the test code
'dim a,b,c,d
'for a = 0 to 255
' for b= 0 to 255 step 20
' for c=0 to 255 step 20
' for d = 0 to 255 step 20
' = a & "." & b & "." & c & "." & d
' ("Site:" & () & "<br/>")
' ("IP:" & & "<br/>")
' ("IP converted to numeric value:" & () & "<br/>")
' ("Restore to IP:" & (()) & "<br/>")
' ("<hr>")
' next
' next
' next
'next
%>
<%
Class clsIpSearch
'##################################################################
'Statement: The data used by this program is null hunting for the famous IP tool software on the Internet" author "Feng Zhihong"
'Mr. carefully collected and organized.
'null hunt' database conversion method:
'Modify the file suffix name is
'Method 1:
' Start Access data, select Open database, and select the open file type "dBASE 5 (*.dbf)"
'Open the file and select the null database in the null database utility under the menu "Null Convert Database"
' Select the function of null to Access 97 format (version optional)> to save the file and become MDB format.
'Method 2:
'Use null provided by SQL Server to import and export data wizard.
' Method Brief Description: Set the DSN to be pointed in the ODBC Control Panel.
'Use null to import and export data wizard, select its correct driver and library to import.
' Or directly import the MDB file generated by the method to the library.
'Method Three:
' After opening the file with Access, the original library data will be automatically referenced through the MDB library.
'
'No other database platform is installed, other methods are not considered.
'################################### Class Description ####################################################
'# IP location search category
'# ConnectionString is a database connection declaration, and the default declaration of the directory of the same level is
'# IpAddress Please set it to the IP address for searching, and the current visitor IP is selected by default.
'# Class creation method
'# Dim objVal' declares a variable
'# Set objVal = New clsIpSearch 'Create class object
'# () 'Show the current visitor IP
'# IP search class method list:
'# .Valid_IP 'IP address correctness validation
'# Parameters: IP 'IP value or string
'# .CLongIP 'Convert IP address to a long integer value
'# Parameters: asNewIP 'The IP address string to be converted
'# .CStringIP 'Convert the value of a long integer to IP
'# Parameters: anNewIP 'To be restored to the value of the IP address
'# .GetClientIP 'Get the visitor's IP
'# .GetIpAddrInfo 'get the IP location where the IpAddRess property has been set
'# Property list (auto-initialization):
'# ConnEctionString 'ADo Access Database Connection Instructions
'# IpAddress 'The IP address to operate
'# Internal error handling:
'# If you are lacking, you have not done it, please add it yourself.
'##################################################################
Public ConnectionString
Public IpAddress
Private DBConn 'Connection object, module-level declaration
'────────────────────────────────
' Class Initialization
Private Sub Class_initialize()
' What is created here is the mdb library file generated through "Data conversion--Method 1"
ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & ("")
IpAddress = GetClientIP()
Set DBConn = OpenConnection()
End Sub
'────────────────────────────────
'Class logout
Private Sub Class_Terminate()
ConnectionString = Null
IpAddress = Null
Set DBConn = Nothing
End Sub
'────────────────────────────────
' Create a connection
Private Function OpenConnection()
Dim tmpConn
Set tmpConn=("")
ConnectionString
Set OpenConnection=tmpConn
Set tmpConn=nothing
End Function
'────────────────────────────────
'Execute an SQL command and return a dataset object
Private Function SQLExeCute(strSql)
Dim Rs
Set Rs=(strSQL)
Set SQLExeCute = Rs
Set Rs=nothing
End Function
ASP writes a complete search class for IP location (2)
------------------------------------
Previous page1234567891011121314151617181920Next pageRead the full text