求一个ASP限制IP段访问的代码

来源:百度知道 编辑:UC知道 时间:2024/05/31 05:05:30
求一个ASP限定IP段的代码,列如可以限制127.0.0.1-127.255.255.255内的IP禁止访问该页面!

<%
if checkIP() then
xmlStr=xmlStr& "<success>true</success><title>合法用户</title><message>欢迎光临!</message>"
else
xmlStr=xmlStr& "<success>false</success><title>系统提示</title><message>非法用户,你没有使用本系统的权限!如有疑问,请与系统管理员联系。</message>"
end if

response.write xmlStr
%>

<%
function checkIP()
Dim vip : vip = cip(getIP())
Dim gcSQL : gcSQL = "gc_checkIP " & vip

OpenConn()
Dim rs : Set rs = conn.execute(gcSQL)
if rs.eof and rs.bof then
checkIP=false
else
checkIP=true
end if
Co(rs)
CloseConn()
end function

function cip(sip)
dim tip : tip=cstr(sip)
dim sip1,sip2,sip3,sip4
sip1=left(tip,cint(instr(tip,".")-1))
tip=mid(tip,cint(instr(tip,".")+1))
sip2=left(tip,cint(instr(tip