当前位置:首页 > 程序&理念 >

ASP 判断IP是否合法

时间:2007-03-20 17:09:58浏览:56880 本站原创


<%
IP=\"222.192.145.12\"
IsIP=\"0\"
if instr(IP,\".\")>1 then
    id=split(IP,\".\")
    i=ubound(id)
    if cint(i)=3 then
        IsIP=\"1\"
        for j=0 to i
            if isnumeric(id(j)) then
                IsIP=\"1\"
            else
                IsIP=\"0\"
                exit for
            end if
            if len(id(j))<=3 then
                IsIP=\"1\"
            else
                IsIP=\"0\"
                exit for
            end if
        next

    else
        IsIP=\"0\"
    end if
end if

if IsIP=\"1\" then
    response.write \"是IP\"
else
    response.write \"非法IP\"
end if
%>
原理:判断是否包含点 然后判断是否是由点分隔开的4段,并分别判断每段是否为三位数字 1

上一篇:现在这些人太能忽悠了
下一篇:如何在IIS中禁用特定MIME类型的缓存(转)

发表评论

昵称:  验证码:

关于博主

博主

博主:BlueCode

职业:web程序

简介:2002年开始一直从事Web制作,网站运营,会PHP+MYSQL ASP+MSSQL,微信开发