如何将获取后的IP转化为数字形式?

flycat2004 2004-03-16 10:56:15
我使用vip=Request.ServerVariables("Remote_Addr")
显示效果如:
172.168.0.1
我用什么方法,可以把以上文字型IP地址边为整形数据,如:
17216801
请指教!!
...全文
32 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
QQgenie 2004-03-16
  • 打赏
  • 举报
回复
转抄:
<%
function IP2Num(sip)
dim str1,str2,str3,str4
dim num
IP2Num=0
if isnumeric(left(sip,2)) then
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
IP2Num = num
end if
end function

userIPnum = IP2Num(Request.ServerVariables("REMOTE_ADDR"))


if userIPnum>IP2Num("10.1.1.207") and userIPnum<IP2Num("10.1.1.209") then
ShowMessage("<center>IP被禁</center>")
end if
%>
yangzixp 2004-03-16
  • 打赏
  • 举报
回复
cint(replace(vip,".",""))
jnyezhi 2004-03-16
  • 打赏
  • 举报
回复
ip = "172.168.0.1"
ip = clng(join(split(ip,"."),""))

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧