pptv vip破解版-fileserve

ip限制
2023年4月7日发(作者:手机内存满了)

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

求一个ASP限定IP段的代码,列如可以限制127.0.0.1-127.255.255.255内的IP禁止访问该页面!

其他回答共1条

2008-11-1120:06lzp4881|八级

<%

ifcheckIP()then

xmlStr=xmlStr&"true合法用户欢迎光临!"

else

xmlStr=xmlStr&"false系统提示非法用户,你没有使用本系统的权限!如有疑问,请与系统

管理员联系。"

endif

mlStr

%>

<%

functioncheckIP()

Dimvip:vip=cip(getIP())

DimgcSQL:gcSQL="gc_checkIP"&vip

OpenConn()

Dimrs:Setrs=e(gcSQL)

n

checkIP=false

else

checkIP=true

endif

Co(rs)

CloseConn()

endfunction

functioncip(sip)

dimtip:tip=cstr(sip)

dimsip1,sip2,sip3,sip4

sip1=left(tip,cint(instr(tip,".")-1))

tip=mid(tip,cint(instr(tip,".")+1))

sip2=left(tip,cint(instr(tip,".")-1))

tip=mid(tip,cint(instr(tip,".")+1))

sip3=left(tip,cint(instr(tip,".")-1))

sip4=mid(tip,cint(instr(tip,".")+1))

cip=cint(sip1)*256*256*256+cint(sip2)*256*256+cint(sip3)*256+cint(sip4)

endfunction

functiongetIP()

getIP=Variables("HTTP_X_FORWARDED_FOR")

IfgetIP=""ThengetIP=Variables("REMOTE_ADDR")

endfunction

%>

2.问:asp程序该怎么写才能同时限制网站除了下面这几段ip别的人都不能访问?

楼主发表于:2005-01-2110:57:07

202.117.0.0-202.117.63.255

202.117.160.0-202.117.160.255

202.117.175.0-202.117.175.255

hollandhut

(荷兰小屋)

等级:

结帖率:100.00%

202.117.200.0-202.117.200.255

202.117.223.0-202.117.223.255

202.200.224.0-202.200.224.255

202.200.239.0-202.200.239.255

202.219.245.32-202.219.245.47

202.219.245.128-202.219.245.191

上面这几段ip之外的站都不能访问

因该怎么写?

chang1216

(医药行业的程序

混混)

等级:

#1楼得分:0回复于:2005-01-2111:04:09

ifleft(Variables("REMOTE_ADDR"),11)<>"202.117.160"orleft(Variables("REMOTE_

ADDR"),11)<>"202.117.175"then

("

抱歉,您无权查看!
")

endif

#2楼得分:0回复于:2005-01-2111:09:07

znjgress

(四空和尚)

等级:

ip限制函数

'******************************

'FunctionCheckIp(cInput_Ip,cBound_Ip)

'Createdbyqqdao,qqdao@2001/11/28

'说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内

'参数:cInput_Ip,代检查的ip

'cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位

'每个范围后添加":ALLOW"表示允许登陆,添加":REFUSE"表示拒绝登陆。多个范围用”;“隔

'例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"

'返回值:true/false

'更新:2001/12/05支持ALLOW,REFUSE支持‟*„,不想对?支持,因为和*差不多

'******************************

functionCheckIp(cInput_Ip,cBound_Ip)

dimcSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip

CheckIp=false

cSingle_Ip=split(cBound_Ip,";")

fori=0toubound(cSingle_Ip)

ifInstr(cSingle_Ip(i),"REFUSE")<>0then'就是拒绝了

cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

ifInstr(cTemp_IP,"*")<>0then'是宽范围

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)

ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen

CheckIp=false

exitfunction

endif

endif

ifInstr(cTemp_IP,"-")=0then

cStart_IP=cTemp_IP

cEnd_Ip=cTemp_IP

else

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"-")-1)

cEnd_Ip=left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)

endif

ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then

CheckIp=false

exitfunction

endif

elseifInstr(cSingle_Ip(i),"ALLOW")<>0then'允许

cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

ifInstr(cTemp_IP,"*")<>0then'是宽范围

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)

ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen

CheckIp=true

endif

endif

ifInstr(cTemp_IP,"-")=0then

cStart_IP=cTemp_IP

cEnd_Ip=cTemp_IP

else

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"-")-1)

cEnd_Ip=left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)

endif

ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then

CheckIp=true

else

CheckIp=false

endif

endif

next

endfunction

'******************************

'FunctionIp2Str(cIp)

'Createdbyqqdao,qqdao@2001/11/28

'参考动网ip算法

'参数:cIpip地址

'返回值:转换后数值

'******************************

functionIp2Str(cIp)

Dimstr1,str2,str3,str4

DimcIp_Temp

ifcIp="127.0.0.1"thencIp="192.168.0.1"

str1=left(cIp,instr(cIp,".")-1)

cIp_Temp=mid(cIp,instr(cIp,".")+1)

str2=left(cIp_Temp,instr(cIp_Temp,".")-1)

cIp_Temp=mid(cIp_Temp,instr(cIp_Temp,".")+1)

str3=left(cIp_Temp,instr(cIp_Temp,".")-1)

str4=mid(cIp_Temp,instr(cIp_Temp,".")+1)

ifisNumeric(str1)=0orisNumeric(str2)=0orisNumeric(str3)=0orisNumeric(str4)=0then

else

Ip2Str=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1

endif

endfunction

'代码调用演示

ifCheckIp("192.168.1.1","192.168.1.*:REFUSE")then

"登陆成功"

else

"您的ip不被允许"

endif

cinput_ip就是要检查的ip,也就是Variables("REMOTE_ADDR")

cbound_ip是范围,可以存到库里,范围的写法,我已详细说明了。

3.[asp]如何实现IP地址段的限制啊?

如屏蔽220.191.46.10~220.191.46.100

这样写:

<%

ip=Variables("REMOTE_HOST")

ip=split(ip,".")

ip0=ip(0)&ip(1)&ip(2)

ip1=cint(ip(3))

ifip0="22019146"then

ifip1<100andip1>10then

""

endif

endif

%>

ip(0)、ip(1)、ip(2)、ip(3)分别代表什么啊???

代表spilt函数以“."切割出来的数组

ip(0):220

ip(1):191

ip(2):46

ip(3):**

搜下spilt就知道了。

4.打算通过IP段限制访问网站,如何实现??zengkunmin,2006-08-3021:39:47

比如在后台设置:192.168.*.*

就起到了限制这个段的所有用户访问。

IPSTR=Variables("HTTP_X_FORWARDED_FOR")

IP=Split(IPSTR,".")

ifip(0)="192"andip(1)="168"then

islocal=true

ct"目标地址"

else

islocal=false

"alert('您不能登陆指定网络')"

endif

5.asp网页如何设置ip访问限制

asp语法

if。。then

。。。

else

。。。

注意thenelse后要回车,不能带语句,语句要在下一行写,否则会出错,显示“页面无法访问”

把<%..%>的内容抄写到一个的文件里,用的网页单独判断ip是否可以访问。

<%

''获取访问者的地址

ip=Variables("REMOTE_ADDR")

''设置允许的IP地址段为192.168.1.1~192.168.1.254

allowip1="192.168.1.1"

allowip2="192.168.1.254"

'heckip(ip,allowip1,allowip2)

Ifcheckip(ip,allowip1,allowip2)Then'如果允许访问,则跳转到。。,如果不允许,则出现提示信息“禁止访问”

ct("")

"禁止访问"

EndIf

''checkip(ip,allowip1,allowip2)函数,用以判断参数ip是不是在允许访问的allowip1~allowip2段内,如果是,返回true,如果不是返回false

functioncheckip(ip,allowip1,allowip2)

dimcheck(4)

checkip=false

ipstr=split(ip,".")

allow1=split(allowip1,".")

allow2=split(allowip2,".")

ifcint(allow1(0))>cint(allow2(0))then''判断IP地址段是否合法

"禁止访问"

exitfunction

endif

fori=0toubound(ipstr)

ifcint(allow1(i))

ifcint(allow1(i))=cint(ipstr(i))then

check(i)=true

checkip=true

exitfor

else

ifcint(ipstr(i))

check(i)=true

checkip=true

exitfor

else

ifcint(ipstr(i))>cint(allow2(i))then

check(i)=false

checkip=false

exitfor

else

check(i)=true

checkip=true

endif

endif

endif

else

ifcint(allow1(i))>cint(ipstr(i))orcint(allow1(i))

check(i)=false

checkip=false

ifi<>ubound(ipstr)then

exitfor

endif

else

check(i)=true

endif

endif

next

if(check(0)=trueandcheck(1)=trueandcheck(2)=trueandcheck(3)=false)and(cint(allow2(2))>cint(ipstr(2)))then

checkip=true

endif

endfunction

%>

更多推荐

ip限制