[VB]ASPX中如何调用(或修改)ASP中ubbcode这段函数?
我在 <srcipt runat=server> 加入下列代码
Function UBBCode(strContent as string) as string
If isnothing(strContent) Or isdbNull(strContent) Then
Exit Function
Else
strContent=Replace(strContent, "[#seperator#] ", " ")
Dim re, strMatches, strMatch, tmpStr1, tmpStr2, tmpStr3, tmpStr4, RNDStr
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern= "\[code\]( <br> )+ "
strContent=re.Replace(strContent, "[code] ")
re.Pattern= "\[quote\]( <br> )+ "
strContent=re.Replace(strContent, "[quote] ")
re.Pattern= "([^=\]][\s]*?|^)(https?|ftp|gopher|news|telnet|mms|rtsp)://([a-z0-9/\-_+=.~!%@?#%&;:$\\()|]+) "
StrContent=re.Replace(StrContent, "$1[url]$2://$3[/url] ")
re.Pattern= "\[img\](.*?)\[\/img\] "
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=CheckLinkStr(strMatch.SubMatches(0))
strContent=Replace(strContent,strMatch.Value, " <img src= " " "&tmpStr1& " " " border= " "0 " " onload= " "javascript:DrawImage(this); " " alt= " "按此在新窗口打开图片 " " onmouseover= " "this.style.cursor= 'hand '; " " onclick= " "window.open(this.src); " " /> ")
Next
Set strMatches=Nothing
re.Pattern= "\[img=(left|right|center|absmiddle)\](.*?)\[\/img\] "
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=strMatch.SubMatches(0)
tmpStr2=CheckLinkStr(strMatch.SubMatches(1))
strContent=Replace(strContent,strMatch.Value, " <img src= " " "&tmpStr2& " " " align= " " "&tmpStr1& " " " onload= " "javascript:DrawImage(this); " " border= " "0 " " alt= " "按此在新窗口打开图片 " " onmouseover= " "this.style.cursor= 'hand '; " " onclick= " "window.open(this.src); " " /> ")
Next
strContent=replace(strContent, "[swf] ", "[swf=550,400] ")
re.Pattern= "\[(swf)=(\d*?|),(\d*?|)\](.*?)\[\/(swf)\] "
Set strMatches=re.Execute(strContent)
For Each strMatch in strMatches
RNDStr=Int(7999 * Rnd + 2000)
tmpStr1=CheckLinkStr(strMatch.SubMatches(3))
strContent= Replace(strContent,strMatch.Value, " <table border= '0 ' cellpadding= '4 ' cellspacing= '1 ' style= 'background: #FFF;color: #666666;margin: 10px;padding: 10px;border: 1px dashed #CCC; '> <tr> <td> <input id= " "VOBJ_ "&RNDStr& " " " type= " "hidden " " value= " "-1 " " /> <a href= " "javascript:UBBShowObj( ' "&strMatch.SubMatches(0)& " ', 'OBJ_ "&RNDStr& " ', ' "&strMatch.SubMatches(3)& " ', ' "&strMatch.SubMatches(1)& " ', ' "&strMatch.SubMatches(2)& " '); " "> <img src= " "/blog/images/icon_flash.gif " " alt= " "显示Flash文件 " " align= " "absmiddle " " border= " "0 " " /> 点击显示/隐藏Flash文件 </a> <div id= " "OBJ_ "&RNDStr& " " "> </div> </td> </tr> </table> ")