『壹』 怎麼在ASP製作中。把訪問著IP寫入到資料庫里具體怎麼做
Request.ServerVariables("橘槐HTTP_X_FORWARDED_FOR") 為讀取用戶IP,直接添加記錄讀取到資料庫返虧表裡。比如:rs("列名"漏伍神)=Request.ServerVariables("HTTP_X_FORWARDED_FOR") 就可以了。
『貳』 在ASP網頁中,如何顯示瀏覽者的ip及地理位置
首先,是前人寫的ASP查詢純真IP的類,請保存為cz.asp
需要一個ip資料庫,把cz.asp,serach.asp和cz.dat資料庫放在一起。
<%
Class TQQWry
Dim Country,LocalStr,Buf,OffSet
Private StartIP,EndIP,CountryFlag
Public FirstStartIP,LastStartIP,RecordCount,QQWryFile
Private Stream,EndIPOff
Private Sub Class_Initialize
Country=""
LocalStr=""
StartIP=0
EndIP=0
CountryFlag=0
FirstStartIP=0
LastStartIP=0
EndIPOff=0
QQWryFile=Server.MapPath("cz.dat")
End Sub
Public Sub SetPath(p)
QQWryFile = Server.MapPath(p)
End Sub
Function IP2Int(IP)
Dim IPArray,i
IPArray=Split(IP,".",-1)
FOr i=0 to 3
If Not IsNumeric(IPArray(i)) Then IPArray(i)=0
If CInt(IPArray(i))<0 Then IPArray(i)=Abs(CInt(IPArray(i)))
If CInt(IPArray(i))>攔搏亮255 Then IPArray(i)=255
Next
IP2Int=(CInt(IPArray(0))*256*256*256)+(CInt(IPArray(1))*256*256)+(CInt(IPArray(2))*256)+CInt(IPArray(3))'-1
End Function
Function Int2IP(IntValue)
p4=IntValue-Fix(IntValue/256)*256
IntValue=(IntValue-p4)/簡寬256
p3=IntValue-Fix(IntValue/256)*256
IntValue=(IntValue-p3)/256
p2=IntValue-Fix(IntValue/256)*256
IntValue=(IntValue-p2)/256
p1=IntValue
Int2IP=Cstr(p1)&"."&Cstr(p2)&銀芹"."&Cstr(p3)&"."&Cstr(p4)
End Function
Private Function GetStartIP(RecNo)
OffSet=FirstStartIP+RecNo * 7
Stream.Position=OffSet
Buf=Stream.Read(7)
EndIPOff=AscB(MidB(Buf,5,1))+(AscB(MidB(Buf,6,1))*256)+(AscB(MidB(Buf,7,1))*256*256)
StartIP=AscB(MidB(Buf,1,1))+(AscB(MidB(Buf,2,1))*256)+(AscB(MidB(Buf,3,1))*256*256)+(AscB(MidB(Buf,4,1))*256*256*256)
GetStartIP=StartIP
End Function
Private Function GetEndIP()
Stream.Position=EndIPOff
Buf=Stream.Read(5)
EndIP=AscB(MidB(Buf,1,1))+(AscB(MidB(Buf,2,1))*256)+(AscB(MidB(Buf,3,1))*256*256)+(AscB(MidB(Buf,4,1))*256*256*256)
CountryFlag=AscB(MidB(Buf,5,1))
GetEndIP=EndIP
End Function
Private Sub GetCountry(IP)
If (CountryFlag=1 Or CountryFlag=2) Then
Country=GetFlagStr(EndIPOff+4)
If CountryFlag=1 Then
LocalStr=GetFlagStr(Stream.Position)
If IP>= IP2Int("255.255.255.0") And IP<=IP2Int("255.255.255.255") Then
LocalStr=GetFlagStr(EndIPOff+21)
Country=GetFlagStr(EndIPOff+12)
End If
Else
LocalStr=GetFlagStr(EndIPOff+8)
End If
Else
Country=GetFlagStr(EndIPOff+4)
LocalStr=GetFlagStr(Stream.Position)
End If
Country=Trim(Country)
LocalStr=Trim(LocalStr)
If InStr(Country,"CZ88.net") Then Country = "IALVIN.CN"
If InStr(LocalStr,"CZ88.net") Then LocalStr = "IALVIN.CN"
End Sub
Private Function GetFlagStr(OffSet)
Dim Flag
Flag=0
Do While (True)
Stream.Position=OffSet
Flag=AscB(Stream.Read(1))
If(Flag=1 Or Flag=2 ) Then
Buf=Stream.Read(3)
If (Flag=2 ) Then
CountryFlag=2
EndIPOff=OffSet-4
End If
OffSet=AscB(MidB(Buf,1,1))+(AscB(MidB(Buf,2,1))*256)+(AscB(MidB(Buf,3,1))*256*256)
Else
Exit Do
End If
Loop
If (OffSet<12 ) Then
GetFlagStr=""
Else
Stream.Position=OffSet
GetFlagStr=GetStr()
End If
End Function
Private Function GetStr()
Dim c
GetStr=""
Do While (True)
c=AscB(Stream.Read(1))
If (c=0) Then Exit Do
If c>127 Then
If Stream.EOS Then Exit Do
GetStr=GetStr&Chr(AscW(ChrB(AscB(Stream.Read(1)))&ChrB(C)))
Else
GetStr=GetStr&Chr(c)
End If
Loop
End Function
Public Function QQWry(DotIP)
Dim IP,nRet
Dim RangB,RangE,RecNo
IP=IP2Int(DotIP)
Set Stream=CreateObject("ADodb.Stream")
Stream.Mode=3
Stream.Type=1
Stream.Open
Stream.LoadFromFile QQWryFile
Stream.Position=0
Buf=Stream.Read(8)
FirstStartIP=AscB(MidB(Buf,1,1))+(AscB(MidB(Buf,2,1))*256)+(AscB(MidB(Buf,3,1))*256*256)+(AscB(MidB(Buf,4,1))*256*256*256)
LastStartIP=AscB(MidB(Buf,5,1))+(AscB(MidB(Buf,6,1))*256)+(AscB(MidB(Buf,7,1))*256*256)+(AscB(MidB(Buf,8,1))*256*256*256)
RecordCount=Int((LastStartIP-FirstStartIP)/7)
If (RecordCount<=1) Then
Country="Unknow"
QQWry=2
Exit Function
End If
RangB=0
RangE=RecordCount
Do While (RangB<(RangE-1))
RecNo=Int((RangB+RangE)/2)
Call GetStartIP (RecNo)
If (IP=StartIP) Then
RangB=RecNo
Exit Do
End If
If (IP>StartIP) Then
RangB=RecNo
Else
RangE=RecNo
End If
Loop
Call GetStartIP(RangB)
Call GetEndIP()
If (StartIP<=IP) And ( EndIP>=IP) Then
nRet=0
Else
nRet=3
End If
Call GetCountry(IP)
QQWry=nRet
End Function
Private Sub Class_Terminate()
On ErrOr Resume Next
Stream.Close
If Err Then Err.Clear
Set Stream=Nothing
End Sub
End Class
Function Look_Ip(path,IP)
Dim Wry, IPType, QQWryVersion, IpCounter
Set Wry = New TQQWry
Wry.SetPath path
On Error Resume Next
IPType = Wry.QQWry(IP)
Look_Ip = Wry.Country & " - " & Wry.LocalStr
If Err Then
Err.Clear
Look_Ip = "查詢出錯"
End If
End Function
%>
下面是查詢代碼,請保存為search.asp
<!--#include file="cz.asp" -->
<%
Dim IP
ip=request.querystring("ip")
if trim(ip)="" then
IP=Request.ServerVariables("REMOTE_ADDR")
elseif ubound(split(trim(ip),"."))<>3 then
IP=Request.ServerVariables("REMOTE_ADDR") 'ip地址
end if
IPAdd=Look_Ip("cz.dat",IP) '這里注意,資料庫文件名是cz.dat
response.write IPAdd
%>
『叄』 如何查找所有物理IP地址屬於某個地區的網站
湊下熱鬧,幫樓主提升人氣
1--ping命令一般在局域網路中實行,外網的話,去計算機學院找個考績好的來做吧
2--asp通過Request.ServerVariables("REMOTE_ADDR") --Request.ServerVariables("HTTP_X_FORWARDED_FOR") 來獲取來訪者的真實ip,盡管有一定的技術支持,但是成功率為88%
net一般不會主動探測真實ip,只要代理有效都當真實地址允許訪問
介紹以上廢話是我覺得個人要想通過技術手段來偵測一個站點的真實ip比較有難度 ,因為水平遠胡談在普通網友之上的站點尚不能繞過代理100%獲取用戶真實ip
3--做網站必須要辦的2件事情是購買/租用空間喊凱,購買/租用伺服器;就憑這2點而言,一個物理地址在鄭州的站點要讓訪問者看到其真實地址,前提應該是 不對地址進行演算法加密,自己架設伺服器/使用鄭州伺服器 如果我經營一站點,估計能把地址拉多遠就拉多遠,絕對不會隨便給人看到「哎呀,這個站點物理地址是廣西柳州!!」
4--另外安全可靠穩定的伺服器基本上不願意被人繞過,或者不通過它這個中轉站自行向它另一頭的客戶端(對它來說使用它的服務的站點跟你這個訪問者都算客戶端)發送數據或截取數據,按照常規操作一般我們得到的結果是使用地址顯示為鄭州的伺服器所代管的站點(就是樓主說的所謂「掛鄭州牌子」),而不是物理地址確實為鄭州的站點
5--申明,本人非專業,我在這里無論是伺服器託管還是自我架設都統一說為獨立伺服器~~~~~免得自己越說越亂
6--樓主要想實現查找到所有物理地址為鄭州的站點,理論上有幾種方法,要麼是同服務商取得聯系,從他的交易記錄和安全監控處可以看到各個站點的真實ip;要麼同鄭州網監部門取得聯系,通過他們的備案/申報記錄可以看到所有物理地址為鄭州的站點;要麼直闖鄭州網路服務商(電信/鐵/網通)機房,要求工作人員立刻給出站點清單
7--TCP/IP協議的作用和應用原理以及《網路基礎》中各種案例如果能倒背如流,查站點還是有希望的!!
總之,沒有簡單有效的辦法,技術含量高,沒有相關工具/軟體提供支持,非要查,考慮闖機房/掃埠
如果有辦法使用google earth,那麼又是另一番境地,不僅可以查到褲滲碰站點,連查工作人員他們家在哪條街哪棟樓哪一戶都不成問題,可惜google不給我們用
『肆』 誰能幫我寫段ASP獲取IP地理位置的代碼並寫入資料庫
剛回答了一個問題,與這個相似..
是採用QQ的ip資料庫.
1.將QQ安裝目錄下的QQwry.dat文件復制到asp文件夾下
2.建立一個asp文件,如文件名ip.asp.代碼內容為:
<%
'文件名:ip.asp 與QQwry.dat放在一個文件夾下面
'使用:在要用到的查詢ip的asp頁面中最前面加入<!--#include file = "ip.asp"-->
'然後可以用address(getIP())獲得請求的地理位置
'=========================================================
'臘衡 IP物理定位搜索類 Version 3.0.0
' QQWry.DAT 利用程序 修改自互聯網流傳代碼
' 本類在ASP環境中使用純真版QQWry.dat通過完美測試
' 如或卜果您的伺服器環境不支持ADodb.Stream,將無法使用此程序
' 推薦使用純真資料庫,更新也方便
' ========================================================
' ============================================
' 返回IP信息
' 如address("127.0.0.1")
' 返回值為:"本機地址 CZ88.NET"
' ============================================
Function address(sip)
Dim Wry, IPType
Set Wry = New TQQWry
IPType = Wry.QQWry(sip)
address=""&Wry.Country & " " & Wry.LocalStr &""
End Function
'獲得請求的實際IP地址
Function getIP()
Dim strIPAddr
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
Else
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End If
getIP = Trim(Mid(strIPAddr, 1, 30))
End Function
Function Look_Ip(IP)
Dim Wry, IPType, QQWryVersion, IpCounter
' 設置類對象
Set Wry = New TQQWry
' 開始搜索衫局穗,並返回搜索結果
' 您可以根據 QQWry(IP) 返回值來判斷該IP地址在資料庫中是否存在,如果不存在可以執行其他的一些操作
' 比如您自建一個資料庫作為追捕等,這里我就不詳細說明了
IPType = Wry.QQWry(IP)
' Country:國家地區欄位
' LocalStr:省市及其他信息欄位
Look_Ip = Wry.Country & " " & Wry.LocalStr
End Function
' ============================================
' 返回IP信息 JS調用
' ============================================
Function GetIpInfoAv(IP, sType)
Dim Wry, IPType
Set Wry = New TQQWry
IPType = Wry.QQWry(IP)
Select Case sType
Case 1 GetIpInfoAv = "document.write(""" & IP & """);"
Case 2 GetIpInfoAv = "document.write(""" & Wry.Country & """);"
Case 3 GetIpInfoAv = "document.write(""" & Wry.LocalStr & """);"
Case Else GetIpInfoAv = "document.write(""您來自:" & IP & " 所在區域:" & Wry.Country & " " & Wry.LocalStr & """);"
End Select
End Function
' ============================================
' 返回QQWry信息
' ============================================
Function WryInfo()
Dim Wry, IPType, QQWry(1)
' 設置類對象
Set Wry = New TQQWry
IPType = Wry.QQWry("255.255.255.255")
' 讀取資料庫版本信息
QQWry(0) = Wry.Country & " " & Wry.LocalStr
' 讀取資料庫IP地址數目
QQWry(1) = Wry.RecordCount + 1
WryInfo = QQWry
End Function
' ============================================
' 愛雪兒IP物理定位搜索類
' ============================================
Class TQQWry
' ============================================
' 變數聲名
' ============================================
Dim Country, LocalStr, Buf, OffSet
Private StartIP, EndIP, CountryFlag
Public QQWryFile
Public FirstStartIP, LastStartIP, RecordCount
Private Stream, EndIPOff
' ============================================
' 類模塊初始化
' ============================================
Private Sub Class_Initialize
Country = ""
LocalStr = ""
StartIP = 0
EndIP = 0
CountryFlag = 0
FirstStartIP = 0
LastStartIP = 0
EndIPOff = 0
QQWryFile = Server.MapPath("QQWry.dat") 'QQ IP庫路徑,要轉換成物理路徑
End Sub
' ============================================
' IP地址轉換成整數
' ============================================
Function IPToInt(IP)
Dim IPArray, i
IPArray = Split(IP, ".", -1)
FOr i = 0 to 3
If Not IsNumeric(IPArray(i)) Then IPArray(i) = 0
If CInt(IPArray(i)) < 0 Then IPArray(i) = Abs(CInt(IPArray(i)))
If CInt(IPArray(i)) > 255 Then IPArray(i) = 255
Next
IPToInt = (CInt(IPArray(0))*256*256*256) + (CInt(IPArray(1))*256*256) + (CInt(IPArray(2))*256) + CInt(IPArray(3))
End Function
' ============================================
' 整數逆轉IP地址
' ============================================
Function IntToIP(IntValue)
p4 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue-p4)/256
p3 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue-p3)/256
p2 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue - p2)/256
p1 = IntValue
IntToIP = Cstr(p1) & "." & Cstr(p2) & "." & Cstr(p3) & "." & Cstr(p4)
End Function
' ============================================
' 獲取開始IP位置
' ============================================
Private Function GetStartIP(RecNo)
OffSet = FirstStartIP + RecNo * 7
Stream.Position = OffSet
Buf = Stream.Read(7)
EndIPOff = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256)
StartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
GetStartIP = StartIP
End Function
' ============================================
' 獲取結束IP位置
' ============================================
Private Function GetEndIP()
Stream.Position = EndIPOff
Buf = Stream.Read(5)
EndIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
CountryFlag = AscB(MidB(Buf, 5, 1))
GetEndIP = EndIP
End Function
' ============================================
' 獲取地域信息,包含國家和和省市
' ============================================
Private Sub GetCountry(IP)
If (CountryFlag = 1 Or CountryFlag = 2) Then
Country = GetFlagStr(EndIPOff + 4)
If CountryFlag = 1 Then
LocalStr = GetFlagStr(Stream.Position)
' 以下用來獲取資料庫版本信息
If IP >= IPToInt("255.255.255.0") And IP <= IPToInt("255.255.255.255") Then
LocalStr = GetFlagStr(EndIPOff + 21)
Country = GetFlagStr(EndIPOff + 12)
End If
Else
LocalStr = GetFlagStr(EndIPOff + 8)
End If
Else
Country = GetFlagStr(EndIPOff + 4)
LocalStr = GetFlagStr(Stream.Position)
End If
' 過濾資料庫中的無用信息
Country = Trim(Country)
LocalStr = Trim(LocalStr)
If InStr(Country, "CZ88.NET") Then Country = "114XP.CN"
If InStr(LocalStr, "CZ88.NET") Then LocalStr = "114XP.CN"
End Sub
' ============================================
' 獲取IP地址標識符
' ============================================
Private Function GetFlagStr(OffSet)
Dim Flag
Flag = 0
Do While (True)
Stream.Position = OffSet
Flag = AscB(Stream.Read(1))
If(Flag = 1 Or Flag = 2 ) Then
Buf = Stream.Read(3)
If (Flag = 2 ) Then
CountryFlag = 2
EndIPOff = OffSet - 4
End If
OffSet = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256)
Else
Exit Do
End If
Loop
If (OffSet < 12 ) Then
GetFlagStr = ""
Else
Stream.Position = OffSet
GetFlagStr = GetStr()
End If
End Function
' ============================================
' 獲取字串信息
' ============================================
Private Function GetStr()
Dim c
GetStr = ""
Do While (True)
c = AscB(Stream.Read(1))
If (c = 0) Then Exit Do
'如果是雙位元組,就進行高位元組在結合低位元組合成一個字元
If c > 127 Then
If Stream.EOS Then Exit Do
GetStr = GetStr & Chr(AscW(ChrB(AscB(Stream.Read(1))) & ChrB(C)))
Else
GetStr = GetStr & Chr(c)
End If
Loop
End Function
' ============================================
' 核心函數,執行IP搜索
' ============================================
Public Function QQWry(DotIP)
Dim IP, nRet
Dim RangB, RangE, RecNo
IP = IPToInt (DotIP)
Set Stream = CreateObject("ADodb.Stream")
Stream.Mode = 3
Stream.Type = 1
Stream.Open
Stream.LoadFromFile QQWryFile
Stream.Position = 0
Buf = Stream.Read(8)
FirstStartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
LastStartIP = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256) + (AscB(MidB(Buf, 8, 1))*256*256*256)
RecordCount = Int((LastStartIP - FirstStartIP)/7)
' 在資料庫中找不到任何IP地址
If (RecordCount <= 1) Then
Country = "未知"
QQWry = 2
Exit Function
End If
RangB = 0
RangE = RecordCount
Do While (RangB < (RangE - 1))
RecNo = Int((RangB + RangE)/2)
Call GetStartIP (RecNo)
If (IP = StartIP) Then
RangB = RecNo
Exit Do
End If
If (IP > StartIP) Then
RangB = RecNo
Else
RangE = RecNo
End If
Loop
Call GetStartIP(RangB)
Call GetEndIP()
If (StartIP <= IP) And ( EndIP >= IP) Then
' 沒有找到
nRet = 0
Else
' 正常
nRet = 3
End If
Call GetCountry(IP)
QQWry = nRet
End Function
' ============================================
' 類終結
' ============================================
Private Sub Class_Terminate
On ErrOr Resume Next
Stream.Close
If Err Then Err.Clear
Set Stream = Nothing
End Sub
End Class
%>
3.要查詢ip的asp頁面內加入:
<!--#include file = "ip.asp"-->
<%
dim ip,ipx
ip=getIP()
ipx=address(ip)
%>
詳情: http://..com/question/63283862.html
要是回答的內容有問題,或認為不妥,請發送網路消息給我,消息內容加上本頁網址哦。。
·
『伍』 asp utf-8編碼下讀取純真資料庫亂碼
如果是accesse資料庫的話,基本上是你的網頁的問題拆穗,我相信你的charset值肯定已經是utf-8了,那麼在asp的第一行應該有一悄運個:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="啟御梁65001"%>
不知道你改了沒有,如果你仍然是936的話,那實際上就會和下面的charset有沖突。
如果你沒有這句的話,請添加上去試試。
--------------------------------------
『陸』 怎麼實現ASP里IP獲取具體地理位置
第一步獲取來訪IP地址
<%ip=request.ServerVariables("REMOTE_ADDR")
response.write "你的IP是" & ip
%>
第二步下載全國IP資料庫,最好用純真的 如果告滲閉找不到找我要 QQ:21616898
第三步
代碼太場我不向寫了 以前寫過相應的程序 演示喊粗地址
http://www.aspsub.cn/ip.asp
我這個襪裂程序就是採用的 asp+ACCESS實現的 只要你的電腦支持ASP 就一定能運行
『柒』 純真IP資料庫在ASP。NET網站中如何用C#
應為在遠程伺服器上,沒有 F:\商務網站設計\QQip\ip\QQWry.Dat
你需要把它改寫成 Server.MapPath("/ip/QQWry.Dat");
然後版把 QQWry.Dat 文件放在網站的ip 目錄下權
『捌』 ASP如何獲取真實IP地址
<%PrivateFunctiongetIP()
DimstrIPAddr
IfRequest.ServerVariables("HTTP_X_FORWARDED_FOR")=""ORInStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),"unknown"絕廳)>0Then
strIPAddr=Request.ServerVariables("REMOTE_ADDR")
ElseIfInStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),並蘆隱",")>0Then
strIPAddr=Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),1,InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),",")-1)
ElseIfInStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),";")>0Then
strIPAddr=Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"嘩睜),1,InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),";")-1)
Else
strIPAddr=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
EndIf
getIP=Trim(Mid(strIPAddr,1,30))
EndFunction
ip=getIP()
response.write(ip)
%>