pjblog的ubbcodeasp文件

2016-02-19 13:57 3 1 收藏

下面图老师小编要跟大家分享pjblog的ubbcodeasp文件,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!

【 tulaoshi.com - Web开发 】

代码如下:


%
'===========PBlog2 UBB代码转换代码==========
' Author:PuterJam
' Copryright PBlog2
' Update: 2005-12-29
'===========================================
Function UBBCode(ByVal strContent,DisSM,DisUBB,DisIMG,AutoURL,AutoKEY)
If isEmpty(strContent) Or isNull(strContent) Then
Exit Function
Else
Dim re, strMatchs, strMatch, rndID,tmpStr1,tmpStr2,tmpStr3,tmpStr4
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
IF AutoURL=1 Then
re.Pattern="([^=]][s]*?|^)(http|https|rstp|ftp|mms|ed2k)://([A-Za-z0-9./=?%-_~`@':+!]*)"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=strMatch.SubMatches(1)
tmpStr3=checkURL(strMatch.SubMatches(2))
strContent=replace(strContent,strMatch.Value,tmpStr1&"a href="""&tmpStr2&"://"&tmpStr3&""" target=""_blank"""&tmpStr2&"://"&tmpStr3&"/a",1,-1,0)
Next
're.Pattern="(^|s)(www.S+)"
'strContent=re.Replace(strContent,"$1a href=""http://$2"" target=""_blank""$2/a")
End IF

IF Not DisUBB=1 Then
IF Not DisIMG=1 Then
re.Pattern="([img])(.[^]]*)[/img]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=(strMatch.SubMatches(1))
strContent=replace(strContent,strMatch.Value,"img src="""&tmpStr1&""" border=""0"" alt=""""/",1,-1,0)
Next

re.Pattern="[img=(left|right|center|absmiddle|)](.[^]]*)([/img])"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=checkURL(strMatch.SubMatches(1))
strContent=replace(strContent,strMatch.Value,"img align="""&tmpStr1&""" src="""&tmpStr2&""" border=""0"" alt=""""/",1,-1,0)
Next

re.Pattern="[img=(d*|),(d*|)](.[^]]*)[/img]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=strMatch.SubMatches(1)
tmpStr3=checkURL(strMatch.SubMatches(2))
strContent=replace(strContent,strMatch.Value,"img width="""&tmpStr1&""" height="""&tmpStr2&""" src="""&tmpStr3&""" border=""0"" alt=""""/",1,-1,0)
Next

re.Pattern="[img=(d*|),(d*|),(left|right|center|absmiddle|)](.[^]]*)([/img])"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=strMatch.SubMatches(1)
tmpStr3=strMatch.SubMatches(2)
tmpStr4=checkURL(strMatch.SubMatches(3))
strContent=replace(strContent,strMatch.Value,"img width="""&tmpStr1&""" height="""&tmpStr2&""" align="""&tmpStr3&""" src="""&tmpStr4&""" border=""0"" alt=""""/",1,-1,0)
Next
else
re.Pattern="([img])(.[^]]*)[/img]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(1))
strContent=replace(strContent,strMatch.Value,"a href="""&tmpStr1&""" target=""_blank"" title="""&tmpStr1&"""img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/查看图片/a",1,-1,0)
Next

re.Pattern="[img=(left|right|center|absmiddle|)](.[^]]*)([/img])"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=checkURL(strMatch.SubMatches(1))
strContent=replace(strContent,strMatch.Value,"a href="""&tmpStr2&""" target=""_blank"" title="""&tmpStr2&"""img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/查看图片/a",1,-1,0)
Next

re.Pattern="[img=(d*|),(d*|)](.[^]]*)[/img]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=strMatch.SubMatches(1)
tmpStr3=checkURL(strMatch.SubMatches(2))
strContent=replace(strContent,strMatch.Value,"a href="""&tmpStr3&""" target=""_blank"" title="""&tmpStr3&"""img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/查看图片/a",1,-1,0)
Next

re.Pattern="[img=(d*|),(d*|),(left|right|center|absmiddle|)](.[^]]*)([/img])"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=strMatch.SubMatches(0)
tmpStr2=strMatch.SubMatches(1)
tmpStr3=strMatch.SubMatches(2)
tmpStr4=checkURL(strMatch.SubMatches(3))
strContent=replace(strContent,strMatch.Value,"a href="""&tmpStr4&""" target=""_blank"" title="""&tmpStr4&"""img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/查看图片/a",1,-1,0)
Next
End IF

'-----------多媒体标签----------------
re.Pattern="[(swf|wma|wmv|rm|ra|qt)(=d*?|)(,d*?|)]([^]*?)[/(swf|wma|wmv|rm|ra|qt)]"
Set strMatchs=re.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=checkURL(strMatch.SubMatches(3))
rndID="temp"&Int(100000 * Rnd)
strContent= Replace(strContent,strMatch.Value,"div class=""UBBPanel""div class=""UBBTitle"""&TitleText&"/divdiv 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/adiv id="""+rndID+"""/div/div/div")
Next
Set strMatchs=nothing
re.Pattern="([mid])(.[^]]*)[/mid]"
strContent= re.Replace(strContent,"embed src=""$2"" height=""45"" width=""314"" autostart=""0""/embed")
'-----------常规标签----------------
re.Pattern = "[url=(.[^]]*)](.[^[]*)[/url]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
tmpStr2=strMatch.SubMatches(1)
strContent=replace(strContent,strMatch.Value,"a target=""_blank"" href="""&tmpStr1&""""&tmpStr2&"/a",1,-1,0)
Next

re.Pattern = "[url](.[^[]*)[/url]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
strContent=replace(strContent,strMatch.Value,"a target=""_blank"" href="""&tmpStr1&""""&tmpStr1&"/a",1,-1,0)
Next

re.Pattern = "[ed2k=([^r]*?)]([^r]*?)[/ed2k]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
tmpStr2=strMatch.SubMatches(1)
strContent=replace(strContent,strMatch.Value,"img border="""" src=""images/ed2k.gif"" alt=""""/a target=""_blank"" href="""&tmpStr1&""""&tmpStr2&"/a",1,-1,0)
Next

re.Pattern = "[ed2k]([^r]*?)[/ed2k]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
strContent=replace(strContent,strMatch.Value,"img border="""" src=""images/ed2k.gif"" alt=""""/a target=""_blank"" href="""&tmpStr1&""""&tmpStr1&"/a",1,-1,0)
Next

re.Pattern = "[email=(.[^]]*)](.[^[]*)[/email]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
tmpStr2=strMatch.SubMatches(1)
strContent=replace(strContent,strMatch.Value,"a href=""mailto:"&tmpStr1&""""&tmpStr2&"/a",1,-1,0)
Next


re.Pattern = "[email](.[^[]*)[/email]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
strContent=replace(strContent,strMatch.Value,"a href=""mailto:"&tmpStr1&""""&tmpStr1&"/a",1,-1,0)
Next

'-----------字体格式----------------
re.Pattern="[align=(w{4,6})]([^r]*?)[/align]"
strContent=re.Replace(strContent,"div align=""$1""$2/div")
re.Pattern="[color=(#w{3,10}|w{3,10})]([^r]*?)[/color]"
strContent=re.Replace(strContent,"span style=""color:$1""$2/span")
re.Pattern="[size=(d{1,2})]([^r]*?)[/size]"
strContent=re.Replace(strContent,"span style=""font-size:$1pt""$2/span")
re.Pattern="[font=([^r]*?)]([^r]*?)[/font]"
strContent=re.Replace(strContent,"span style=""font-family:$1""$2/span")
re.Pattern="[b]([^r]*?)[/b]"
strContent=re.Replace(strContent,"strong$1/strong")
re.Pattern="[i]([^r]*?)[/i]"
strContent=re.Replace(strContent,"i$1/i")
re.Pattern="[u]([^r]*?)[/u]"
strContent=re.Replace(strContent,"u$1/u")
re.Pattern="[s]([^r]*?)[/s]"
strContent=re.Replace(strContent,"s$1/s")
re.Pattern="[sup]([^r]*?)[/sup]"
strContent=re.Replace(strContent,"sup$1/sup")
re.Pattern="[sub]([^r]*?)[/sub]"
strContent=re.Replace(strContent,"sub$1/sub")
re.Pattern="[fly]([^r]*?)[/fly]"
strContent=re.Replace(strContent,"marquee width=""90%"" behavior=""alternate"" scrollamount=""3""$1/marquee")

End IF

'-----------特殊标签----------------
re.Pattern = "[down=(.[^]]*)](.[^[]*)[/down]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
tmpStr2=strMatch.SubMatches(1)
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/ a href="""&tmpStr1&""" target=""_blank"""&tmpStr2&"/a",1,-1,0)
Next

re.Pattern = "[down](.[^[]*)[/down]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/ a href="""&tmpStr1&""" target=""_blank""下载此文件/a",1,-1,0)
Next

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

re.Pattern = "[mDown=(.[^]]*)](.[^[]*)[/mDown]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
tmpStr2=strMatch.SubMatches(1)
if len(memName)0 then
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/ a href="""&tmpStr1&""" target=""_blank"""&tmpStr2&"/a",1,-1,0)
else
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""只允许会员下载"" style=""margin:0px 2px -4px 0px""/ 该文件只允许会员下载! a href=""login.asp""登录/a | a href=""register.asp""注册/a",1,-1,0)
end if
Next

re.Pattern = "[mDown](.[^[]*)[/mDown]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
tmpStr1=checkURL(strMatch.SubMatches(0))
if len(memName)0 then
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/ a href="""&tmpStr1&""" target=""_blank""下载此文件/a",1,-1,0)
else
strContent=replace(strContent,strMatch.Value,"img src=""images/download.gif"" alt=""只允许会员下载"" style=""margin:0px 2px -4px 0px""/ 该文件只允许会员下载! a href=""login.asp""登录/a | a href=""register.asp""注册/a",1,-1,0)
end if
Next


re.Pattern="[code](.*?)[/code]"
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/code.gif"" style=""margin:0px 2px -3px 0px"" alt=""程序代码""/ 程序代码/divdiv class=""UBBContent""$1/div/div")

re.Pattern="[quote](.*?)[/quote]"
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""引用内容""/ 引用内容/divdiv class=""UBBContent""$1/div/div")
re.Pattern="[quote=(.[^]]*)](.*?)[/quote]"
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""引用来自 $1""/ 引用来自 $1/divdiv class=""UBBContent""$2/div/div")

re.Pattern="[hidden](.*?)[/hidden]"
if len(memName)0 then
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""显示被隐藏内容""/ 显示被隐藏内容/divdiv class=""UBBContent""$1/div/div")
else
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""隐藏内容""/ 隐藏内容/divdiv class=""UBBContent""该内容已经被作者隐藏,只有会员才允许查阅 a href=""login.asp""登录/a | a href=""register.asp""注册/a/div/div")
end if

re.Pattern="[hidden=(.[^]]*)](.*?)[/hidden]"
if len(memName)0 then
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""显示被隐藏内容 $1""/ 显示被隐藏内容来自 $1/divdiv class=""UBBContent""$2/div/div")
else
strContent= re.Replace(strContent,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""隐藏内容 $1""/ 隐藏内容/divdiv class=""UBBContent""该内容已经被作者隐藏,只有会员才允许查阅 a href=""login.asp""登录/a | a href=""register.asp""注册/a/div/div")
end if

re.Pattern="[html](.*?)[/html]"
Set strMatchs=re.Execute(strContent)
For Each strMatch in strMatchs
RAndomize
rndID="temp"&Int(100000 * Rnd)
strContent=Replace(strContent,strMatch.Value,"div class=""UBBPanel""div class=""UBBTitle""img src=""images/html.gif"" style=""margin:0px 2px -3px 0px"" HTML代码/divdiv class=""UBBContent""TEXTAREA rows=""8"" id="""&rndID&""""&UBBFilter(HTMLDecode(strMatch.SubMatches(0)))& "/TEXTAREAbr/INPUT onclick=""runEx('"&rndID&"')"" type=""button"" value=""运行此代码""/ INPUT onclick=""doCopy('"&rndID&"')"" type=""button"" value=""复制此代码""/br/ [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]/div/div",1,-1,0)
Next
Set strMatchs=nothing
'-----------List标签----------------
strContent = Replace(strContent,"[list]","ul")
re.Pattern = "[list=(.[^]]*)]"
strContent = re.Replace(strContent,"ul style=""list-style-type:$1""")
re.Pattern = "[*](.[^[]*)(n|)"
strContent = re.Replace(strContent,"li$1/li")
strContent = Replace(strContent,"[/list]","/ul")

'-----------表情图标----------------
IF Not DisSM=1 Then
dim log_Smilies,log_SmiliesContent
For Each log_Smilies IN Arr_Smilies
log_SmiliesContent=Split(log_Smilies,"|")
strContent=Replace(strContent,log_SmiliesContent(2)," img src=""images/smilies/"&log_SmiliesContent(1)&""" border=""0"" style=""margin:0px 0px -2px 0px"" alt=""""/")
Next
End IF

'-----------关键词识别----------------
IF AutoKEY=1 Then
dim log_Keywords,log_KeywordsContent
For Each log_Keywords IN Arr_Keywords
log_KeywordsContent=Split(log_Keywords,"$|$")
IF log_KeywordsContent(3)"None" Then
strContent=Replace(strContent,log_KeywordsContent(1),"a href="""&log_KeywordsContent(2)&""" target=""_blank""img src=""images/keywords/"&log_KeywordsContent(3)&""" border=""0"" alt=""""/ "&log_KeywordsContent(1)&"/a")
Else
strContent=Replace(strContent,log_KeywordsContent(1),"a href="""&log_KeywordsContent(2)&""" target=""_blank"""&log_KeywordsContent(1)&"/a")
End IF
Next
End IF

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

Set re=Nothing

UBBCode=strContent
End IF
End Function
%

来源:https://www.tulaoshi.com/n/20160219/1605796.html

延伸阅读
VB提供的方法使我们可以很容易地使用资源文件中的字符、图片等资源。我们可以用以下方法播放资源文件中的wav声音:首先,在你的资源文件的源文件(RC)文件加入下面一行: MySoundWAVEc:musicvanhalen.wav 然后将其编译为RES文件。最后使用下面的声明及代码: PrivateDeclareFunctionPlaySoundLib_"winmm.dll"Alias"PlaySoundA"(...
下面我已程序代码做成模块,只要导入必要之参数即可! 此一模块共有四个参数: 1、sSheetName:要导出资料的文件名称(Sheetname),例如Sheet1 2、sExcelPath:要导出资料的Excel档案路径名称(Workbookpath),例如C:ook1.xls 3、sAccessTable:要导入的AccessTable名称,例如TestTable 4、sAccessDBPath:要导入的Acce...
标签: Web开发
代码如下: public void exportHibernteToSQL(){ Configuration cfg=new Configuration().configure("/hibernate.cfg.xml"); SchemaExport schemaExport = new SchemaExport(cfg); schemaExport.setOutputFile("d:/mysql_sql.sql"); schemaExport.create(true, false); } 注意:Hibernate的配置文件是什么数据库方言和驱动,将生成什么数...
标签: 电脑入门
cue文件是什么文件?其实cue文件是一种索引文件。是指关盘镜像文件或者标记文件,按照文本文件格式编制。在刻录关盘映像文件的时候能提高刻录效率的作用。可以直接用记事本上打开它。你仔细查看通常下载cue文件的时候一般会有bin文件,这两个文件是一起出现的,当你在下载游戏软件或者视频的时候,这个时候下载到的cue文件是专门用来加载bin文件...
标签: 电脑入门
在日常使用电脑的过程中,每个人都可能遇到过误删除数据、误格式化硬盘分区等比较麻烦的情况,甚至还可能出现误删除硬盘分区的情况。那么一旦出现这些情况之后,该如何恢复那些误删除的数据呢? 如何在Windows中恢复数据? 如果用户只是在操作时误删除了一些文件,例如Word文件、文本文件等等,或者只是误格式化了非系统分区,而Windows还运行...

经验教程

533

收藏

94
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部