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

中间件编程

开发平台:

HTML/CSS

  1. <%
  2. '///////////////////////////////////////////////////////////////////////////////
  3. '//              Z-Blog
  4. '// 作    者:    朱煊(zx.asd)
  5. '// 版权所有:    RainbowSoft Studio
  6. '// 技术支持:    rainbowsoft@163.com
  7. '// 程序名称:    
  8. '// 程序版本:    
  9. '// 单元名称:    c_function.asp
  10. '// 开始时间:    2004.07.28
  11. '// 最后修改:    
  12. '// 备    注:    函数模块
  13. '///////////////////////////////////////////////////////////////////////////////
  14. '*********************************************************
  15. ' 目的:    显示错误页面
  16. ' 输入:    id
  17. ' 返回:    无
  18. '*********************************************************
  19. Dim ShowError_Custom
  20. Sub ShowError(id)
  21. If IsEmpty(ShowError_Custom)=False Then
  22. Execute(ShowError_Custom)
  23. Exit Sub
  24. End If
  25. Response.Redirect ZC_BLOG_HOST & "function/c_error.asp?errorid=" & id & "&number=" & Err.Number & "&description=" & Server.URLEncode(Err.Description) & "&source=" & Server.URLEncode(Err.Source) & "&sourceurl="  &Server.URLEncode(Request.ServerVariables("Http_Referer")) 
  26. End Sub
  27. '*********************************************************
  28. '*********************************************************
  29. ' 目的:    XML-RPC显示错误页面
  30. '*********************************************************
  31. Function RespondError(faultCode,faultString)
  32. Dim strXML
  33. Dim strError
  34. strXML="<?xml version=""1.0"" encoding=""UTF-8""?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>$1</int></value></member><member><name>faultString</name><value><string>$2</string></value></member></struct></value></fault></methodResponse>"
  35. strError=strXML
  36. strError=Replace(strError,"$1",TransferHTML(faultCode,"[html-format]"))
  37. strError=Replace(strError,"$2",TransferHTML(faultString,"[html-format]"))
  38. Response.Clear
  39. Response.BinaryWrite ChrB(&HEF) & ChrB(&HBB) & ChrB(&HBF)
  40. Response.Write strError
  41. Response.End
  42. End Function
  43. '*********************************************************
  44. '*********************************************************
  45. ' 目的:    检查正则式
  46. ' 输入:    id
  47. ' 返回:    成功为True
  48. '*********************************************************
  49. Function CheckRegExp(source,para)
  50. If para="[username]" Then
  51. para="^[.A-Za-z0-9u4e00-u9fa5]+$"
  52. End If
  53. If para="[password]" Then
  54. para="^[a-z0-9]+$"
  55. End If
  56. If para="[email]" Then
  57. para="^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*.)+[a-zA-Z]*)$"
  58. End If
  59. If para="[homepage]" Then
  60. para="^[a-zA-Z]+://[a-zA-Z0-9-.&?/]+?/*$"
  61. End If
  62. If para="[nojapan]" Then
  63. para="[u3040-u30ff]+"
  64. End If
  65. If para="[guid]" Then
  66. para="^w{8}-w{4}-w{4}-w{4}-w{12}$"
  67. End If
  68. Dim re
  69. Set re = New RegExp
  70. re.Global = True
  71. re.Pattern = para
  72. re.IgnoreCase = False
  73. CheckRegExp = re.Test(source)
  74. End Function
  75. '*********************************************************
  76. '*********************************************************
  77. ' 目的:    检查参数
  78. ' 返回:    出错则转到ShowError(3)
  79. '*********************************************************
  80. Function CheckParameter(byRef source,strType,default)
  81. On Error Resume Next
  82. If strType="int" Then
  83. '数值
  84. If IsNull(source) Then
  85. source=default
  86. ElseIf IsEmpty(source) Then
  87. source=default
  88. ElseIf IsNumeric(source) Then
  89. source=CLng(source)
  90. ElseIf source="" Then
  91. source=default
  92. Else
  93. Call ShowError(3)
  94. End if
  95. If Err.Number<>0 Then Call ShowError(3)
  96. CheckParameter=True
  97. ElseIf  strType="dtm" Then
  98. '日期
  99. If IsNull(source) Then
  100. source=default
  101. ElseIf IsEmpty(source) Then
  102. source=default
  103. ElseIf IsDate(source) Then
  104. source=source
  105. Call FormatDateTime(source,vbLongDate)
  106. Call FormatDateTime(source,vbShortDate)
  107. ElseIf source="" Then
  108. source=default
  109. Else
  110. Call ShowError(3)
  111. End if
  112. If Err.Number<>0 Then Call ShowError(3)
  113. CheckParameter=True
  114. ElseIf strType="sql" Then
  115. 'SQL
  116. If IsNull(source) Or Trim(source)="" Or IsEmpty(source) Then
  117. source=default
  118. Else
  119. source=CStr(Replace(source,Chr(39),Chr(39)&Chr(39)))
  120. End If
  121. ElseIf strType="bool" Then
  122. 'Boolean
  123. source=CBool(source)
  124. If Err.Number<>0 Then
  125. Err.Clear
  126. If IsEmpty(source)=True Then
  127. source=True
  128. Else
  129. source=False
  130. End If
  131. End If
  132. Else
  133. Call ShowError(0)
  134. End If
  135. End Function
  136. '*********************************************************
  137. '*********************************************************
  138. ' 目的:    检查引用
  139. ' 返回:    无
  140. '*********************************************************
  141. Sub CheckReference(strDestination)
  142. Exit Sub
  143. Dim strReferer
  144. strReferer=CStr(Request.ServerVariables("HTTP_REFERER"))
  145. If Instr(strReferer,ZC_BLOG_HOST)=0 Then 
  146. ShowError(5)
  147. End If
  148. End Sub
  149. '*********************************************************
  150. '*********************************************************
  151. ' 目的:    搜索字符串
  152. ' 返回:    
  153. ' 备注:     不区分大小写
  154. '*********************************************************
  155. Function Search(strText,strQuestion)
  156. Dim s
  157. Dim i
  158. Dim j
  159. s=strText
  160. i=Instr(1,s,strQuestion,vbTextCompare)
  161. If i>0 Then
  162. s=Left(s,i+Len(strQuestion)+100)
  163. s=Right(s,Len(strQuestion)+200)
  164. Else
  165. s=""
  166. End If
  167. If s<>"" Then
  168. i=1
  169. Do While InStr(i,s,strQuestion,vbTextCompare)>0
  170. j=InStr(i,s,strQuestion,vbTextCompare)
  171. If Len(s)-j-Len(strQuestion)<0 Then
  172. s=Left(s,j-1) & "<b style='color:#FF6347'>" & strQuestion & "</b>"
  173. Exit Do
  174. Else
  175. s=Left(s,j-1) & "<b style='color:#FF6347'>" & strQuestion & "</b>" & Right(s,Len(s)-j-Len(strQuestion)+1)
  176. End If
  177. i=j+Len("<b style='color:#FF6347'>" & strQuestion & "</b>")-1
  178. If i>=Len(s) Then Exit Do
  179. Loop
  180. End If
  181. If s="" Then
  182. Search=strText
  183. Else
  184. Search=s
  185. End If
  186. End Function
  187. '*********************************************************
  188. '*********************************************************
  189. ' 目的:    检查引用
  190. ' 输入:    SQL值(引用)
  191. ' 返回:    
  192. '*********************************************************
  193. Function FilterSQL(strSQL)
  194. FilterSQL=CStr(Replace(strSQL,chr(39),chr(39)&chr(39)))
  195. End Function
  196. '*********************************************************
  197. '*********************************************************
  198. ' 目的:    检查引用
  199. ' 输入:    
  200. ' 输入:    要替换的字符代号
  201. ' 返回:    
  202. '*********************************************************
  203. Function TransferHTML(ByVal source,para)
  204. Dim objRegExp
  205. '先换"&"
  206. If Instr(para,"[&]")>0 Then  source=Replace(source,"&","&amp;")
  207. If Instr(para,"[<]")>0 Then  source=Replace(source,"<","&lt;")
  208. If Instr(para,"[>]")>0 Then  source=Replace(source,">","&gt;")
  209. If Instr(para,"[""]")>0 Then source=Replace(source,"""","&quot;")
  210. If Instr(para,"[space]")>0 Then source=Replace(source," ","&nbsp;")
  211. If Instr(para,"[enter]")>0 Then
  212. source=Replace(source,vbCrLf,"<br/>")
  213. source=Replace(source,vbLf,"<br/>")
  214. End If
  215. If Instr(para,"[vbCrlf]")>0 And ZC_AUTO_NEWLINE Then 
  216. Set objRegExp=New RegExp
  217. objRegExp.IgnoreCase =True
  218. objRegExp.Global=True
  219. objRegExp.Pattern="((</?form[^n<]*>)|(<select[^n<]*>)|(<textarea[^n<]*>)|(</?option[^n<]*>)|(</?dl[^n<]*>)|(</?dt[^n<]*>)|(</?dd[^n<]*>)|(</?th[^n<]*>)|(</?tr[^n<]*>)|(</?td[^n<]*>)|(</?tbody[^n<]*>)|(</?table[^n<]*>)|(</?hr[^n<]*>)|(</?div[^n<]*>)|(</?ul[^n<]*>)|(</?li[^n<]*>)|(</?ol[^n<]*>)|(</?h1[^n<]*>)|(</?h2[^n<]*>)|(</?h3[^n<]*>)|(</?h4[^n<]*>)|(</?h5[^n<]*>)|(</?h6[^n<]*>)|(</?p[^n<]*>))(x20*(rn|n))"
  220. source= objRegExp.Replace(source,"$1")
  221. objRegExp.Pattern="(rn|n)"
  222. source= objRegExp.Replace(source,"<br/>")
  223. source=Replace(source,"<html>","")
  224. source=Replace(source,"</html>","")
  225. source=Replace(source,"<body>","")
  226. source=Replace(source,"</body>","")
  227. End If
  228. If Instr(para,"[vbTab]")>0 Then source=Replace(source,vbTab,"&nbsp;&nbsp;")
  229. If Instr(para,"[upload]")>0 Then
  230. source=Replace(source,"src=""upload/","src="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/")
  231. source=Replace(source,"href=""upload/","href="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/")
  232. source=Replace(source,"value=""upload/","value="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/")
  233. source=Replace(source,"href=""http://upload/","href="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/")
  234. source=Replace(source,"(this.nextSibling,'upload/","(this.nextSibling,'"& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/")
  235. source=Replace(source,"src=""image/face/","src="""& ZC_BLOG_HOST & "image/face/")
  236. End If
  237. If Instr(para,"[anti-upload]")>0 Then
  238. source=Replace(source,"src="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/","src=""upload/")
  239. source=Replace(source,"href="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/","href=""upload/")
  240. source=Replace(source,"value="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/","value=""upload/")
  241. source=Replace(source,"href="""& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/","href=""http://upload/")
  242. source=Replace(source,"(this.nextSibling,'"& ZC_BLOG_HOST & ZC_UPLOAD_DIRECTORY & "/","(this.nextSibling,'upload/")
  243. source=Replace(source,"src="""& ZC_BLOG_HOST & "image/face/","src=""image/face/")
  244. End If
  245. If Instr(para,"[zc_blog_host]")>0 Then
  246. source=Replace(source,"<#ZC_BLOG_HOST#>",ZC_BLOG_HOST)
  247. End If
  248. If Instr(para,"[anti-zc_blog_host]")>0 Then
  249. source=Replace(source,ZC_BLOG_HOST,"<#ZC_BLOG_HOST#>")
  250. End If
  251. If Instr(para,"[no-asp]")>0 Then
  252. source=Replace(source,"<"&"%","&lt;"&"%")
  253. source=Replace(source,"%"&">","%"&"&gt;")
  254. End If
  255. If ZC_COMMENT_NOFOLLOW_ENABLE And Instr(para,"[nofollow]")>0 Then
  256. source=Replace(source,"<a ","<a rel=""nofollow"" ")
  257. End If
  258. If Instr(para,"[nohtml]")>0  Then
  259. Set objRegExp=New RegExp
  260. objRegExp.IgnoreCase =True
  261. objRegExp.Global=True
  262. objRegExp.Pattern="<[^>]*>"
  263. source= objRegExp.Replace(source,"")
  264. End If
  265. If Instr(para,"[filename]")>0  Then
  266. source=Replace(source,"/","")
  267. source=Replace(source,"","")
  268. source=Replace(source,":","")
  269. source=Replace(source,"?","")
  270. source=Replace(source,"*","")
  271. source=Replace(source,"""","")
  272. source=Replace(source,"<","")
  273. source=Replace(source,">","")
  274. source=Replace(source,"|","")
  275. source=Replace(source," ","")
  276. End If
  277. If Instr(para,"[normalname]")>0  Then
  278. source=Replace(source,"$","")
  279. source=Replace(source,"(","")
  280. source=Replace(source,")","")
  281. source=Replace(source,"*","")
  282. source=Replace(source,"+","")
  283. source=Replace(source,",","")
  284. source=Replace(source,"[","")
  285. source=Replace(source,"]","")
  286. source=Replace(source,"{","")
  287. source=Replace(source,"}","")
  288. source=Replace(source,"?","")
  289. source=Replace(source,"","")
  290. source=Replace(source,"^","")
  291. source=Replace(source,"|","")
  292. source=Replace(source,":","")
  293. source=Replace(source,"""","")
  294. source=Replace(source,"'","")
  295. End If
  296. If Instr(para,"[textarea]")>0 Then
  297. 'Set objRegExp=New RegExp
  298. 'objRegExp.IgnoreCase =True
  299. 'objRegExp.Global=True
  300. 'objRegExp.Pattern="(&)([#a-z0-9]{2,10})(;)"
  301. 'source= objRegExp.Replace(source,"&amp;$2$3")
  302. source=Replace(source,"&","&amp;")
  303. source=Replace(source,"%","&#037;")
  304. source=Replace(source,"<","&lt;")
  305. source=Replace(source,">","&gt;")
  306. End If
  307. If ZC_JAPAN_TO_HTML And Instr(para,"[japan-html]")>0 Then
  308. source=Replace(source,"ガ","&#12460;")
  309. source=Replace(source,"ギ","&#12462;")
  310. source=Replace(source,"ア","&#12450;")
  311. source=Replace(source,"ゲ","&#12466;")
  312. source=Replace(source,"ゴ","&#12468;")
  313. source=Replace(source,"ザ","&#12470;")
  314. source=Replace(source,"ジ","&#12472;")
  315. source=Replace(source,"ズ","&#12474;")
  316. source=Replace(source,"ゼ","&#12476;")
  317. source=Replace(source,"ゾ","&#12478;")
  318. source=Replace(source,"ダ","&#12480;")
  319. source=Replace(source,"ヂ","&#12482;")
  320. source=Replace(source,"ヅ","&#12485;")
  321. source=Replace(source,"デ","&#12487;")
  322. source=Replace(source,"ド","&#12489;")
  323. source=Replace(source,"バ","&#12496;")
  324. source=Replace(source,"パ","&#12497;")
  325. source=Replace(source,"ビ","&#12499;")
  326. source=Replace(source,"ピ","&#12500;")
  327. source=Replace(source,"ブ","&#12502;")
  328. source=Replace(source,"ブ","&#12502;")
  329. source=Replace(source,"プ","&#12503;")
  330. source=Replace(source,"ベ","&#12505;")
  331. source=Replace(source,"ペ","&#12506;")
  332. source=Replace(source,"ボ","&#12508;")
  333. source=Replace(source,"ポ","&#12509;")
  334. source=Replace(source,"ヴ","&#12532;")
  335. End If
  336. If ZC_JAPAN_TO_HTML And Instr(para,"[html-japan]")>0 Then
  337. source=Replace(source,"&#12460;","ガ")
  338. source=Replace(source,"&#12462;","ギ")
  339. source=Replace(source,"&#12450;","ア")
  340. source=Replace(source,"&#12466;","ゲ")
  341. source=Replace(source,"&#12468;","ゴ")
  342. source=Replace(source,"&#12470;","ザ")
  343. source=Replace(source,"&#12472;","ジ")
  344. source=Replace(source,"&#12474;","ズ")
  345. source=Replace(source,"&#12476;","ゼ")
  346. source=Replace(source,"&#12478;","ゾ")
  347. source=Replace(source,"&#12480;","ダ")
  348. source=Replace(source,"&#12482;","ヂ")
  349. source=Replace(source,"&#12485;","ヅ")
  350. source=Replace(source,"&#12487;","デ")
  351. source=Replace(source,"&#12489;","ド")
  352. source=Replace(source,"&#12496;","バ")
  353. source=Replace(source,"&#12497;","パ")
  354. source=Replace(source,"&#12499;","ビ")
  355. source=Replace(source,"&#12500;","ピ")
  356. source=Replace(source,"&#12502;","ブ")
  357. source=Replace(source,"&#12502;","ブ")
  358. source=Replace(source,"&#12503;","プ")
  359. source=Replace(source,"&#12505;","ベ")
  360. source=Replace(source,"&#12506;","ペ")
  361. source=Replace(source,"&#12508;","ボ")
  362. source=Replace(source,"&#12509;","ポ")
  363. source=Replace(source,"&#12532;","ヴ")
  364. End If
  365. If Instr(para,"[html-format]")>0 Then
  366. source=Replace(source,"&","&amp;")
  367. source=Replace(source,"<","&lt;")
  368. source=Replace(source,">","&gt;")
  369. source=Replace(source,"""","&quot;")
  370. End If
  371. If Instr(para,"[anti-html-format]")>0 Then
  372. source=Replace(source,"&quot;","""")
  373. source=Replace(source,"&lt;","<")
  374. source=Replace(source,"&gt;",">")
  375. source=Replace(source,"&amp;","&")
  376. End If
  377. If Instr(para,"[wapnohtml]")>0 Then
  378. source=Replace(source,"<br/>",vbCrLf)
  379. source=Replace(source,"<br>",vbCrLf)
  380. Set objRegExp=New RegExp
  381. objRegExp.IgnoreCase =True
  382. objRegExp.Global=True
  383. objRegExp.Pattern="(<[^>]*)|([^<]*>)"
  384. source= objRegExp.Replace(source,"")
  385. objRegExp.Pattern="(rn|n)"
  386. source= objRegExp.Replace(source,"<br/>")
  387. End If
  388. If Instr(para,"[nbsp-br]")>0 Then
  389. Set objRegExp=New RegExp
  390. objRegExp.IgnoreCase =True
  391. objRegExp.Global=True
  392. objRegExp.Pattern="&lt;$|&lt;b$|&lt;br$|&lt;br/$"
  393. source= objRegExp.Replace(source,"")
  394. objRegExp.Pattern="^br/&gt;|^r/&gt;|^/&gt;|^&gt;"
  395. source= objRegExp.Replace(source,"")
  396. objRegExp.Pattern="&lt;br/&gt;"
  397. source= objRegExp.Replace(source,"<br/>")
  398. objRegExp.Pattern="&amp;nbsp;"
  399. source= objRegExp.Replace(source," ")
  400. End If
  401. If Instr(para,"[closehtml]")>0 Then
  402. source=closeHTML(source)
  403. End If
  404. TransferHTML=source
  405. End Function
  406. '*********************************************************
  407. '*********************************************************
  408. ' 目的:   301 Moved
  409. ' 输入:    
  410. ' 返回:    
  411. '*********************************************************
  412. Sub RedirectBy301(strURL)
  413. Response.Clear
  414. Response.Status="301 Moved Permanently"
  415. Response.AddHeader "Location",strURL
  416. Response.End
  417. End Sub
  418. '*********************************************************
  419. '*********************************************************
  420. ' 目的:   Random Number Create
  421. ' 输入:    
  422. ' 返回:    
  423. '*********************************************************
  424. Sub CreateVerifyNumber()
  425. Dim i,j,s,t
  426. Randomize
  427. Dim aryVerifyNumber(10000)
  428. For j=0 To 10000
  429. s=""
  430. For i = 0 To 4
  431. t = Int(Rnd * Len(ZC_VERIFYCODE_STRING))
  432. s= s & Mid(ZC_VERIFYCODE_STRING,t + 1, 1)
  433. Next
  434. aryVerifyNumber(j)=s
  435. Next
  436. Application.Lock
  437. Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")=aryVerifyNumber
  438. Application.UnLock
  439. End Sub
  440. '*********************************************************
  441. '*********************************************************
  442. ' 目的:   Random Number Get
  443. ' 输入:    
  444. ' 返回:    
  445. '*********************************************************
  446. Function GetVerifyNumber()
  447. Randomize
  448. Dim i,j,s,t
  449. Dim aryVerifyNumber
  450. Application.Lock
  451. aryVerifyNumber=Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")
  452. Application.UnLock
  453. If IsEmpty(aryVerifyNumber)=True Or IsArray(aryVerifyNumber)=False Then
  454. Call CreateVerifyNumber()
  455. Application.Lock
  456. aryVerifyNumber=Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")
  457. Application.UnLock
  458. End If
  459. For i=0 To 10000
  460. If (aryVerifyNumber(i)<>"") And (Len(aryVerifyNumber(i))=5) Then 
  461. GetVerifyNumber=aryVerifyNumber(i)
  462. Exit For
  463. End If
  464. Next
  465. aryVerifyNumber(i)=aryVerifyNumber(i)&"-"
  466. If i=5000 Then
  467. For j=5001 To 10000
  468. s=""
  469. For i = 0 To 4
  470. t = Int(Rnd * Len(ZC_VERIFYCODE_STRING))
  471. s= s & Mid(ZC_VERIFYCODE_STRING,t + 1, 1)
  472. Next
  473. aryVerifyNumber(j)=s
  474. Next
  475. End If
  476. If i=10000 Then
  477. For j=0 To 5000
  478. s=""
  479. For i = 0 To 4
  480. t = Int(Rnd * Len(ZC_VERIFYCODE_STRING))
  481. s= s & Mid(ZC_VERIFYCODE_STRING,t + 1, 1)
  482. Next
  483. aryVerifyNumber(j)=s
  484. Next
  485. End If
  486. Application.Lock
  487. Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")=aryVerifyNumber
  488. Application.UnLock
  489. End Function
  490. '*********************************************************
  491. '*********************************************************
  492. ' 目的:   Random Number Check
  493. ' 输入:    
  494. ' 返回:    
  495. '*********************************************************
  496. Function CheckVerifyNumber(ByVal strNumber)
  497. Dim i,j,s,t
  498. Dim aryVerifyNumber
  499. Application.Lock
  500. aryVerifyNumber=Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")
  501. Application.UnLock
  502. If IsEmpty(aryVerifyNumber) Then Exit Function
  503. strNumber=UCase(strNumber)
  504. For j=0 To 10000
  505. If aryVerifyNumber(j)=strNumber & "-" Then
  506. Randomize
  507. s=""
  508. For i = 0 To 4
  509. t = Int(Rnd * Len(ZC_VERIFYCODE_STRING))
  510. s= s & Mid(ZC_VERIFYCODE_STRING,t + 1, 1)
  511. Next
  512. aryVerifyNumber(j)=s
  513. Application.Lock
  514. Application(ZC_BLOG_CLSID & "VERIFY_NUMBER")=aryVerifyNumber
  515. Application.UnLock
  516. CheckVerifyNumber=True
  517. Exit Function
  518. End If
  519. Next
  520. End Function
  521. '*********************************************************
  522. '*********************************************************
  523. ' 目的:    UBB
  524. ' 输入:    
  525. ' 输入:    
  526. ' 返回:    
  527. '*********************************************************
  528. Function UBBCode(ByVal strContent,strType)
  529. Dim objRegExp
  530. Set objRegExp=new RegExp
  531. objRegExp.IgnoreCase =True
  532. objRegExp.Global=True
  533. If ZC_UBB_LINK_ENABLE And Instr(strType,"[link]")>0 Then
  534. objRegExp.Pattern="([URL])(([a-zA-Z0-9]+?)://[^ :()fnrtv]+?)([/URL])"
  535. strContent= objRegExp.Replace(strContent,"<a href=""$2"" target=""_blank"">$2</a>")
  536. objRegExp.Pattern="([URL])([^ :()fnrtv]+?)([/URL])"
  537. strContent= objRegExp.Replace(strContent,"<a href=""http://$2"" target=""_blank"">$2</a>")
  538. objRegExp.Pattern="([URL=)(([a-zA-Z0-9]+?)://[^ :()fnrtv]+?)(])(.+?)([/URL])"
  539. strContent= objRegExp.Replace(strContent,"<a href=""$2"" target=""_blank"">$5</a>")
  540. objRegExp.Pattern="([URL=)([^ :()fnrtv]+?)(])(S+?)([/URL])"
  541. strContent= objRegExp.Replace(strContent,"<a href=""http://$2"" target=""_blank"">$4</a>")
  542. End If
  543. If ZC_UBB_LINK_ENABLE And Instr(strType,"[email]")>0 Then
  544. objRegExp.Pattern="([EMAIL])(S+@S+?)([/EMAIL])"
  545. strContent= objRegExp.Replace(strContent,"<a href=""mailto:$2"" >$2</a>")
  546. objRegExp.Pattern="([EMAIL=)(S+@S+?)(])(.+?)([/EMAIL])"
  547. strContent= objRegExp.Replace(strContent,"<a href=""mailto:$2"">$4</a>")
  548. End If
  549. If ZC_UBB_FONT_ENABLE And Instr(strType,"[font]")>0 Then
  550. objRegExp.Pattern="([I])([u0000-uffff]+?)([/I])"
  551. strContent=objRegExp.Replace(strContent,"<i>$2</i>")
  552. objRegExp.Pattern="([B])([u0000-uffff]+?)([/B])"
  553. strContent=objRegExp.Replace(strContent,"<b>$2</b>")
  554. objRegExp.Pattern="([U])([u0000-uffff]+?)([/U])"
  555. strContent=objRegExp.Replace(strContent,"<u>$2</u>")
  556. objRegExp.Pattern="([S])([u0000-uffff]+?)([/S])"
  557. strContent=objRegExp.Replace(strContent,"<s>$2</s>")
  558. objRegExp.Pattern="([QUOTE])([u0000-uffff]+?)([/QUOTE])"
  559. strContent=objRegExp.Replace(strContent,"<blockquote><div class=""quote"">$2"&"</div></blockquote>")
  560. objRegExp.Pattern="([QUOTE=)(.+?)(])([u0000-uffff]+?)([/QUOTE])"
  561. strContent= objRegExp.Replace(strContent,"<blockquote><div class=""quote quote2""><div class=""quote-title"">"&ZC_MSG153&" $2</div>$4"&"</div></blockquote>")
  562. objRegExp.Pattern="([REVERT=)(.+?)(])([u0000-uffff]+?)([/REVERT])"
  563. strContent= objRegExp.Replace(strContent,"<blockquote><div class=""quote quote3""><div class=""quote-title"">$2</div>$4</div></blockquote>")
  564. End If
  565. If ZC_UBB_CODE_ENABLE And Instr(strType,"[code]")>0 Then
  566. Dim strCode
  567. Dim Match, Matches
  568. strContent =Replace(strContent,vbLf,"")
  569. '[CODELITE]
  570. objRegExp.Pattern="([CODE_LITE])(.+?)([/CODE_LITE])"
  571. Set Matches = objRegExp.Execute(strContent)
  572. For Each Match in Matches
  573. strCode=Match
  574. strCode = TransferHTML(strCode,"[<][>][space][vbTab]")
  575. strCode=Replace(strCode,vbCr,"<br/>")
  576. strContent =Replace(strContent,Match,strCode)
  577. objRegExp.Global=False
  578. objRegExp.Pattern="([CODE_LITE](<br/>)?)(.+?)([/CODE_LITE])"
  579. strContent=objRegExp.Replace(strContent,"<p class=""code""><code>$3</code></p>")
  580. objRegExp.Global=True
  581. Next
  582. Set Matches = Nothing
  583. '[CODE]
  584. objRegExp.Pattern="([CODE])(.+?)([/CODE])"
  585. Set Matches = objRegExp.Execute(strContent)
  586. For Each Match in Matches
  587. strCode=Match
  588. strCode = TransferHTML(strCode,"[<][>][space][vbTab]")
  589. strCode = Replace(strCode,vbCr,Chr(8)&Chr(11)&Chr(9)&Chr(12))
  590. strContent =Replace(strContent,Match,strCode)
  591. objRegExp.Global=False
  592. objRegExp.Pattern="([CODE])(.+?)([/CODE])"
  593. strContent=objRegExp.Replace(strContent,"<textarea class=""code"" rows=""10"" cols=""50"">$2</textarea>")
  594. objRegExp.Global=True
  595. Next
  596. Set Matches = Nothing
  597. strContent =Replace(strContent,vbCr,vbCrLf)
  598. strContent =Replace(strContent,Chr(8)&Chr(11)&Chr(9)&Chr(12),vbCr)
  599. End If
  600. If ZC_UBB_FACE_ENABLE And Instr(strType,"[face]")>0 Then
  601. objRegExp.Pattern="([F])(.+?)([/F])"
  602. strContent= objRegExp.Replace(strContent,"<img src="""& ZC_BLOG_HOST &"image/face/$2.gif"" style=""padding:2px;border:0;"" width="""&ZC_EMOTICONS_FILESIZE&""" title=""$2"" alt=""$2"" />")
  603. End If
  604. If ZC_UBB_IMAGE_ENABLE And Instr(strType,"[image]")>0 Then
  605. '[img]
  606. objRegExp.Pattern="([IMG=)([0-9]*),([0-9]*),([^n[]*)(])(.+?)([/IMG])"
  607. strContent= objRegExp.Replace(strContent,"<img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
  608. objRegExp.Pattern="([IMG=)([0-9]*),([^n[]*)(])(.+?)([/IMG])"
  609. strContent= objRegExp.Replace(strContent,"<img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
  610. objRegExp.Pattern="([IMG=)([0-9]*)(])(.+?)([/IMG])"
  611. strContent= objRegExp.Replace(strContent,"<img src=""$4"" alt="""" title="""" width=""$2""/>")
  612. objRegExp.Pattern="([IMG])(.+?)([/IMG])"
  613. strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" src=""$2"" alt="""" title=""""/>")
  614. objRegExp.Pattern="([IMG_LEFT=)([0-9]*),([0-9]*),([^n[]*)(])(.+?)([/IMG_LEFT])"
  615. strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
  616. objRegExp.Pattern="([IMG_LEFT=)([0-9]*),([^n[]*)(])(.+?)([/IMG_LEFT])"
  617. strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
  618. objRegExp.Pattern="([IMG_LEFT=)([0-9]*)(])(.+?)([/IMG_LEFT])"
  619. strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$4"" alt="""" title="""" width=""$2""/>")
  620. objRegExp.Pattern="([IMG_LEFT])(.+?)([/IMG_LEFT])"
  621. strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-left"" style=""float:left"" src=""$2"" alt="""" title=""""/>")
  622. objRegExp.Pattern="([IMG_RIGHT=)([0-9]*),([0-9]*),(.*)(])(.+?)([/IMG_RIGHT])"
  623. strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
  624. objRegExp.Pattern="([IMG_RIGHT=)([0-9]*),(.*)(])(.+?)([/IMG_RIGHT])"
  625. strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
  626. objRegExp.Pattern="([IMG_RIGHT=)([0-9]*)(])(.+?)([/IMG_RIGHT])"
  627. strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$4"" alt="""" title="""" width=""$2""/>")
  628. objRegExp.Pattern="([IMG_RIGHT])(.+?)([/IMG_RIGHT])"
  629. strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-right"" style=""float:right"" src=""$2"" alt="""" title=""""/>")
  630. End If
  631. If ZC_UBB_FLASH_ENABLE And Instr(strType,"[flash]")>0 Then
  632. '[flash]
  633. objRegExp.Pattern="([FLASH=)([0-9]*),([0-9]*),([a-z]*)(])(.+?)([/FLASH])"
  634. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"" width=""$2"" height=""$3""><param name=""movie"" value=""$6""><param name=""quality"" value=""high""><param name=""play"" value=""$4""><embed src=""$6"" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" width=""$2"" height=""$3"" play=""$4""></embed></object>")
  635. End If
  636. If ZC_UBB_TYPESET_ENABLE And Instr(strType,"[typeset]")>0 Then
  637. objRegExp.Pattern="([ALIGN-CENTER])([u0000-uffff]+?)([/ALIGN-CENTER])"
  638. strContent=objRegExp.Replace(strContent,"<div style=""margin:10px 0 10px 0;text-align:center;"">$2</div>")
  639. objRegExp.Pattern="([ALIGN-LELT])([u0000-uffff]+?)([/ALIGN-LELT])"
  640. strContent=objRegExp.Replace(strContent,"<div style=""margin:10px 0 10px 0;text-align:left;"">$2</div>")
  641. objRegExp.Pattern="([ALIGN-RIGHT])([u0000-uffff]+?)([/ALIGN-RIGHT])"
  642. strContent=objRegExp.Replace(strContent,"<div style=""margin:10px 0 10px 0;text-align:right;"">$2</div>")
  643. objRegExp.Pattern="([HR])([u0000-uffff]?)([/HR])"
  644. strContent=objRegExp.Replace(strContent,"<hr/>")
  645. objRegExp.Pattern="([FONT-FACE=)([a-zx20]*)(])([u0000-uffff]+?)([/FONT-FACE])"
  646. strContent=objRegExp.Replace(strContent,"<font face=""$2"">$4</font>")
  647. objRegExp.Pattern="([FACE=)([a-zx20]*)(])([u0000-uffff]+?)([/FACE])"
  648. strContent=objRegExp.Replace(strContent,"<font face=""$2"">$4</font>")
  649. objRegExp.Pattern="([FONT-SIZE=)([1-7]*)(])([u0000-uffff]+?)([/FONT-SIZE])"
  650. strContent=objRegExp.Replace(strContent,"<font size=""$2"">$4</font>")
  651. objRegExp.Pattern="([SIZE=)([1-7]*)(])([u0000-uffff]+?)([/SIZE])"
  652. strContent=objRegExp.Replace(strContent,"<font size=""$2"">$4</font>")
  653. objRegExp.Pattern="([FONT-COLOR=)([#0-9a-z]*)(])([u0000-uffff]+?)([/FONT-COLOR])"
  654. strContent=objRegExp.Replace(strContent,"<font color=""$2"">$4</font>")
  655. objRegExp.Pattern="([COLOR=)([#0-9a-z]*)(])([u0000-uffff]+?)([/COLOR])"
  656. strContent=objRegExp.Replace(strContent,"<font color=""$2"">$4</font>")
  657. End If
  658. If ZC_UBB_MEDIA_ENABLE And Instr(strType,"[media]")>0 Then
  659. '[WMA]
  660. objRegExp.Pattern="([WMA=)([a-z]*)(])(.+?)([/WMA])"
  661. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" height=""68"" width=""350""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""$2""><param name=""Filename"" value=""$4""><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$4"" autostart=""$2"" width=""350"" height=""45""></embed></object>")
  662. objRegExp.Pattern="([WMA])(.+?)([/WMA])"
  663. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" height=""68"" width=""350""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""true""><param name=""Filename"" value=""$2""><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$2"" autostart=""true"" width=""350"" height=""45""></embed></object>")
  664. '[WMV]
  665. objRegExp.Pattern="([WMV=)([0-9]*),([0-9]*),([a-z]*)(])(.+?)([/WMV])"
  666. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95""  width=""$2"" height=""$3""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""$4""><param name=""Filename"" value=""$6""><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$6"" autostart=""$4""></embed></object>")
  667. objRegExp.Pattern="([WMV])(.+?)([/WMV])"
  668. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95""><param name=""ShowStatusBar"" value=""-1""><param name=""AutoStart"" value=""true""><param name=""Filename"" value=""$2""><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""$2"" autostart=""true""></embed></object>")
  669. '[RMV]
  670. objRegExp.Pattern="([RM=)([0-9]*),([0-9]*),([a-z]*)(])(.+?)([/RM])"
  671. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" width=""$2"" height=""$3""><param name=""src"" value=""$6""><param name=""controls"" value=""imagewindow""><param name=""console"" value=""one""><param name=""AutoStart"" value=""$4""><embed src=""$6"" type=""audio/x-pn-realaudio-plugin"" width=""$2"" height=""$3"" nojava=""true"" controls=""imagewindow,ControlPanel,StatusBar"" console=""one"" autostart=""$4""></object>")
  672. objRegExp.Pattern="([RM])(.+?)([/RM])"
  673. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA""><param name=""src"" value=""$2""><param name=""controls"" value=""imagewindow""><param name=""console"" value=""one""><param name=""AutoStart"" value=""true""><embed src=""$2"" type=""audio/x-pn-realaudio-plugin"" nojava=""true"" controls=""imagewindow,ControlPanel,StatusBar"" console=""one"" autostart=""true""></embed></object>")
  674. '[RA]
  675. objRegExp.Pattern="([RA=)([a-z]*)(])(.+?)([/RA])"
  676. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" width=""350"" height=""36""><param name=""src"" value=""$4""><param name=""controls"" value=""ControlPanel""><param name=""console"" value=""one""><param name=""AutoStart"" value=""$2""><embed src=""$4"" type=""audio/x-pn-realaudio-plugin"" nojava=""true"" controls=""ControlPanel,StatusBar"" console=""one"" autostart=""$2"" width=""350"" height=""36""></embed></object>")
  677. objRegExp.Pattern="([RA])(.+?)([/RA])"
  678. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" width=""350"" height=""36""><param name=""src"" value=""$2""><param name=""controls"" value=""ControlPanel""><param name=""console"" value=""one""><param name=""AutoStart"" value=""true""><embed src=""$2"" type=""audio/x-pn-realaudio-plugin"" nojava=""true"" controls=""ControlPanel,StatusBar"" console=""one"" autostart=""true"" width=""350"" height=""36""></embed></object>")
  679. '[QT]
  680. objRegExp.Pattern="([QT=)([0-9]*),([0-9]*),([a-z]*)(])(.+?)([/QT])"
  681. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"" codebase=""http://www.apple.com/qtactivex/qtplugin.cab"" width=""$2"" height=""$3"" ><param name=""src"" value=""$6"" ><param name=""autoplay"" value=""$4"" ><embed  src=""qtmimetype.pntg"" type=""image/x-macpaint"" pluginspage=""http://www.apple.com/quicktime/download"" qtsrc=""$6"" width=""$2"" height=""$3"" autoplay=""$4"" ></embed></object>")
  682. objRegExp.Pattern="([QT])(.+?)([/QT])"
  683. strContent= objRegExp.Replace(strContent,"<object classid=""clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"" codebase=""http://www.apple.com/qtactivex/qtplugin.cab"" ><param name=""src"" value=""$2"" ><param name=""autoplay"" value=""true"" ><embed  src=""qtmimetype.pntg"" type=""image/x-macpaint"" pluginspage=""http://www.apple.com/quicktime/download"" qtsrc=""$2"" autoplay=""true"" ></embed></object>")
  684. '[MEDIA]
  685. objRegExp.Pattern="([MEDIA=)([a-z]*),([0-9]*),([0-9]*)(])(.+?)([/MEDIA])"
  686. strContent= objRegExp.Replace(strContent,"<div class=""media""><a href="""" onclick=""javascript:ShowMedia(this.nextSibling,'$6','$2',$3,$4);return(false);"">"& ZC_MSG103 &"</a><div class=""media-object""></div></div>")
  687. objRegExp.Pattern="([MEDIA=)([0-9]*),([0-9]*)(])(.+?)([/MEDIA])"
  688. strContent= objRegExp.Replace(strContent,"<div class=""media""><a href="""" onclick=""javascript:ShowMedia(this.nextSibling,'$5','AUTO',$2,$3);return(false);"">"& ZC_MSG103 &"</a><div class=""media-object""></div></div>")
  689. objRegExp.Pattern="([MEDIA])(.+?)([/MEDIA])"
  690. strContent= objRegExp.Replace(strContent,"<div class=""media""><a href="""" onclick=""javascript:ShowMedia(this.nextSibling,'$2','AUTO',400,300);return(false);"">"& ZC_MSG103 &"</a><div class=""media-object""></div></div>")
  691. End If
  692. If ZC_UBB_AUTOLINK_ENABLE And Instr(strType,"[autolink]")>0 Then
  693. objRegExp.Pattern="(^|rn|n)((http|https|ftp|mailto|gopher|news|telnet|mms|rtsp|ed2k|tencent|nfcall|dic|pig2pig|callto|exeem|ymsgr|thunder|p4p|pplive|synacast|ppstream|feed|wangwang|qqtv|rssfeed|msnim|chrome|file|ppg|thunder):{1}/{0,2}[^<>fnrtv]+?)(rn|n|$)"
  694. strContent=objRegExp.Replace(strContent,vbCrlf & "<a href=""$2""  target=""_blank"">$2</a>" & vbCrlf)
  695. objRegExp.Pattern="(^|rn|n)((http|https|ftp|mailto|gopher|news|telnet|mms|rtsp|ed2k|tencent|nfcall|dic|pig2pig|callto|exeem|ymsgr|thunder|p4p|pplive|synacast|ppstream|feed|wangwang|qqtv|rssfeed|msnim|chrome|file|ppg|thunder):{1}/{0,2}[^<>fnrtv]+?)(rn|n|$)"
  696. strContent=objRegExp.Replace(strContent,vbCrlf & "<a href=""$2""  target=""_blank"">$2</a>" & vbCrlf)
  697. End If
  698. If ZC_UBB_AUTOKEY_ENABLE And Instr(strType,"[key]")>0 Then
  699. Dim i,j
  700. If IsArray(KeyWords) Then
  701. For i=Lbound(KeyWords,2) To Ubound(KeyWords,2)
  702. objRegExp.Pattern="((<.*)("&KeyWords(1,i)&")(.*>))|((<a.*)("&KeyWords(1,i)&")(/a>))"
  703. Set Matches = objRegExp.Execute(strContent)
  704. For Each Match in Matches
  705. strContent=Replace(strContent,Match,vbVerticalTab & vbTab & vbVerticalTab)
  706. Next
  707. strContent=Replace(strContent,KeyWords(1,i),"<a href="""& KeyWords(2,i) &""" target=""_blank"">"& KeyWords(1,i) &"</a>")
  708. For Each Match in Matches
  709. strContent=Replace(strContent,vbVerticalTab & vbTab & vbVerticalTab,Match,1,1)
  710. Next
  711. Set Matches = Nothing
  712. Next
  713. End If
  714. End If
  715. If ZC_UBB_LINK_ENABLE And Instr(strType,"[link-antispam]")>0 Then
  716. Dim Match2, Matches2 ,strCode2
  717. objRegExp.Pattern="(href="".+?"")"
  718. Set Matches2 = objRegExp.Execute(strContent)
  719. For Each Match2 in Matches2
  720. strCode2=Match2
  721. strCode2=Left(strCode2,Len(strCode2)-1)
  722. strCode2=Right(strCode2,Len(strCode2)-6)
  723. strCode2=URLEncodeForAntiSpam(strCode2)
  724. strContent =Replace(strContent,Match2,"href=""" & strCode2 & """")
  725. Next
  726. Set Matches2 = Nothing
  727. End If
  728. Set objRegExp=Nothing
  729. UBBCode=strContent
  730. End Function
  731. '*********************************************************
  732. '*********************************************************
  733. ' 目的:    Save Text to File
  734. ' 输入:    
  735. ' 输入:    
  736. ' 返回:    
  737. '*********************************************************
  738. Function SaveToFile(strFullName,strContent,strCharset,bolRemoveBOM)
  739. On Error Resume Next
  740. Dim objStream
  741. Set objStream = Server.CreateObject("ADODB.Stream")
  742. With objStream
  743. .Type = adTypeText
  744. .Mode = adModeReadWrite
  745. .Open
  746. .Charset = strCharset
  747. .Position = objStream.Size
  748. .WriteText = strContent
  749. .SaveToFile strFullName,adSaveCreateOverWrite
  750. .Close
  751. End With
  752. Set objStream = Nothing
  753. If bolRemoveBOM Then
  754. If strContent<>"" And ZC_STATIC_TYPE="shtml" Then
  755. Call RemoveBOM(strFullName)
  756. End If
  757. End If
  758. Err.Clear
  759. End Function
  760. '*********************************************************
  761. '*********************************************************
  762. ' 目的:    Load Text form File
  763. ' 输入:    
  764. ' 输入:    
  765. ' 返回:    
  766. '*********************************************************
  767. Function LoadFromFile(strFullName,strCharset)
  768. On Error Resume Next
  769. Dim objStream
  770. Set objStream = Server.CreateObject("ADODB.Stream")
  771. With objStream
  772. .Type = adTypeText
  773. .Mode = adModeReadWrite
  774. .Open
  775. .Charset = strCharset
  776. .Position = objStream.Size
  777. .LoadFromFile strFullName
  778. LoadFromFile=.ReadText
  779. .Close
  780. End With
  781. Set objStream = Nothing
  782. Err.Clear
  783. End Function
  784. '*********************************************************
  785. '*********************************************************
  786. ' 目的:    Remove BOM from UTF-8
  787. '*********************************************************
  788. Function RemoveBOM(strFullName)
  789. On Error Resume Next
  790. Dim objStream
  791. Dim strContent
  792. Set objStream = Server.CreateObject("ADODB.Stream")
  793. With objStream
  794. .Type = adTypeBinary
  795. .Mode = adModeReadWrite
  796. .Open
  797. .Position = objStream.Size
  798. .LoadFromFile strFullName
  799. .Position = 3
  800. strContent=.Read
  801. .Close
  802. End With
  803. Set objStream = NoThing
  804. Set objStream = Server.CreateObject("ADODB.Stream")
  805. With objStream
  806. .Type = adTypeBinary
  807. .Mode = adModeReadWrite
  808. .Open
  809. .Position = objStream.Size
  810. .Write = strContent
  811. .SaveToFile strFullName,adSaveCreateOverWrite
  812. .Close
  813. End With
  814. Set objStream = Nothing
  815. Err.Clear
  816. End Function
  817. '*********************************************************
  818. '*********************************************************
  819. ' 目的:    Save Value For Setting
  820. '*********************************************************
  821. Function SaveValueForSetting(ByRef strContent,bolConst,strTypeVar,strItem,strValue)
  822. Dim i,j,s,t
  823. Dim strConst
  824. Dim objRegExp
  825. If bolConst=True Then strConst="Const"
  826. Set objRegExp=New RegExp
  827. objRegExp.IgnoreCase =True
  828. objRegExp.Global=True
  829. strValue=TransferHTML(strValue,"[no-asp]")
  830. If strTypeVar="String" Then
  831. strValue=Replace(strValue,"""","""""")
  832. strValue=""""& strValue &""""
  833. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))(.+?)(rn|n|$)"
  834. If objRegExp.Test(strContent)=True Then
  835. strContent=objRegExp.Replace(strContent,"$1$2"& strValue &"$8")
  836. SaveValueForSetting=True
  837. Exit Function
  838. End If
  839. End If
  840. If strTypeVar="Boolean" Then
  841. strValue=Trim(strValue)
  842. If LCase(strValue)="true" Then
  843. strValue="True"
  844. Else
  845. strValue="False"
  846. End If
  847. If objRegExp.Test(strContent)=True Then
  848. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))([a-z]+)( *)(rn|n|$)"
  849. strContent=objRegExp.Replace(strContent,"$1$2"& strValue &"$9")
  850. SaveValueForSetting=True
  851. Exit Function
  852. End If
  853. End If
  854. If strTypeVar="Numeric" Then
  855. strValue=Trim(strValue)
  856. If IsNumeric(strValue)=False Then
  857. strValue=0
  858. End If
  859. If objRegExp.Test(strContent)=True Then
  860. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))([0-9.]+)( *)(rn|n|$)"
  861. strContent=objRegExp.Replace(strContent,"$1$2"& strValue &"$9")
  862. SaveValueForSetting=True
  863. Exit Function
  864. End If
  865. End If
  866. SaveValueForSetting=False
  867. End Function
  868. '*********************************************************
  869. '*********************************************************
  870. ' 目的:    Load Value For Setting
  871. '*********************************************************
  872. Function LoadValueForSetting(strContent,bolConst,strTypeVar,strItem,ByRef strValue)
  873. Dim i,j,s,t
  874. Dim strConst
  875. Dim objRegExp
  876. Dim Matches,Match
  877. If bolConst=True Then strConst="Const"
  878. Set objRegExp=New RegExp
  879. objRegExp.IgnoreCase =True
  880. objRegExp.Global=True
  881. If strTypeVar="String" Then
  882. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))(.+?)(rn|n|$)"
  883. Set Matches = objRegExp.Execute(strContent)
  884. If Matches.Count=1 Then
  885. t=Matches(0).Value
  886. t=Replace(t,VbCrlf,"")
  887. t=Replace(t,Vblf,"")
  888. objRegExp.Pattern="( *)""(.*)""( *)($)"
  889. Set Matches = objRegExp.Execute(t)
  890. If Matches.Count>0 Then
  891. s=Trim(Matches(0).Value)
  892. s=Mid(s,2,Len(s)-2)
  893. s=Replace(s,"""""","""")
  894. strValue=s
  895. LoadValueForSetting=True
  896. Exit Function
  897. End If
  898. End If
  899. End If
  900. If strTypeVar="Boolean" Then
  901. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))([a-z]+)( *)(rn|n|$)"
  902. Set Matches = objRegExp.Execute(strContent)
  903. If Matches.Count=1 Then
  904. t=Matches(0).Value
  905. t=Replace(t,VbCrlf,"")
  906. t=Replace(t,Vblf,"")
  907. objRegExp.Pattern="( *)((True)|(False))( *)($)"
  908. Set Matches = objRegExp.Execute(t)
  909. If Matches.Count>0 Then
  910. s=Trim(Matches(0).Value)
  911. s=LCase(Matches(0).Value)
  912. If InStr(s,"true")>0 Then
  913. strValue=True
  914. ElseIf InStr(s,"false")>0 Then
  915. strValue=False
  916. End If
  917. LoadValueForSetting=True
  918. Exit Function
  919. End If
  920. End If
  921. End If
  922. If strTypeVar="Numeric" Then
  923. objRegExp.Pattern="(^|rn|n)(( *)" & strConst & "( *)" & strItem & "( *)=( *))([0-9.]+)( *)(rn|n|$)"
  924. Set Matches = objRegExp.Execute(strContent)
  925. If Matches.Count=1 Then
  926. t=Matches(0).Value
  927. t=Replace(t,VbCrlf,"")
  928. t=Replace(t,Vblf,"")
  929. objRegExp.Pattern="( *)([0-9.]+)( *)($)"
  930. Set Matches = objRegExp.Execute(t)
  931. If Matches.Count>0 Then
  932. s=Trim(Matches(0).Value)
  933. If IsNumeric(s)=True Then
  934. strValue=s
  935. LoadValueForSetting=True
  936. Exit Function
  937. End If
  938. End If
  939. End If
  940. End If
  941. LoadValueForSetting=False
  942. End Function
  943. '*********************************************************
  944. '*********************************************************
  945. ' 目的:    
  946. '*********************************************************
  947. Function IsObjInstalled(strClassString)
  948. On Error Resume Next
  949. IsObjInstalled = False
  950. Err = 0
  951. Dim xTestObj
  952. Set xTestObj = Server.CreateObject(strClassString)
  953. If 0 = Err Then IsObjInstalled = True
  954. Set xTestObj = Nothing
  955. Err = 0
  956. End Function
  957. '*********************************************************
  958. '*********************************************************
  959. ' 目的:    
  960. '*********************************************************
  961. Function URLEncodeForAntiSpam(strUrl)
  962. Dim i,s
  963. For i =1 To Len(strUrl)
  964. s=s & Mid(strUrl,i,1) & CStr(Int((10 * Rnd)))
  965. Next
  966. URLEncodeForAntiSpam=ZC_BLOG_HOST & "function/c_urlredirect.asp?url=" & Server.URLEncode(s)
  967. End Function
  968. '*********************************************************
  969. '*********************************************************
  970. ' 目的:    
  971. '*********************************************************
  972. Function URLDecodeForAntiSpam(strUrl)
  973. Dim i,s
  974. For i =1 To Len(strUrl) Step 2
  975. s=s & Mid(strUrl,i,1)
  976. Next
  977. If CheckRegExp(s,"[homepage]")=False Then s=""
  978. URLDecodeForAntiSpam=s
  979. End Function
  980. '*********************************************************
  981. '*********************************************************
  982. ' 目的:    
  983. '*********************************************************
  984. Function GetTime(t)
  985.         GetTime=DateAdd("h", -(ZC_HOST_TIME_ZONE / 100) + (ZC_TIME_ZONE / 100) , t)
  986. End Function
  987. '*********************************************************
  988. '*********************************************************
  989. '目的:自动闭合HTML
  990. '*********************************************************
  991. Function closeHTML(strContent)
  992.   Dim arrTags,i,OpenPos,ClosePos,re,strMatchs,j,Match
  993. Set re=new RegExp
  994. re.IgnoreCase =True
  995. re.Global=True
  996.     arrTags=array("p","div","span","table","ul","font","b","u","i","h1","h2","h3","h4","h5","h6")
  997.   For i=0 To ubound(arrTags)
  998.    OpenPos=0
  999.    ClosePos=0
  1000.    
  1001.    re.Pattern="<"+arrTags(i)+"( [^<>]+|)>"
  1002.    Set strMatchs=re.Execute(strContent)
  1003.    For Each Match In strMatchs
  1004.     OpenPos=OpenPos+1
  1005.    Next
  1006.    re.Pattern="</"+arrTags(i)+">"
  1007.    Set strMatchs=re.Execute(strContent)
  1008.    For Each Match In strMatchs
  1009.     ClosePos=ClosePos+1
  1010.    Next
  1011.    For j=1 To OpenPos-ClosePos
  1012.       strContent=strContent+"</"+arrTags(i)+">"
  1013.    Next
  1014.   Next
  1015.   closeHTML=strContent
  1016. End Function 
  1017. '*********************************************************
  1018. '*********************************************************
  1019. ' 目的:三态
  1020. '*********************************************************
  1021. Function IIf(ByVal expr,ByVal  truepart,ByVal  falsepart)
  1022. If expr=True Then
  1023. IIf=truepart
  1024. Else
  1025. IIf=falsepart
  1026. End If
  1027. End Function
  1028. '*********************************************************
  1029. '*********************************************************
  1030. ' 目的:    unescape
  1031. ' 输入:    
  1032. ' 输入:    要替换的字符
  1033. ' 返回:    
  1034. '*********************************************************
  1035. %>
  1036. <script language="javascript" runat="server">
  1037. function vbsunescape(source){
  1038. return unescape(source);
  1039. }
  1040. </script>