加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

部分值得一看的代码asp

发布时间:2023-09-06 14:03:33 所属栏目:Asp教程 来源:
导读:Asp中对ip进行过滤限制函数

<%

&#39;获取访问者的地址

ip=Request.ServerVariables("REMOTE_ADDR")

&#39;允许的IP地址段为10.0.0.0~10.68.63.255

allowip1="10.0.0.0"

allowip2="10.68.10.
Asp中对ip进行过滤限制函数
 
<%
 
'获取访问者的地址
 
ip=Request.ServerVariables("REMOTE_ADDR")
 
'允许的IP地址段为10.0.0.0~10.68.63.255
 
allowip1="10.0.0.0"
 
allowip2="10.68.10.71"
 
response.write checkip(ip,allowip1,allowip2)
 
function checkip(ip,allowip1,allowip2)
 
dim check(4)
 
checkip=false
 
ipstr=split(ip,".")
 
allow1=split(allowip1,".")
 
allow2=split(allowip2,".")
 
if cint(allow1(0))>cint(allow2(0)) then
 
'判断IP地址段是否合法
 
response.write "IP地址段出错!"
 
exit function
 
end if
 
for i=0 to ubound(ipstr)
 
if cint(allow1(i))<cint(allow2(i)) then
 
if cint(allow1(i))=cint(ipstr(i)) then
 
check(i)=true
 
checkip=true
 
exit for
 
elseif cint(ipstr(i))<cint(allow2(i)) then
 
check(i)=true
 
checkip=true
 
exit for
 
elseif cint(ipstr(i))>cint(allow2(i)) then
 
check(i)=false
 
checkip=false
 
exit for
 
else
 
check(i)=true
 
checkip=true
 
end if
 
end if
 
end if
 
elseif cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
 
check(i)=false
 
checkip=false
 
if i<>ubound(ipstr) then
 
exit for
 
end if
 
else
 
check(i)=true
 
end if
 
end if
 
next
 
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
 
checkip=true
 
end if
 
end function
 
%>
 
 
<%
 
'列举使用HTML表单提交的所有值
 
For Each item In Request.Form
 
     Response.Write Request.Form(item)
 
Next
 
%>
 
列举使用HTML表单提交的所有值
 
利用ASP得到图片尺寸大小
 
<%  
 
imgpath="default_22.gif"
 
set  pp=new  imgInfo  
 
w = pp.imgW(server.mappath(imgpath))  
 
h = pp.imgH(server.mappath(imgpath))
 
set pp=nothing
 
response.write "<img src='"&imgpath&"' border=0><br>宽:"&w&";高:"&h
 
 
Class  imgInfo  
 
dim  aso  
 
Private  Sub  Class_Initialize  
 
   set  aso=CreateObject("Adodb.Stream")  
 
   aso.Mode=3    
 
   aso.Type=1    
 
   aso.Open    
 
End  Sub  
 
Private  Sub  Class_Terminate
 
   err.clear
 
   set  aso=nothing  
 
End  Sub  
 
Private  Function  Bin2Str(Bin)  
 
   Dim  I,  Str  
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章