Yx_cls.Asp
上传用户:btntkt
上传日期:2021-04-16
资源大小:5296k
文件大小:15k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

DOS

  1. <%
  2. Class Cls_Cache
  3. Private cache
  4. Private cacheNames
  5. Private expireTime
  6. Private expireTimeName
  7. Private path
  8. Private Sub class_initialize()
  9. path=Request.servervariables("url")
  10. path=left(path,instrRev(path,"/"))
  11. end sub
  12.  
  13. Private Sub class_terminate()
  14. End Sub
  15. Public Property Get Version
  16. Version="Cache v1.2"
  17. End Property
  18. Public property Get valid '读取缓存是否有效/属性
  19. if isempty(cache) or (not isdate(expireTime) or CDate(expireTime)<now) then
  20. valid=false
  21. else
  22. valid=true
  23. end if
  24. end property
  25. public property get value '读取当前缓存内容/属性
  26. if isempty(cache) or (not isDate(expireTime)) then
  27. value=null
  28. elseif CDate(expireTime)<now then
  29. value=null
  30. else
  31. value=cache
  32. end if
  33. end property
  34. public property let name(str) '设置缓存名称/属性
  35. cacheNames=str&path
  36. cache=application(cacheNames)
  37. expireTimeName=str&"expire"&path
  38. expireTime=application(expireTimeName)
  39. end property
  40. Public property let expire(tm) '设置缓存过期时间/属性
  41. expireTime=tm
  42. application.Lock()
  43. application(expireTimeName)=expireTime
  44. application.UnLock()
  45. End property
  46. public sub add(varCache,varExpireTime) '对缓存赋值/方法
  47. if isempty(varCache) or not isDate(varExpireTime) then
  48. exit sub
  49. end if
  50. cache=varCache
  51. expireTime=varExpireTime
  52. application.lock
  53. application(cacheNames)=cache
  54. application(expireTimeName)=expireTime
  55. application.unlock
  56. end sub
  57. public sub clean()
  58. application.lock
  59. application(cacheNames)=empty
  60. application(expireTimeName)=empty
  61. application.unlock
  62. cache=empty
  63. expireTime=empty
  64. End sub
  65. '比较缓存值是否相同/方法——返回是或否
  66. public function verify(varcache2)
  67. If typename(cache)<>typename(varcache2) then
  68. verify=false
  69. Elseif typename(cache)="Object" then
  70. If cache is varcache2 then
  71. verify=true
  72. Else
  73. verify=false
  74. End if
  75. Elseif typename(cache)="Variant()" then
  76. If join(cache,"^")=join(varcache2,"^") then
  77. verify=true
  78. Else
  79. verify=false
  80. End if
  81. Else
  82. If cache=varcache2 then
  83. verify=true
  84. Else
  85. verify=false
  86. End if
  87. End if
  88. End function
  89. End Class
  90. %>
  91. <%
  92. Class Cls_Fun
  93. Public Function LockedIpCheck()
  94. Dim num_ip,rs,Arr_Rs,I
  95. Cache.Name="IPData"
  96. If Cache.valid Then
  97. Arr_Rs=Cache.Value
  98. Else
  99. Set Rs=YxBBs.execute("select id,StartIp,EndIP,ReadMe from [YX_lockip]")
  100. If Rs.Eof Or Rs.Bof Then
  101. Exit Function
  102. Else
  103. Arr_Rs=Rs.GetRows(-1)
  104. Rs.Close
  105. Cache.add Arr_Rs,dateadd("n",5000,now)'5000分钟更新
  106. End If
  107. End If
  108. num_ip=IpEncode(YxBBs.MyIp)
  109. For i=0 To Ubound(Arr_Rs,2)
  110. If Arr_Rs(1,I)<=num_ip And Arr_Rs(2,I)>=num_ip Then
  111. Response.Write "<font size=3><b>你所在网段已被封锁:</b><font color=#FF0000>"&Arr_Rs(3,I)&"</font></font>"
  112. Response.End
  113. End If
  114. Next
  115. End Function
  116. Public  Function IpDecode(byval uip)
  117. If trim(uip)="" or not isnumeric(uip) Then
  118. IpDecode=0
  119. Else
  120. uip=Cdbl(uip)
  121. Dim ary_ip(3)
  122. ary_ip(0)=fix(uip/16777216)
  123. ary_ip(1)=fix((uip-ary_ip(0)*16777216)/65536)
  124. ary_ip(2)=fix((uip-fix(uip/65536)*65536)/256)
  125. uip=uip-fix(uip/65536)*65536
  126. ary_ip(3)=fix(uip-fix(uip/256)*256)
  127. IpDecode=join(ary_ip,".")
  128. End If
  129. End Function
  130. Public Function IpEncode(byval uip)
  131. If isnull(uip) or uip="" Then
  132. IpEncode=0
  133. else
  134. Dim ary_ip,n
  135. ary_ip=split(trim(uip),".")
  136. n=ubound(ary_ip)
  137. If n=3 Then
  138. IpEncode=ary_ip(0)*256*256*256+ary_ip(1)*65536+ary_ip(2)*256+ary_ip(3)
  139. else
  140. IpEncode=0
  141. End If
  142. End If
  143. End Function
  144. '禁止外部提交
  145. Public Function CheckMake()
  146. Dim Come,Here
  147. Come=Request.ServerVariables("HTTP_REFERER")
  148. Here=Request.ServerVariables("SERVER_NAME")
  149. If Mid(Come,8,len(Here))<>Here Then YxBBs.Error("您所提交的数据来自本站外部,请不要从论坛外部提交数据,谢谢合作!")
  150. End Function
  151. '传字符值
  152. Public Function GetStr(Str)
  153. Str = Trim(Request.Form(Str))
  154. If IsEmpty(Str) Then
  155. Str = ""
  156. Else
  157. Str = Replace(Str,"'","&#39;")
  158. Str = Replace(Str,"|","&#124;")
  159. End If
  160. GetStr = Trim(Str)
  161. End Function
  162. Public Function GetSqlStr(Str)
  163. If IsEmpty(Str) Or Isnull(Str) Then
  164. Str = ""
  165. End If
  166. GetSqlStr = Trim(Str)
  167. End Function
  168. '整数检验
  169. Public Function isInteger(para)
  170.    on error resume Next
  171.    Dim str
  172.    Dim l,i
  173.    If isNUll(para) Then 
  174.   isInteger=false
  175.   Exit Function
  176.    End If
  177.    str=cstr(para)
  178.    If trim(str)="" Then
  179.   isInteger=false
  180.   Exit Function
  181.    End If
  182.    l=len(str)
  183.    For i=1 to l
  184.    If mid(str,i,1)>"9" or mid(str,i,1)<"0" Then
  185.   isInteger=false 
  186.   Exit Function
  187.    End If
  188.    Next
  189.    isInteger=true
  190.    If err.number<>0 Then err.clear
  191. End Function
  192. '名字字符检验
  193. Public Function CheckName(str)
  194. checkname=true
  195. 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,"