include.asp
上传用户:saigedz
上传日期:2019-10-14
资源大小:997k
文件大小:13k
源码类别:

中间件编程

开发平台:

HTML/CSS

  1. <%
  2. '///////////////////////////////////////////////////////////////////////////////
  3. '// 插件应用:    Z-Blog 1.7
  4. '// 插件制作:    
  5. '// 备    注:    
  6. '// 最后修改:   
  7. '// 最后版本:    
  8. '///////////////////////////////////////////////////////////////////////////////
  9. Const TOTORO_SV_THRESHOLD = 50
  10. Const TOTORO_TB_PAGE_VALUE = 0
  11. Const TOTORO_LEVEL_VALUE = 100
  12. Const TOTORO_NAME_VALUE = 45
  13. Const TOTORO_HYPERLINK_VALUE = 10
  14. Const TOTORO_BADWORD_VALUE = 50
  15. Const TOTORO_BADWORD_LIST = "虚拟主机|域名注册|服务器托管|hosting|poker|免费铃声|免费彩信|铃声下载|搜索引擎营销|数据恢复|彩票软件|手机图片|魔兽金币|交友中心|成人用品|私服|企业黄页|出租|显示屏|投影仪|群发|翻译公司|留学咨询|外挂下载|硬盘录像机|google排名|注册香港公司|婚庆公司|投影幕|培养箱|花店|一号通|印刷公司|打包机|封口机|管件|砂机|打标机|升降机"
  16. Const TOTORO_INTERVAL_VALUE = 25
  17. Const TOTORO_INTERVAL_HOUR = 1
  18. Const TOTORO_DEL_DIRECTLY = False
  19. Dim Totoro_SV
  20. Totoro_SV=0
  21. Dim Totoro_SpamCount_Comment
  22. Dim Totoro_SpamCount_TrackBack
  23. '注册插件
  24. Call RegisterPlugin("Totoro","ActivePlugin_Totoro")
  25. '具体的接口挂接
  26. Function ActivePlugin_Totoro() 
  27. '挂上接口
  28. 'Filter_Plugin_PostComment_Core
  29. Call Add_Filter_Plugin("Filter_Plugin_PostComment_Core","Totoro_chkComment")
  30. 'Filter_Plugin_PostTrackBack_Core
  31. Call Add_Filter_Plugin("Filter_Plugin_PostTrackBack_Core","Totoro_chkTrackBack")
  32. 'Action_Plugin_Admin_Begin
  33. Call Add_Action_Plugin("Action_Plugin_Admin_Begin","If Request.QueryString(""act"")=""CommentMng"" Then Call Totoro_GetSpamCount_Comment() End If")
  34. Call Add_Action_Plugin("Action_Plugin_Admin_Begin","If Request.QueryString(""act"")=""TrackBackMng"" Then Call Totoro_GetSpamCount_TrackBack() End If")
  35. '网站管理加上二级菜单项
  36. Call Add_Response_Plugin("Response_Plugin_SettingMng_SubMenu",MakeSubMenu("TotoroⅡ设置","../plugin/totoro/setting.asp","m-left",False))
  37. End Function
  38. '*********************************************************
  39. ' 目的:    检查评论
  40. '*********************************************************
  41. Function Totoro_chkComment(ByRef objComment)
  42. Call Totoro_checkLevel(BlogUser.Level)
  43. Call Totoro_checkName(objComment.Author)
  44. Call Totoro_checkHyperLink(objComment.Content)
  45. Call Totoro_checkBadWord(objComment.Content & "&" & objComment.Author & "&" & objComment.HomePage & "&" & objComment.IP & "&" & objComment.Email)
  46. Call Totoro_checkInterval(Request.ServerVariables("REMOTE_ADDR"),now,true)
  47. If Totoro_SV>=TOTORO_SV_THRESHOLD Then
  48. Dim strKey
  49. strKey=Request.QueryString("key")
  50. Dim objArticle
  51. If objComment.AuthorID>0 Then
  52. objComment.Author=Users(objComment.AuthorID).Name
  53. End If
  54. If objComment.log_ID>0 Then
  55. Set objArticle=New TArticle
  56. If objArticle.LoadInfoByID(1-objComment.log_ID) Then
  57. If Not (strKey=objArticle.CommentKey) Then Call ShowError(43)
  58. If objArticle.Level<4 Then Call ShowError(44)
  59. End If
  60. Set objArticle=Nothing
  61. Else
  62. If Not (strKey=Left(MD5(ZC_BLOG_HOST & ZC_BLOG_CLSID & CStr(0) & CStr(Day(Now))),8)) Then Call ShowError(43)
  63. End If
  64. Dim objUser
  65. For Each objUser in Users
  66. If IsObject(objUser) Then
  67. If (UCase(objUser.Name)=UCase(objComment.Author)) And (objUser.ID<>objComment.AuthorID) Then Call ShowError(31)
  68. End If
  69. Next
  70. objComment.log_ID=-1-objComment.log_ID
  71. If objComment.Post Then
  72. End if
  73. If IsEmpty(Request.Form("inpAjax"))=False Then
  74. objComment.Content="你的评论已进入审核过程,请勿再次提交。"
  75. Call ReturnAjaxComment(objComment)
  76. Response.End
  77. End If
  78. Call Totoro_ExitError("你的评论已进入审核过程,请勿再次提交。")
  79. End If
  80. End Function
  81. '*********************************************************
  82. '*********************************************************
  83. ' 目的:    检查引用
  84. '*********************************************************
  85. Function Totoro_chkTrackBack(ByRef objTrackBack)
  86. Call Totoro_checkHyperLink(objTrackBack.Title  &  "|" &  objTrackBack.Blog &  "|" & objTrackBack.Excerpt)
  87. Call Totoro_checkBadWord(objTrackBack.Title &  "|" & objTrackBack.Blog &  "|" & objTrackBack.Excerpt &  "|" & objTrackBack.IP &  "|" & objTrackBack.URL)
  88. Call Totoro_checkInterval(Request.ServerVariables("REMOTE_ADDR"),now,false)
  89. Call TOTORO_CheckTBSource(objTrackBack.URL)
  90. If Totoro_SV>=TOTORO_SV_THRESHOLD Then
  91. objTrackBack.log_ID=-1-objTrackBack.log_ID
  92. If objTrackBack.Post Then
  93. End if
  94. Call ExitError("你的引用已进入审核过程,请勿再次提交。")
  95. End If
  96. End Function
  97. '*********************************************************
  98. '*********************************************************
  99. ' 目的:    检查TB原址页面中是否有本博客链接(by Zx.MYS)
  100. '*********************************************************
  101. Function TOTORO_CheckTBSource(ByVal URL)
  102. If TOTORO_TB_Page_Value=0 or Totoro_SV >= TOTORO_SV_THRESHOLD Then Exit Function
  103. dim TOTORO_xmlHTTP,TOTORO_TbPageContent
  104. Dim TOTORO_lResolve,TOTORO_lConnect,TOTORO_lSend,TOTORO_lReceive '超时设置,单位:秒
  105. TOTORO_lResolve=5 '解析地址(DNS)超时时间
  106. TOTORO_lConnect=5 '链接超时时间
  107. TOTORO_lSend=5 '发送请求时间
  108. TOTORO_lReceive=15 '等待响应时间
  109. dim i,TOTORO_HTTPRETRY    '后加入
  110. TOTORO_HTTPRETRY = 3    '后加入, 重试次数
  111. TOTORO_HTTPRETRY = TOTORO_HTTPRETRY-1    '调整重试次数
  112. 'On Error Resume Next    '后加入, 防报错. 相当于连接失败后直接+SV
  113. for i=0 to TOTORO_HTTPRETRY    '重试n次, 在任一次连接成功后即跳出循环, 当然也可以用其它循环改写.
  114. Set TOTORO_xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
  115. TOTORO_xmlHTTP.setTimeouts TOTORO_lResolve*1000,TOTORO_lConnect*1000,TOTORO_lSend*1000,TOTORO_lReceive*1000
  116. TOTORO_xmlHTTP.Open "GET",URL,false
  117. TOTORO_xmlHTTP.SetRequestHeader "Content-type", "text/xml"
  118. TOTORO_xmlHTTP.Send
  119. If Err Then    '如果连接失败
  120.   Err.Clear    '清除本次错误
  121.   TOTORO_TbPageContent = ""    '链接失败后TOTORO_TbPageContent为空字符串, 可省略
  122.   set TOTORO_xmlhttp = nothing    '清空内存以便重试
  123. else    '非失败即成功
  124.   TOTORO_TbPageContent = TOTORO_xmlHTTP.ResponseText
  125.   Set TOTORO_xmlHTTP = Nothing
  126.   exit for    '跳出循环
  127. end if
  128. next
  129. If InStr(LCase(TOTORO_TbPageContent),LCase(ZC_BLOG_HOST))=0 then Totoro_SV=Totoro_SV + TOTORO_TB_Page_Value
  130. End Function
  131. '*********************************************************
  132. Function Totoro_checkLevel(ByVal level)
  133. If TOTORO_LEVEL_VALUE=0 Then Exit Function
  134. If Level=1 Then
  135. Totoro_SV=Totoro_SV-TOTORO_LEVEL_VALUE*(4)
  136. ElseIf  Level=2 Then
  137. Totoro_SV=Totoro_SV-TOTORO_LEVEL_VALUE*(3)
  138. ElseIf  Level=3 Then
  139. Totoro_SV=Totoro_SV-TOTORO_LEVEL_VALUE*(2)
  140. ElseIf  Level=4 Then
  141. Totoro_SV=Totoro_SV-TOTORO_LEVEL_VALUE*(1)
  142. ElseIf  Level=5 Then
  143. Totoro_SV=Totoro_SV-TOTORO_LEVEL_VALUE*(0)
  144. End If
  145. End Function
  146. Function Totoro_checkName(ByVal name)
  147. If TOTORO_NAME_VALUE=0 Then Exit Function
  148. Dim i,s
  149. s=FilterSQL(name)
  150. Dim objRS
  151. Set objRS=objConn.Execute("SELECT COUNT([comm_ID]) FROM [blog_Comment] WHERE [log_ID]>=0 and [comm_Author] ='" & s & "'")
  152. If (Not objRS.bof) And (Not objRS.eof) Then
  153. i=objRS(0)
  154. End If
  155. Set objRS=Nothing
  156. If i>0 And i<=10   Then Totoro_SV=Totoro_SV-10-TOTORO_NAME_VALUE*(0)
  157. If i>10 And i<=20  Then Totoro_SV=Totoro_SV-10-TOTORO_NAME_VALUE*(1)
  158. If i>20 And i<=50 Then Totoro_SV=Totoro_SV-10-TOTORO_NAME_VALUE*(2)
  159. If i>50           Then Totoro_SV=Totoro_SV-10-TOTORO_NAME_VALUE*(3)
  160. End Function
  161. Function Totoro_checkBadWord(ByVal content)
  162. If Totoro_SV+TOTORO_BADWORD_VALUE=0 Then Exit Function
  163. Dim i,j
  164. j=0
  165.     Dim strFilter
  166.     strFilter = Split(TOTORO_BADWORD_LIST, "|")
  167. For i = 0 To UBound(strFilter)
  168. If strFilter(i)<>"" Then
  169. If InStr(LCase(content), LCase(strFilter(i))) > 0 Then
  170. j=j+1
  171. End If
  172. End If
  173.     Next
  174. Totoro_SV=Totoro_SV+TOTORO_BADWORD_VALUE*j
  175. End Function
  176. Function Totoro_checkHyperLink(ByVal content)
  177. If TOTORO_HYPERLINK_VALUE=0 Then Exit Function
  178. Dim SRegExp,Matches
  179. Set SRegExp=New RegExp
  180. SRegExp.IgnoreCase =True
  181. SRegExp.Global=True
  182. SRegExp.Pattern="https:|http:"
  183. Set Matches = SRegExp.Execute(content)
  184. If Matches.count=0 Then
  185. Totoro_SV=Totoro_SV
  186. ElseIf  Matches.count=1 Then
  187. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2-1)
  188. ElseIf  Matches.count=2 Then
  189. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2*2-1)
  190. ElseIf  Matches.count=3 Then
  191. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2*2*2-1)
  192. ElseIf  Matches.count=4 Then
  193. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2*2*2*2-1)
  194. ElseIf  Matches.count=5 Then
  195. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2*2*2*2*2-1)
  196. Else
  197. Totoro_SV=Totoro_SV+TOTORO_HYPERLINK_VALUE*(2*2*2*2*2*2-1)
  198. End If
  199. Set SRegExp=Nothing
  200. End Function
  201. Function Totoro_checkInterval(ByVal ip,ByVal posttime,ByVal iscomment)
  202. If TOTORO_INTERVAL_VALUE=0 Then Exit Function
  203. Dim i,j,t,s,m,n
  204. Dim objRS
  205. If iscomment Then
  206. m="SELECT COUNT([comm_ID]) FROM [blog_Comment] WHERE [comm_IP] ='" & ip & "'"
  207. n="SELECT [comm_PostTime] FROM [blog_Comment] WHERE [comm_IP] ='" & ip & "'"
  208. Else
  209. m="SELECT COUNT([tb_ID]) FROM [blog_TrackBack] WHERE [tb_IP] ='" & ip & "'"
  210. n="SELECT [tb_PostTime] FROM [blog_TrackBack] WHERE [tb_IP] ='" & ip & "'"
  211. End If
  212. Set objRS=objConn.Execute(m)
  213. If (Not objRS.bof) And (Not objRS.eof) Then
  214. i=objRS(0)
  215. End If
  216. Set objRS=Nothing
  217. s=0
  218. If i>0 Then
  219. Set objRS=objConn.Execute(n)
  220. If (Not objRS.bof) And (Not objRS.eof) Then
  221. Do While Not objRS.eof
  222. t=objRS("comm_PostTime")
  223. If DateDiff("h",t,posttime)<TOTORO_INTERVAL_HOUR Then
  224. j=j+1
  225. If     DateDiff("n",t,posttime)>((TOTORO_INTERVAL_HOUR*60)5)*4 Then
  226. s=s+(TOTORO_INTERVAL_VALUE5)*1
  227. ElseIf DateDiff("n",t,posttime)>((TOTORO_INTERVAL_HOUR*60)5)*3 Then
  228. s=s+(TOTORO_INTERVAL_VALUE5)*2
  229. ElseIf DateDiff("n",t,posttime)>((TOTORO_INTERVAL_HOUR*60)5)*2 Then
  230. s=s+(TOTORO_INTERVAL_VALUE5)*3
  231. ElseIf DateDiff("n",t,posttime)>((TOTORO_INTERVAL_HOUR*60)5)*1 Then
  232. s=s+(TOTORO_INTERVAL_VALUE5)*4
  233. ElseIf DateDiff("n",t,posttime)>((TOTORO_INTERVAL_HOUR*60)5)*0 Then
  234. s=s+(TOTORO_INTERVAL_VALUE5)*5
  235. Else
  236. s=s+(TOTORO_INTERVAL_VALUE5)*6
  237. End If
  238. End If
  239. objRS.MoveNext
  240. Loop
  241. End If
  242. Set objRS=Nothing
  243. End If
  244. Totoro_SV=Totoro_SV+s
  245. End Function
  246. '*********************************************************
  247. ' 目的:    错误退出
  248. '*********************************************************
  249. Function Totoro_ExitError(strInput)
  250. If IsEmpty(Request.Form("inpAjax"))=False Then
  251. Call RespondError(vbObjectError+1,strInput)
  252. Response.End
  253. End If
  254. Response.Redirect ZC_BLOG_HOST & "function/c_error.asp?errorid=" & 0 & "&number=" & (vbObjectError+1) & "&description=" & Server.URLEncode(strInput) & "&source="
  255. End Function
  256. '*********************************************************
  257. '*********************************************************
  258. ' 目的:    
  259. '*********************************************************
  260. Function Totoro_GetSpamCount_Comment()
  261. If IsEmpty(objConn)=True Then Exit Function
  262. Dim objRS1
  263. Set objRS1=objConn.Execute("SELECT COUNT([comm_ID]) FROM [blog_Comment] WHERE [log_ID]<0")
  264. If (Not objRS1.bof) And (Not objRS1.eof) Then
  265. Totoro_SpamCount_Comment="("&objRS1(0)&"条未审核的评论)"
  266. End If
  267. '评论管理加上二级菜单项
  268. Call Add_Response_Plugin("Response_Plugin_CommentMng_SubMenu",MakeSubMenu("审核评论" & Totoro_SpamCount_Comment,"../plugin/totoro/setting1.asp","m-left",False) & "<scr" & "ipt src=""../plugin/totoro/common.js"" type=""text/javascript""></scr" & "ipt><scr" & "ipt src=""../plugin/totoro/cmmng.js"" type=""text/javascript""></scr" & "ipt>")
  269. End Function
  270. '*********************************************************
  271. '*********************************************************
  272. ' 目的:    
  273. '*********************************************************
  274. Function Totoro_GetSpamCount_TrackBack()
  275. If IsEmpty(objConn)=True Then Exit Function
  276. Dim objRS2
  277. Set objRS2=objConn.Execute("SELECT COUNT([tb_ID]) FROM [blog_TrackBack] WHERE [log_ID]<0")
  278. If (Not objRS2.bof) And (Not objRS2.eof) Then
  279. Totoro_SpamCount_TrackBack="("&objRS2(0)&"条未审核的引用)"
  280. End If
  281. '引用管理加上二级菜单项
  282. Call Add_Response_Plugin("Response_Plugin_TrackBackMng_SubMenu",MakeSubMenu("审核引用" & Totoro_SpamCount_TrackBack,"../plugin/totoro/setting2.asp","m-left",False) & "<scr" & "ipt src=""../plugin/totoro/common.js""  type=""text/javascript""></scr" & "ipt><scr" & "ipt src=""../plugin/totoro/tbmng.js""  type=""text/javascript""></scr" & "ipt>")
  283. End Function
  284. '*********************************************************
  285. %>