str1=left(sip,instr(sip,".")-1)问题 asp问题 求高手回答
答案:1 悬赏:30 手机版
解决时间 2021-03-25 08:23
- 提问者网友:火车头
- 2021-03-24 15:59
str1=left(sip,instr(sip,".")-1)问题 asp问题 求高手回答
最佳答案
- 五星知识达人网友:往事隔山水
- 2021-03-24 16:24
什么错误,是不是sip有可能不是ip格式,你可以加个判断
<%
function ipp(sip)
adb = "../ip.mdb"
aConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(adb)
Set AConn = Server.CreateObject("ADODB.Connection")
aConn.Open aConnStr
if IsIp(sip)=false then
sip="192.168.0.1"
end if
If sip="127.0.0.1" Then sip="192.168.0.1" end if
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
sql="select * from address where ip1 <="&num&" and ip2 >="&num
set rsa=aconn.execute(sql)
if not rsa.eof then
ipp=rsa("country")
else
ipp="未知地区"
end if
rsa.close
set aconn=nothing
end function
Function IsIp(str)
Dim patn
patn = "^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)$"
IsIp = RegTest(patn,str)
End Function
Function RegTest(pattern,strTest)
RegTest = False
Dim regEx, Matchs
Set regEx = New RegExp
regEx.Pattern = pattern
regEx.IgnoreCase = False
regEx.Global = True
RegTest = regEx.Test(strTest)
End Function
%>
<%
function ipp(sip)
adb = "../ip.mdb"
aConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(adb)
Set AConn = Server.CreateObject("ADODB.Connection")
aConn.Open aConnStr
if IsIp(sip)=false then
sip="192.168.0.1"
end if
If sip="127.0.0.1" Then sip="192.168.0.1" end if
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
sql="select * from address where ip1 <="&num&" and ip2 >="&num
set rsa=aconn.execute(sql)
if not rsa.eof then
ipp=rsa("country")
else
ipp="未知地区"
end if
rsa.close
set aconn=nothing
end function
Function IsIp(str)
Dim patn
patn = "^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)$"
IsIp = RegTest(patn,str)
End Function
Function RegTest(pattern,strTest)
RegTest = False
Dim regEx, Matchs
Set regEx = New RegExp
regEx.Pattern = pattern
regEx.IgnoreCase = False
regEx.Global = True
RegTest = regEx.Test(strTest)
End Function
%>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯