jb51用的ubb转换 原创
程序员文章站
2022-09-02 18:03:31
ubbcode.asp复制代码 代码如下:<% Function UBBCode(strContent) If isEmpty(strConten...
ubbcode.asp
<%
Function UBBCode(strContent)
If isEmpty(strContent) Or isNull(strContent) Then
Exit Function
Else
dim regex,strMatch
set regex=new RegExp
regex.IgnoreCase =True
regex.Global=True
regex.Pattern="\[html\]((\r\n)?([\s\S]+?))\[\/html\]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
'response.write strMatch.SubMatches(3)
Randomize
rndID="runcode"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><font color=red>HTML代码:</font><TEXTAREA style=""width:96%; height:300px;"" id="""&rndID&""" class=""htmlarea"">"&UBBFilter(HTMLDecode(strMatch.SubMatches(2)))& "</TEXTAREA><br/><INPUT onclick=""runEx('"&rndID&"')"" type=""button"" value=""运行此代码""/> <INPUT onclick=""doCopy("&rndID&")"" type=""button"" value=""复制此代码""/> <INPUT onclick=""doSave("&rndID&")"" type=""button"" value=""保存代码""/><br/> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]")
Next
Set strMatchs=nothing
'去空行
regex.pattern="\n[\s]*\r"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
strContent=Replace(strContent,strMatch.Value,"")
Next
'代码块
regex.Pattern="\[code\]((\r\n)?([\s\S]+?))\[\/code\]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
Randomize
rndID="code"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><div style=""float:left""><font color=green>CODE代码:</font></div><div style=""float:right;text-align:right;"">[<a href=""javascript:void(null)"" onclick=""doCopy("&rndID&")"">复制此代码</a>]</div><br/><div class=""codetextarea"" id="""&rndID&""">"&strMatch.SubMatches(2)&"</div>")
Next
Set strMatchs=nothing
'实现插入影音文件
regex.Pattern="\[(swf|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(swf|wma|wmv|rm|ra|qt)\]"
Set strMatchs=regex.Execute(strContent)
dim strType,strWidth,strHeight,strSRC,TitleText
For Each strMatch in strMatchs
RAndomize
strType=strMatch.SubMatches(0)
if strType="swf" then
TitleText="<img src=""../images/flash.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>Flash动画"
elseif strType="wma" then
TitleText="<img src=""../images/music.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放音频文件"
elseif strType="wmv" then
TitleText="<img src=""../images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放视频文件"
elseif strType="rm" then
TitleText="<img src=""../images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real视频流文件"
elseif strType="ra" then
TitleText="<img src=""../images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real音频流文件"
elseif strType="qt" then
TitleText="<img src=""../images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放mov视频文件"
end if
strWidth=strMatch.SubMatches(1)
strHeight=strMatch.SubMatches(2)
if (len(strWidth)=0) then
strWidth="400"
else
strWidth=right(strWidth,(len(strWidth)-1))
end if
if (len(strHeight)=0) then
strHeight="300"
else
strHeight=right(strHeight,(len(strHeight)-1))
end if
strSRC=strMatch.SubMatches(3)
rndID="temp"&Int(100000 * Rnd)
strContent= Replace(strContent,strMatch.Value,"<div class=""UBBPanel""><div class=""UBBTitle"">"&TitleText&"</div><div class=""UBBContent""><a id="""+rndID+"_href"" href=""javascript:MediaShow('"+strType+"','"+rndID+"','"+strSRC+"','"+strWidth+"','"+strHeight+"')""><img name="""+rndID+"_img"" src=""../images/mm_snd.gif"" style=""margin:0px 3px -2px 0px"" border=""0"" alt=""""/><span id="""+rndID+"_text"">在线播放</span></a><div id="""+rndID+"""></div></div></div>")
Next
Set strMatchs=nothing
regex.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
strContent= regex.Replace(strContent,"<embed src=""$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,"","") '因为以前上传图片
set regex=nothing
end if
UBBCode=strContent
end function
%>
基本上来自pjhome
复制代码 代码如下:
<%
Function UBBCode(strContent)
If isEmpty(strContent) Or isNull(strContent) Then
Exit Function
Else
dim regex,strMatch
set regex=new RegExp
regex.IgnoreCase =True
regex.Global=True
regex.Pattern="\[html\]((\r\n)?([\s\S]+?))\[\/html\]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
'response.write strMatch.SubMatches(3)
Randomize
rndID="runcode"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><font color=red>HTML代码:</font><TEXTAREA style=""width:96%; height:300px;"" id="""&rndID&""" class=""htmlarea"">"&UBBFilter(HTMLDecode(strMatch.SubMatches(2)))& "</TEXTAREA><br/><INPUT onclick=""runEx('"&rndID&"')"" type=""button"" value=""运行此代码""/> <INPUT onclick=""doCopy("&rndID&")"" type=""button"" value=""复制此代码""/> <INPUT onclick=""doSave("&rndID&")"" type=""button"" value=""保存代码""/><br/> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]")
Next
Set strMatchs=nothing
'去空行
regex.pattern="\n[\s]*\r"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
strContent=Replace(strContent,strMatch.Value,"")
Next
'代码块
regex.Pattern="\[code\]((\r\n)?([\s\S]+?))\[\/code\]"
Set strMatchs=regex.Execute(strContent)
For Each strMatch in strMatchs
Randomize
rndID="code"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"<br/><div style=""float:left""><font color=green>CODE代码:</font></div><div style=""float:right;text-align:right;"">[<a href=""javascript:void(null)"" onclick=""doCopy("&rndID&")"">复制此代码</a>]</div><br/><div class=""codetextarea"" id="""&rndID&""">"&strMatch.SubMatches(2)&"</div>")
Next
Set strMatchs=nothing
'实现插入影音文件
regex.Pattern="\[(swf|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(swf|wma|wmv|rm|ra|qt)\]"
Set strMatchs=regex.Execute(strContent)
dim strType,strWidth,strHeight,strSRC,TitleText
For Each strMatch in strMatchs
RAndomize
strType=strMatch.SubMatches(0)
if strType="swf" then
TitleText="<img src=""../images/flash.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>Flash动画"
elseif strType="wma" then
TitleText="<img src=""../images/music.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放音频文件"
elseif strType="wmv" then
TitleText="<img src=""../images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放视频文件"
elseif strType="rm" then
TitleText="<img src=""../images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real视频流文件"
elseif strType="ra" then
TitleText="<img src=""../images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real音频流文件"
elseif strType="qt" then
TitleText="<img src=""../images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放mov视频文件"
end if
strWidth=strMatch.SubMatches(1)
strHeight=strMatch.SubMatches(2)
if (len(strWidth)=0) then
strWidth="400"
else
strWidth=right(strWidth,(len(strWidth)-1))
end if
if (len(strHeight)=0) then
strHeight="300"
else
strHeight=right(strHeight,(len(strHeight)-1))
end if
strSRC=strMatch.SubMatches(3)
rndID="temp"&Int(100000 * Rnd)
strContent= Replace(strContent,strMatch.Value,"<div class=""UBBPanel""><div class=""UBBTitle"">"&TitleText&"</div><div class=""UBBContent""><a id="""+rndID+"_href"" href=""javascript:MediaShow('"+strType+"','"+rndID+"','"+strSRC+"','"+strWidth+"','"+strHeight+"')""><img name="""+rndID+"_img"" src=""../images/mm_snd.gif"" style=""margin:0px 3px -2px 0px"" border=""0"" alt=""""/><span id="""+rndID+"_text"">在线播放</span></a><div id="""+rndID+"""></div></div></div>")
Next
Set strMatchs=nothing
regex.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
strContent= regex.Replace(strContent,"<embed src=""$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,"","") '因为以前上传图片
set regex=nothing
end if
UBBCode=strContent
end function
%>
基本上来自pjhome
上一篇: vue项目常用插件
下一篇: 关于Camera补帧处理
推荐阅读
-
剑指offer11:输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。(进制转换,补码反码)
-
SEO经验之谈:用原创文章提升转化率的几个要点介绍
-
用C#把文件转换为XML的代码
-
常用到用css3实现的转换,过渡和动画
-
发一个php简单的伪原创程序,配合商城采集用的
-
用Excel 数据透视表的多表合并功能轻易完成表格转换
-
如何将含有图片的PPT转换成Word用Word格式查看
-
用Python实现换行符转换的脚本的教程
-
强烈推荐,超详细,实操零失误:node.js安装 + npm安装教程 + Vue开发环境搭建 【非原创,但是用生命推荐的转载】
-
用jQuery将JavaScript对象转换为querystring查询字符串的方法