ubb.asp
资源名称:1.rar [点击查看]
上传用户:ziqing_518
上传日期:2022-08-09
资源大小:446k
文件大小:11k
源码类别:

多媒体编程

开发平台:

ASP/ASPX

  1. <%
  2. rem ------------ubb代码
  3. function ChkBadWords(fString)
  4.     bwords = split(BadWords, "|")
  5.     for i = 0 to ubound(bwords)
  6.         fString = Replace(fString, bwords(i), string(len(bwords(i)),"*")) 
  7.     next
  8.     ChkBadWords = fString
  9. end function
  10. function doCode(fString, fOTag, fCTag, fROTag, fRCTag)
  11.     fOTagPos = Instr(1, fString, fOTag, 1)
  12.     fCTagPos = Instr(1, fString, fCTag, 1)
  13.     while (fCTagPos > 0 and fOTagPos > 0)
  14.         fString = replace(fString, fOTag, fROTag, 1, 1, 1)
  15.         fString = replace(fString, fCTag, fRCTag, 1, 1, 1)
  16.         fOTagPos = Instr(1, fString, fOTag, 1)
  17.         fCTagPos = Instr(1, fString, fCTag, 1)
  18.     wend
  19.     doCode = fString
  20. end function
  21. function HTMLEncode(fString)
  22.     fString = replace(fString, ">", "&gt;")
  23.     fString = replace(fString, "<", "&lt;")
  24.     fString = Replace(fString, CHR(13), "")
  25.     fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
  26.     fString = Replace(fString, CHR(10), "<BR>")
  27.     HTMLEncode = fString
  28. end function
  29. function HTMLDecode(fString)
  30.     fString = replace(fString, "&gt;", ">")
  31.     fString = replace(fString, "&lt;", "<")
  32.     fString = Replace(fString, "", CHR(13))
  33.     fString = Replace(fString, "</P><P>", CHR(10) & CHR(10))
  34.     fString = Replace(fString, "<BR>", CHR(10))
  35.     HTMLDecode = fString
  36. end function
  37. function HTMLDecode1(fString)
  38.     fString = replace(fString, "&gt;", ">")
  39.     fString = replace(fString, "&lt;", "<")
  40.     fString = Replace(fString, "", CHR(13))
  41.     fString = Replace(fString, "</P><P>", CHR(10) & CHR(10))
  42.     fString = Replace(fString, "<BR>", CHR(10))
  43.     HTMLDecode1 = fString
  44. end function
  45. function UBBCode(strContent)
  46.     if strAllowHTML <> 1 then
  47.         strContent = HTMLEncode(strContent)
  48.     end if
  49.     dim re
  50.     Set re=new RegExp
  51.     re.IgnoreCase =true
  52.     re.Global=True
  53. if boolSoftimg_1=true then
  54. re.Pattern="([IMG])(.[^]]*)([/IMG])"
  55. strContent=re.Replace(strContent,"<IMG SRC=""$2"" border=0>")
  56. end if
  57.     re.Pattern="[DIR=*([0-9]*),*([0-9]*)](.[^]]*)[/DIR]"
  58.     strContent=re.Replace(strContent,"<object classid=clsid:166B1BCA-3F9C-11CF-8075-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0 width=$1 height=$2><param name=src value=$3><embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed></object>")
  59.     re.Pattern="[QT=*([0-9]*),*([0-9]*)](.[^]]*)[/QT]"
  60.     strContent=re.Replace(strContent,"<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=TOFIT bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")
  61. if boolSoftmedia_1=true then
  62. re.Pattern="[MP=*([0-9]*),*([0-9]*)](.[^]]*)[/MP]"
  63. strContent=re.Replace(strContent,"<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=$1 height=$2 ><param name=ShowStatusBar value=-1><param name=Filename value=$3><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=$3  width=$1 height=$2></embed></object>")
  64. end if
  65. if boolSoftreal_1=true then
  66.   re.Pattern="[RM=*([0-9]*),*([0-9]*)](.[^]]*)[/RM]"
  67.   strContent=re.Replace(strContent,"<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=$1 height=$2><PARAM NAME=SRC VALUE=$3><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=true></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=$1><PARAM NAME=SRC VALUE=$3><PARAM NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT>")
  68. end if
  69. if boolSoftflash_1=true then
  70. re.Pattern="([FLASH])(.[^]]*)([/FLASH])"
  71. strContent= re.Replace(strContent,"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400><PARAM NAME=movie VALUE=""$2""><PARAM NAME=quality VALUE=high><embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400>$2</embed></OBJECT>")
  72. end if
  73.     re.Pattern="([URL])(http://.[^]]*)([/URL])"
  74.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><A HREF=""$2"" TARGET=_blank>$2</A>")
  75.     re.Pattern="([URL])(.[^]]*)([/URL])"
  76.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><A HREF=""http://$2"" TARGET=_blank>$2</A>")
  77.     re.Pattern="([URL=(http://.[^]]*)])(.[^]]*)([/URL])"
  78.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><A HREF=""$2"" TARGET=_blank>$3</A>")
  79.     re.Pattern="([URL=(.[^]]*)])(.[^]]*)([/URL])"
  80.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><A HREF=""http://$2"" TARGET=_blank>$3</A>")
  81.     re.Pattern="([EMAIL])(.[^]]*)([/EMAIL])"
  82.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/email1.gif><A HREF=""mailto:$2"">$2</A>")
  83.     re.Pattern="([EMAIL=(.[^]]*)])(.[^]]*)([/EMAIL])"
  84.     strContent= re.Replace(strContent,"<img align=absmiddle src=./images/email1.gif><A HREF=""mailto:$2"" TARGET=_blank>$3</A>")
  85. re.Pattern = "^(http://[A-Za-z0-9./=?%-&_~`@']+)"
  86. strContent = re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><a target=_blank href=$1>$1</a>")
  87. re.Pattern = "(http://[A-Za-z0-9./=?%-&_~`@']+)$"
  88. strContent = re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><a target=_blank href=$1>$1</a>")
  89. re.Pattern = "[^>=""](http://[A-Za-z0-9./=?%-&_~`@']+)"
  90. strContent = re.Replace(strContent,"<img align=absmiddle src=./images/url.gif><a target=_blank href=$1>$1</a>")
  91.     re.Pattern="([em(.[^]]*)])"
  92.     strContent=re.Replace(strContent,"<img src=./images/em$2.gif border=0 align=absmiddle>")
  93.     re.Pattern="([HTML])(.[^]]*)([/HTML])"
  94.     strContent=re.Replace(strContent,"<table width='100%' border='0' cellspacing='0' cellpadding='6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
  95.     re.Pattern="([code])(.[^]]*)([/code])"
  96.     strContent=re.Replace(strContent,"<table width='100%' border='0' cellspacing='0' cellpadding='6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
  97.     re.Pattern="([QUOTE])(.[^]]*)([/QUOTE])"
  98.     strContent=re.Replace(strContent,"<BLOCKQUOTE><BLOCKQUOTE><table width='100%' border='0' cellspacing='0' cellpadding='6'><td>$2</td></table></BLOCKQUOTE></BLOCKQUOTE><br>")
  99.     re.Pattern="([fly])(.*)([/fly])"
  100.     strContent=re.Replace(strContent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
  101.     re.Pattern="([move])(.*)([/move])"
  102.     strContent=re.Replace(strContent,"<MARQUEE scrollamount=3>$2</marquee>")
  103.     re.Pattern="[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.[^]]*)[/GLOW]"
  104.     strContent=re.Replace(strContent,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
  105.     re.Pattern="[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.[^]]*)[/SHADOW]"
  106.     strContent=re.Replace(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
  107. '--------------------------------------------------
  108.     strContent = doCode(strContent, "[list]", "[/list]", "<ul>", "</ul>")
  109.     strContent = doCode(strContent, "[list=1]", "[/list]", "<ol type=1>", "</ol id=1>")
  110.     strContent = doCode(strContent, "[list=a]", "[/list]", "<ol type=a>", "</ol id=a>")
  111.     strContent = doCode(strContent, "[*]", "[/*]", "<li>", "</li>")
  112. '--------------------------------------------------
  113.     re.Pattern="([face=(.[^]]*)])(.*)([/face])"
  114.     strContent=re.Replace(strContent,"<font face=$2>$3</font>")
  115.     re.Pattern="([i])(.[^]]*)([/i])"
  116.     strContent=re.Replace(strContent,"<i>$2</i>")
  117.     re.Pattern="([u])(.[^]]*)([/u])"
  118.     strContent=re.Replace(strContent,"<u>$2</u>")
  119.     re.Pattern="([b])(.[^]]*)([/b])"
  120.     strContent=re.Replace(strContent,"<b>$2</b>")
  121.     re.Pattern="[align=(.[^]]*)](.*)[/align]"
  122.     strContent=re.Replace(strContent,"<div align=$1>$2</div>")
  123.     re.Pattern="[color=(.[^]]*)](.[^[]*)[/color]"
  124.     strContent=re.Replace(strContent,"<font color=$1>$2</font>")
  125. if boolSoftsize_1=true then
  126. re.Pattern="([size=1])(.[^[]*)([/size])"
  127. strContent=re.Replace(strContent,"<font size=1>$2</font>")
  128. re.Pattern="([size=2])(.[^[]*)([/size])"
  129. strContent=re.Replace(strContent,"<font size=2>$2</font>")
  130. re.Pattern="([size=3])(.[^[]*)([/size])"
  131. strContent=re.Replace(strContent,"<font size=3>$2</font>")
  132. re.Pattern="([size=4])(.[^[]*)([/size])"
  133. strContent=re.Replace(strContent,"<font size=4>$2</font>")
  134. re.Pattern="([size=5])(.[^[]*)([/size])"
  135. strContent=re.Replace(strContent,"<font size=5>$2</font>")
  136. re.Pattern="([size=6])(.[^[]*)([/size])"
  137. strContent=re.Replace(strContent,"<font size=6>$2</font>")
  138. re.Pattern="([size=7])(.[^[]*)([/size])"
  139. strContent=re.Replace(strContent,"<font size=7>$2</font>")
  140. end if
  141.     strContent=ChkBadWords(strContent)
  142.     set re=Nothing
  143.     UBBCode=strContent
  144. end function
  145. public function translate(sourceStr,fieldStr)
  146. rem 处理逻辑表达式的转化问题
  147.   dim  sourceList
  148.   dim resultStr
  149.   dim i,j
  150.   if instr(sourceStr," ")>0 then 
  151.      dim isOperator
  152.      isOperator = true
  153.      sourceList=split(sourceStr)
  154.      '--------------------------------------------------------
  155.      rem Response.Write "num:" & cstr(ubound(sourceList)) & "<br>"
  156.      for i = 0 to ubound(sourceList)
  157.         rem Response.Write i 
  158.     Select Case ucase(sourceList(i))
  159.     Case "AND","&","和","与"
  160.         resultStr=resultStr & " and "
  161.         isOperator = true
  162.     Case "OR","|","或"
  163.         resultStr=resultStr & " or "
  164.         isOperator = true
  165.     Case "NOT","!","非","!","!"
  166.         resultStr=resultStr & " not "
  167.         isOperator = true
  168.     Case "(","(","("
  169.         resultStr=resultStr & " ( "
  170.         isOperator = true
  171.     Case ")",")",")"
  172.         resultStr=resultStr & " ) "
  173.         isOperator = true
  174.     Case Else
  175.         if sourceList(i)<>"" then
  176.             if not isOperator then resultStr=resultStr & " and "
  177.             if inStr(sourceList(i),"%") > 0 then
  178.                 resultStr=resultStr&" "&fieldStr& " like '" & replace(sourceList(i),"'","''") & "' "
  179.             else
  180.                 resultStr=resultStr&" "&fieldStr& " like '%" & replace(sourceList(i),"'","''") & "%' "
  181.             end if
  182.                 isOperator=false
  183.         End if    
  184.     End Select
  185.         rem Response.write resultStr+"<br>"
  186.      next 
  187.      translate=resultStr
  188.   else '单条件
  189.      if inStr(sourcestr,"%") > 0 then
  190.          translate=" " & fieldStr & " like '" & replace(sourceStr,"'","''") &"' "
  191.      else
  192.     translate=" " & fieldStr & " like '%" & replace(sourceStr,"'","''") &"%' "
  193.      End if
  194.      rem 前后各加一个空格,免得连sql时忘了加,而出错。
  195.   end if  
  196. end function
  197. %>