首页 > 编程 > Regex > 正文

asp的ubb函数(推荐)

2020-03-16 21:24:02
字体:
来源:转载
供稿:网友
asp的ubb函数(推荐)

  1. function unHtml(content)  
  2. unHtml=content  
  3. if content <> "" then  
  4. unHtml=replace(unHtml,"&","&")  
  5. unHtml=replace(unHtml,"<","<")  
  6. unHtml=replace(unHtml,">",">")  
  7. unHtml=replace(unHtml,chr(34),""")  
  8. unHtml=replace(unHtml,chr(13),"<br>")  
  9. unHtml=replace(unHtml,chr(32)," ")  
  10. 'unHtml=ubb(unHtml)  
  11. end if  
  12. end function  
  13.  
  14. function ubb(content)  
  15. Dim nowtime,i  
  16. ubb=content  
  17. nowtime=now()  
  18. UBB=Convert(ubb,"code")  
  19. UBB=Convert(ubb,"html")  
  20. UBB=Convert(ubb,"url")  
  21. UBB=Convert(ubb,"color")  
  22. UBB=Convert(ubb,"font")  
  23. UBB=Convert(ubb,"size")  
  24. UBB=Convert(ubb,"quote")  
  25. UBB=Convert(ubb,"email")  
  26. UBB=Convert(ubb,"img")  
  27. UBB=Convert(ubb,"swf")  
  28.  
  29. UBB=AutoURL(ubb)  
  30. ubb=replace(ubb,"[b]","<b>",1,-1,1)  
  31. ubb=replace(ubb,"[/b]","</b>",1,-1,1)  
  32. ubb=replace(ubb,"[i]","<i>",1,-1,1)  
  33. ubb=replace(ubb,"[/i]","</i>",1,-1,1)  
  34. ubb=replace(ubb,"[u]","<u>",1,-1,1)  
  35. ubb=replace(ubb,"[/u]","</u>",1,-1,1)  
  36. ubb=replace(ubb,"[blue]","<font color='#000099'>",1,-1,1)  
  37. ubb=replace(ubb,"[/blue]","</font>",1,-1,1)  
  38. ubb=replace(ubb,"[red]","<font color='#990000'>",1,-1,1)  
  39. ubb=replace(ubb,"[/red]","</font>",1,-1,1)  
  40. for i=1 to 28  
  41. ubb=replace(ubb,"{:em"&i&"}","<IMG SRC=emot/emotface/em"&i&".gif></img>",1,6,1)  
  42. ubb=replace(ubb,"{:em"&i&"}","",1,-1,1)  
  43. next  
  44. ubb=replace(ubb,"["&chr(176),"[",1,-1,1)  
  45. ubb=replace(ubb,chr(176)&"]","]",1,-1,1)  
  46. ubb=replace(ubb,"/"&chr(176),"/",1,-1,1)  
  47. ' ubb=replace(ubb,"{;em","{:em",1,-1,1)  
  48. end function  
  49.  
  50.  
  51. function Convert(ubb,CovT)  
  52. Dim cText,startubb,endubb,Lcovt,text,codetext  
  53. cText=ubb  
  54. startubb=1  
  55. do while Covt="url" or Covt="color" or Covt="font" or Covt="size"  
  56. startubb=instr(startubb,cText,"["&CovT&"=",1)  
  57. if startubb=0 then exit do  
  58. endubb=instr(startubb,cText,"]",1)  
  59. if endubb=0 then exit do  
  60. Lcovt=Covt  
  61. startubb=startubb+len(lCovT)+2  
  62. text=mid(cText,startubb,endubb-startubb)  
  63. codetext=replace(text,"[","["&chr(176),1,-1,1)  
  64. codetext=replace(codetext,"]",chr(176)&"]",1,-1,1)  
  65. 'codetext=replace(codetext,"{:em","{;em",1,-1,1)  
  66. codetext=replace(codetext,"/","/"&chr(176),1,-1,1)  
  67. select case CovT  
  68. case "color"  
  69. cText=replace(cText,"[color="&text&"]","<font color='"&text&"'>",1,1,1)  
  70. cText=replace(cText,"[/color]","</font>",1,1,1)  
  71. case "font"  
  72. cText=replace(cText,"[font="&text&"]","<font face='"&text&"'>",1,1,1)  
  73. cText=replace(cText,"[/font]","</font>",1,1,1)  
  74. case "size"  
  75. if IsNumeric(text) then  
  76. if text>6 then text=6  
  77. if text<1 then text=1  
  78. cText=replace(cText,"[size="&text&"]","<font size='"&text&"'>",1,1,1)  
  79. cText=replace(cText,"[/size]","</font>",1,1,1)  
  80. end if  
  81. case "url"  
  82. cText=replace(cText,"[url="&text&"]","<a href='"&codetext&"' target=_blank>",1,1,1)  
  83. cText=replace(cText,"[/url]","</a>",1,1,1)  
  84. case "email"  
  85. cText=replace(cText,"["&CovT&"="&text&"]","<a href=mailto:"&text&">",1,1,1)  
  86. cText=replace(cText,"[/"&CovT&"]","</a>",1,1,1)  
  87. end select  
  88. loop  
  89.  
  90. startubb=1  
  91. do  
  92. startubb=instr(startubb,cText,"["&CovT&"]",1)  
  93. if startubb=0 then exit do  
  94. endubb=instr(startubb,cText,"[/"&CovT&"]",1)  
  95. if endubb=0 then exit do  
  96. Lcovt=Covt  
  97. startubb=startubb+len(lCovT)+2  
  98. text=mid(cText,startubb,endubb-startubb)  
  99. codetext=replace(text,"[","["&chr(176),1,-1,1)  
  100. codetext=replace(codetext,"]",chr(176)&"]",1,-1,1)  
  101. 'codetext=replace(codetext,"{:em","{;em",1,-1,1)  
  102. codetext=replace(codetext,"/","/"&chr(176),1,-1,1)  
  103. select case CovT  
  104. case "url"  
  105. cText=replace(cText,"["&CovT&"]"&text,"<a href='"&codetext&"' target=_blank>"&codetext,1,1,1)  
  106. cText=replace(cText,"<a href='"&codetext&"' target=_blank>"&codetext&"[/"&CovT&"]","<a href="&codetext&" target=_blank>"&codetext&"</a>",1,1,1)  
  107. case "email"  
  108. cText=replace(cText,"["&CovT&"]","<a href=mailto:"&text&">",1,1,1)  
  109. cText=replace(cText,"[/"&CovT&"]","</a>",1,1,1)  
  110. case "html"  
  111. codetext=replace(codetext,"<br>",chr(13),1,-1,1)  
  112. codetext=replace(codetext," ",chr(32),1,-1,1)  
  113. Randomize  
  114. rid="temp"&Int(100000 * Rnd)  
  115. cText=replace(cText,"{html}"&text,"代码片断如下:<TEXTAREA id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext,1,1,1)  
  116. cText=replace(cText,"代码片断如下:<TEXTAREA id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext&"{/html}","代码片断如下:<TEXTAREA id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext&"</TEXTAREA><INPUT onclick=runEx('"&rid&"') type=button value=运行此段代码 name=Button1 class='Tips_bo'> <INPUT onclick=JM_cc('"&rid&"') type=button value=复制到我的剪贴板 name=Button2 class='Tips_bo'>",1,1,1)  
  117. case "img"  
  118. cText=replace(cText,"[img]"&text,"<a href="&chr(34)&"about:<img src="&codetext&" border=0>"&chr(34)&" target=_blank><img src="&codetext,1,1,1)  
  119. cText=replace(cText,"[/img]"," vspace=2 hspace=2 border=0 alt=::点击图片在新窗口中打开::></a>",1,1,1)  
  120. case "code"  
  121. cText=replace(cText,"[code]"&text,"以下内容为程序代码<hr noshade>"&codetext,1,1,1)  
  122. cText=replace(cText,"以下内容为程序代码<hr noshade>"&codetext&"[/code]","以下内容为程序代码<hr noshade>"&codetext&"<hr noshade>",1,1,1)  
  123. case "quote"  
  124. atext=replace(text,"[img]","",1,-1,1)  
  125. atext=replace(atext,"[/img]","",1,-1,1)  
  126. atext=replace(atext,"[swf]","",1,-1,1)  
  127. atext=replace(atext,"[/swf]","",1,-1,1)  
  128. atext=replace(atext,"{html}","",1,-1,1)  
  129. atext=replace(atext,"{/html}","",1,-1,1)  
  130. ' atext=replace(atext,"{:em","{;em",1,-1,1)  
  131. atext=SplitWords(atext,350)  
  132. atext=replace(atext,chr(32)," ",1,-1,1)  
  133. cText=replace(cText,"[quote]"&text,"<blockquote><hr noshade>"&atext,1,1,1)  
  134. cText=replace(cText,"<blockquote><hr noshade>"&atext&"[/quote]","<blockquote><hr noshade>"&atext&"<hr noshade></blockquote>",1,1,1)  
  135. case "swf"  
  136. cText=replace(cText,"[swf]"&text,"影片地址:<br>"&text&"<br><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='500' height='500'>",1,1,1)  
  137. cText=replace(cText,"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='500' height='500'>"&"[/swf]","<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='500' height='500'>"&"</embed></object>",1,1,1)  
  138. end select  
  139. loop  
  140. Convert=cText  
  141. end function  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表