『壹』 怎么在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)
%>