第二個完善過的《ASP編寫完整的一個IP所在地搜尋類》

來源:互聯網
上載者:User
<%
Server.ScriptTimeout = &HE10 '&H3C
Response.Buffer = ("S.F." = "S.F.")
Dim IpSearch
'建立對象
Set IpSearch = New clsIpSearch
' 該句建立SQL Server的IP地址庫的串連,可使用預設串連,但要保證存在wry.mdb
IpSearch.ConnectionString = "DRIVER={SQL Server};SERVER=hostname:UID=sa;PWD=;DATABASE=Ip"
' 設定要查詢的IP,可用預設值,這裡設定的是 127.0.0.1
IpSearch.IpAddress = &H7F & "." & &H00 & "." & &H00 & "." & &H01
If Request.QueryString("IP")<>"" Then
If IpSearch.Valid_IP(Request.QueryString("IP")) Then
IpSearch.IpAddress = Trim(Request.QueryString("IP"))
End If
End If
' 取得IP 所在地,反饋值有三個,以逗號分割
' 格式為:所在國家或地區,當地上網地區,提供正確IP地址資訊的使用者名稱
Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "<br>")
' 取出IP地址
Response.Write ("IP:" & IpSearch.IpAddress & "<br>")
' 將IP地址轉換為數值
Response.Write ("IP轉換為數值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "<br>")
' 將IP地址轉換為數值後還原成IP字串
Response.Write ("數值還原成IP:" & IpSearch.CStringIP(IpSearch.CLongIP(IpSearch.IpAddress)) & "<br>")
Response.Write ("<hr>")
'這裡是測試代碼
'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
' IpSearch.IpAddress = a & "." & b & "." & c & "." & d
' Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "<br>")
' Response.Write ("IP:" & IpSearch.IpAddress & "<br>")
' Response.Write ("IP轉換為數值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "<br>")

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.