📄 yx_cls.asp
字号:
<%
Class Cls_Cache
Private cache
Private cacheNames
Private expireTime
Private expireTimeName
Private path
Private Sub class_initialize()
path=Request.servervariables("url")
path=left(path,instrRev(path,"/"))
end sub
Private Sub class_terminate()
End Sub
Public Property Get Version
Version="Cache v1.2"
End Property
Public property Get valid '读取缓存是否有效/属性
if isempty(cache) or (not isdate(expireTime) or CDate(expireTime)<now) then
valid=false
else
valid=true
end if
end property
public property get value '读取当前缓存内容/属性
if isempty(cache) or (not isDate(expireTime)) then
value=null
elseif CDate(expireTime)<now then
value=null
else
value=cache
end if
end property
public property let name(str) '设置缓存名称/属性
cacheNames=str&path
cache=application(cacheNames)
expireTimeName=str&"expire"&path
expireTime=application(expireTimeName)
end property
Public property let expire(tm) '设置缓存过期时间/属性
expireTime=tm
application.Lock()
application(expireTimeName)=expireTime
application.UnLock()
End property
public sub add(varCache,varExpireTime) '对缓存赋值/方法
if isempty(varCache) or not isDate(varExpireTime) then
exit sub
end if
cache=varCache
expireTime=varExpireTime
application.lock
application(cacheNames)=cache
application(expireTimeName)=expireTime
application.unlock
end sub
public sub clean()
application.lock
application(cacheNames)=empty
application(expireTimeName)=empty
application.unlock
cache=empty
expireTime=empty
End sub
'比较缓存值是否相同/方法——返回是或否
public function verify(varcache2)
If typename(cache)<>typename(varcache2) then
verify=false
Elseif typename(cache)="Object" then
If cache is varcache2 then
verify=true
Else
verify=false
End if
Elseif typename(cache)="Variant()" then
If join(cache,"^")=join(varcache2,"^") then
verify=true
Else
verify=false
End if
Else
If cache=varcache2 then
verify=true
Else
verify=false
End if
End if
End function
End Class
%>
<%
Class Cls_Fun
Public Function LockedIpCheck()
Dim num_ip,rs,Arr_Rs,I
Cache.Name="IPData"
If Cache.valid Then
Arr_Rs=Cache.Value
Else
Set Rs=YxBBs.execute("select id,StartIp,EndIP,ReadMe from [YX_lockip] where Lock")
If Rs.Eof Or Rs.Bof Then
Exit Function
Else
Arr_Rs=Rs.GetRows(-1)
Rs.Close
Cache.add Arr_Rs,dateadd("n",5000,now)'5000分钟更新
End If
End If
num_ip=IpEncode(YxBBs.MyIp)
For i=0 To Ubound(Arr_Rs,2)
If Arr_Rs(1,I)<=num_ip And Arr_Rs(2,I)>=num_ip Then
Response.Write "<font size=3><b>你所在网段已被封锁:</b><font color=#FF0000>"&Arr_Rs(3,I)&"</font></font>"
Response.End
End If
Next
End Function
Public Function IpDecode(byval uip)
If trim(uip)="" or not isnumeric(uip) Then
IpDecode=0
Else
uip=Cdbl(uip)
Dim ary_ip(3)
ary_ip(0)=fix(uip/16777216)
ary_ip(1)=fix((uip-ary_ip(0)*16777216)/65536)
ary_ip(2)=fix((uip-fix(uip/65536)*65536)/256)
uip=uip-fix(uip/65536)*65536
ary_ip(3)=fix(uip-fix(uip/256)*256)
IpDecode=join(ary_ip,".")
End If
End Function
Public Function IpEncode(byval uip)
If isnull(uip) or uip="" Then
IpEncode=0
else
Dim ary_ip,n
ary_ip=split(trim(uip),".")
n=ubound(ary_ip)
If n=3 Then
IpEncode=ary_ip(0)*256*256*256+ary_ip(1)*65536+ary_ip(2)*256+ary_ip(3)
else
IpEncode=0
End If
End If
End Function
'禁止外部提交
Public Function CheckMake()
Dim Come,Here
Come=Request.ServerVariables("HTTP_REFERER")
Here=Request.ServerVariables("SERVER_NAME")
If Mid(Come,8,len(Here))<>Here Then YxBBs.Error("您所提交的数据来自本站外部,请不要从论坛外部提交数据,谢谢合作!")
End Function
'传字符值
Public Function GetStr(Str)
Str = Trim(Request.Form(Str))
If IsEmpty(Str) Then
Str = ""
Else
Str = Replace(Str,"'","'")
Str = Replace(Str,"|","|")
End If
GetStr = Trim(Str)
End Function
Public Function GetSqlStr(Str)
If IsEmpty(Str) Or Isnull(Str) Then
Str = ""
End If
GetSqlStr = Trim(Str)
End Function
'整数检验
Public Function isInteger(para)
on error resume Next
Dim str
Dim l,i
If isNUll(para) Then
isInteger=false
Exit Function
End If
str=cstr(para)
If trim(str)="" Then
isInteger=false
Exit Function
End If
l=len(str)
For i=1 to l
If mid(str,i,1)>"9" or mid(str,i,1)<"0" Then
isInteger=false
Exit Function
End If
Next
isInteger=true
If err.number<>0 Then err.clear
End Function
'名字字符检验
Public Function CheckName(str)
checkname=true
If Instr(str,"=")>0 or Instr(str,"%")>0 or Instr(str,chr(32))>0 or Instr(str,"?")>0 or Instr(str,"&")>0 or Instr(str,";")>0 or Instr(str,",")>0 or Instr(str,"'")>0 or Instr(str,chr(34))>0 or Instr(str,chr(9))>0 or Instr(str,"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -