ubbcode.asp
复制代码 代码如下:
<%
FunctionUBBCode(strContent)
IfisEmpty(strContent)OrisNull(strContent)Then
ExitFunction
Else
dimregex,strMatch
setregex=newRegExp
regex.IgnoreCase=True
regex.Global=True
regex.Pattern="[html]((rn)?([sS]+?))[/html]"
SetstrMatchs=regex.Execute(strContent)
ForEachstrMatchinstrMatchs
'response.writestrMatch.SubMatches(3)
Randomize
rndID="runcode"&Int(100000*Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><fontcolor=red>HTML代码:</font><TEXTAREAwidth:96%;height:300px;""id="""&rndID&"""class=""htmlarea"">"&UBBFilter(HTMLDecode(strMatch.SubMatches(2)))&"</TEXTAREA><br/><INPUTonclick=""runEx('"&rndID&"')""type=""button""value=""运行此代码""/><INPUTonclick=""doCopy("&rndID&")""type=""button""value=""复制此代码""/><INPUTonclick=""doSave("&rndID&")""type=""button""value=""保存代码""/><br/>[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]")
Next
SetstrMatchs=nothing
'去空行
regex.pattern="n[s]*r"
SetstrMatchs=regex.Execute(strContent)
ForEachstrMatchinstrMatchs
strContent=Replace(strContent,strMatch.Value,"")
Next
'代码块
regex.Pattern="[code]((rn)?([sS]+?))[/code]"
SetstrMatchs=regex.Execute(strContent)
ForEachstrMatchinstrMatchs
Randomize
rndID="code"&Int(100000*Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><divfloat:left""><fontcolor=green>CODE代码:</font></div><divfloat:right;text-align:right;"">[<ahref=""javascript:void(null)""onclick=""doCopy("&rndID&")"">复制此代码</a>]</div><br/><divclass=""codetextarea""id="""&rndID&""">"&strMatch.SubMatches(2)&"</div>")
Next
SetstrMatchs=nothing
'实现插入影音文件
regex.Pattern="[(swf|wma|wmv|rm|ra|qt)(=d*?|)(,d*?|)]([^<>]*?)[/(swf|wma|wmv|rm|ra|qt)]"
SetstrMatchs=regex.Execute(strContent)
dimstrType,strWidth,strHeight,strSRC,TitleText
ForEachstrMatchinstrMatchs
RAndomize
strType=strMatch.SubMatches(0)
ifstrType="swf"then
TitleText="<imgsrc=""../images/flash.gif""alt=""""margin:0px2px-3px0px""border=""0""/>Flash动画"
elseifstrType="wma"then
TitleText="<imgsrc=""../images/music.gif""alt=""""margin:0px2px-3px0px""border=""0""/>播放音频文件"
elseifstrType="wmv"then
TitleText="<imgsrc=""../images/mediaplayer.gif""alt=""""margin:0px2px-3px0px""border=""0""/>播放视频文件"
elseifstrType="rm"then
TitleText="<imgsrc=""../images/realplayer.gif""alt=""""margin:0px2px-3px0px""border=""0""/>播放real视频流文件"
elseifstrType="ra"then
TitleText="<imgsrc=""../images/realplayer.gif""alt=""""margin:0px2px-3px0px""border=""0""/>播放real音频流文件"
elseifstrType="qt"then
TitleText="<imgsrc=""../images/mediaplayer.gif""alt=""""margin:0px2px-3px0px""border=""0""/>播放mov视频文件"
endif
strWidth=strMatch.SubMatches(1)
strHeight=strMatch.SubMatches(2)
if(len(strWidth)=0)then
strWidth="400"
else
strWidth=right(strWidth,(len(strWidth)-1))
endif
if(len(strHeight)=0)then
strHeight="300"
else
strHeight=right(strHeight,(len(strHeight)-1))
endif
strSRC=strMatch.SubMatches(3)
rndID="temp"&Int(100000*Rnd)
strContent=Replace(strContent,strMatch.Value,"<divclass=""UBBPanel""><divclass=""UBBTitle"">"&TitleText&"</div><divclass=""UBBContent""><aid="""+rndID+"_href""href=""javascript:MediaShow('"+strType+"','"+rndID+"','"+strSRC+"','"+strWidth+"','"+strHeight+"')""><imgname="""+rndID+"_img""src=""../images/mm_snd.gif""margin:0px3px-2px0px""border=""0""alt=""""/><spanid="""+rndID+"_text"">在线播放</span></a><divid="""+rndID+"""></div></div></div>")
Next
SetstrMatchs=nothing
regex.Pattern="([mid])(.[^]]*)[/mid]"
strContent=regex.Replace(strContent,"<embedsrc=""$2""height=""45""width=""314""autostart=""0""></embed>")
regex.pattern="<br>([s||]*)?<br>"
strContent=regex.replace(strContent,"<br>")
strContent=replace(strContent,"&","&")
strContent=replace(strContent,"'","'")
strContent=replace(strContent,"","")'因为以前上传图片
setregex=nothing
endif
UBBCode=strContent
endfunction
%>
基本上来自pjhome