一个IP判断用户地址的问题,头都大了!高手帮帮忙
dim connIP,connstrIP,dbIP dbip="/datacnmai/ip.mdb"
Set connIP = Server.CreateObject("ADODB.Connection")
connstrIP="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(dbip)
'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)
connIP.Open connstrIP
Set RsConfig = conn.execute("Select dixz,diqi from config")
If rsConfig(1) = 1 Then
Dim arrCountry
arrCountry = Split(rsConfig(0)," ?")
Set rsConfig=Nothing
Dim IP,arrIp,IPcount,Address
IP = Request.ServerVariables("REMOTE_ADDR")
arrIP = Split(IP,".")
IPCount = arrIp(0)*256*256*256 + arrIP(1)*256*256 +arrIP(2)*256 + arrIP(3)
Set rsIP = server.createobject("adodb.recordset")
sqlIP="Select Country from cnmai_ip where (startid <"& ipCOunt &") and (endid > "& ipcount &") "
rsIP.open sqlIP,connIP,1,1
If Not(rsIP.eof And rsIP.bof) Then
Address = rsIP(0)
Dim mk
mk=0
For i=0 To UBound(arrCountry)-1
If (InStr(1,Address,arrCountry(i))>0) And (Trim(arrCountry(i)) <>"") Then
mk=1
Exit For
End If
Next
If mk = 0 Then
response.write (" <center> <br> <font color=red>本站仅允许XX地区用户发布信息! </font> <br> <br>如果您是XX地区用户而无法发布请联系QQ:XXXXX </center>")
response.write " <meta http-equiv=refresh content=""10;URL=index.asp"">"
response.End
End If
End If
End If
上面是别人帮我写的一段判断ip的代码,调用ip.mdb判断用户的ip,如果ip存在数据库中就可以发布信息。
例如有个用户ip是122.66.112.135,现在的ip数据库里没有。我想添加新的ip网段进ip数据库,应该怎么添加?
我用122×256×256×256+66×256×256+112×256+1(网段开始)和122×256×256×256+66×256×256+112×256+256(网段结束)计算出了数值。但添加数据库中后,用户还是不能发布信息。
请教各位高手,这个问题给我弄的头都大了