欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp的ubb函数(推荐)

程序员文章站 2022-09-08 19:01:17
复制代码 代码如下: function unhtml(content) unhtml=content if content <> "" then un...
复制代码 代码如下:

 function unhtml(content)
unhtml=content
if content <> "" then
unhtml=replace(unhtml,"&","&")
unhtml=replace(unhtml,"<","<")
unhtml=replace(unhtml,">",">")
unhtml=replace(unhtml,chr(34),""")
unhtml=replace(unhtml,chr(13),"<br>")
unhtml=replace(unhtml,chr(32)," ")
'unhtml=ubb(unhtml)
end if
end function

function ubb(content)
dim nowtime,i
ubb=content
nowtime=now()
ubb=convert(ubb,"code")
ubb=convert(ubb,"html")
ubb=convert(ubb,"url")
ubb=convert(ubb,"color")
ubb=convert(ubb,"font")
ubb=convert(ubb,"size")
ubb=convert(ubb,"quote")
ubb=convert(ubb,"email")
ubb=convert(ubb,"img")
ubb=convert(ubb,"swf")

ubb=autourl(ubb)
ubb=replace(ubb,"[b]","<b>",1,-1,1)
ubb=replace(ubb,"[/b]","</b>",1,-1,1)
ubb=replace(ubb,"[i]","<i>",1,-1,1)
ubb=replace(ubb,"[/i]","</i>",1,-1,1)
ubb=replace(ubb,"[u]","<u>",1,-1,1)
ubb=replace(ubb,"[/u]","</u>",1,-1,1)
ubb=replace(ubb,"[blue]","<font color='#000099'>",1,-1,1)
ubb=replace(ubb,"[/blue]","</font>",1,-1,1)
ubb=replace(ubb,"[red]","<font color='#990000'>",1,-1,1)
ubb=replace(ubb,"[/red]","</font>",1,-1,1)
for i=1 to 28
ubb=replace(ubb,"{:em"&i&"}","<img src=emot/emotface/em"&i&".gif></img>",1,6,1)
ubb=replace(ubb,"{:em"&i&"}","",1,-1,1)
next
ubb=replace(ubb,"["&chr(176),"[",1,-1,1)
ubb=replace(ubb,chr(176)&"]","]",1,-1,1)
ubb=replace(ubb,"/"&chr(176),"/",1,-1,1)
' ubb=replace(ubb,"{;em","{:em",1,-1,1)
end function


function convert(ubb,covt)
dim ctext,startubb,endubb,lcovt,text,codetext
ctext=ubb
startubb=1
do while covt="url" or covt="color" or covt="font" or covt="size"
startubb=instr(startubb,ctext,"["&covt&"=",1)
if startubb=0 then exit do
endubb=instr(startubb,ctext,"]",1)
if endubb=0 then exit do
lcovt=covt
startubb=startubb+len(lcovt)+2
text=mid(ctext,startubb,endubb-startubb)
codetext=replace(text,"[","["&chr(176),1,-1,1)
codetext=replace(codetext,"]",chr(176)&"]",1,-1,1)
'codetext=replace(codetext,"{:em","{;em",1,-1,1)
codetext=replace(codetext,"/","/"&chr(176),1,-1,1)
select case covt
case "color"
ctext=replace(ctext,"[color="&text&"]","<font color='"&text&"'>",1,1,1)
ctext=replace(ctext,"[/color]","</font>",1,1,1)
case "font"
ctext=replace(ctext,"[font="&text&"]","<font face='"&text&"'>",1,1,1)
ctext=replace(ctext,"[/font]","</font>",1,1,1)
case "size"
if isnumeric(text) then
if text>6 then text=6
if text<1 then text=1
ctext=replace(ctext,"[size="&text&"]","<font size='"&text&"'>",1,1,1)
ctext=replace(ctext,"[/size]","</font>",1,1,1)
end if
case "url"
ctext=replace(ctext,"[url="&text&"]","<a href='"&codetext&"' target=_blank>",1,1,1)
ctext=replace(ctext,"[/url]","</a>",1,1,1)
case "email"
ctext=replace(ctext,"["&covt&"="&text&"]","<a href=mailto:"&text&">",1,1,1)
ctext=replace(ctext,"[/"&covt&"]","</a>",1,1,1)
end select
loop

startubb=1
do
startubb=instr(startubb,ctext,"["&covt&"]",1)
if startubb=0 then exit do
endubb=instr(startubb,ctext,"[/"&covt&"]",1)
if endubb=0 then exit do
lcovt=covt
startubb=startubb+len(lcovt)+2
text=mid(ctext,startubb,endubb-startubb)
codetext=replace(text,"[","["&chr(176),1,-1,1)
codetext=replace(codetext,"]",chr(176)&"]",1,-1,1)
'codetext=replace(codetext,"{:em","{;em",1,-1,1)
codetext=replace(codetext,"/","/"&chr(176),1,-1,1)
select case covt
case "url"
ctext=replace(ctext,"["&covt&"]"&text,"<a href='"&codetext&"' target=_blank>"&codetext,1,1,1)
ctext=replace(ctext,"<a href='"&codetext&"' target=_blank>"&codetext&"[/"&covt&"]","<a href="&codetext&" target=_blank>"&codetext&"</a>",1,1,1)
case "email"
ctext=replace(ctext,"["&covt&"]","<a href=mailto:"&text&">",1,1,1)
ctext=replace(ctext,"[/"&covt&"]","</a>",1,1,1)
case "html"
codetext=replace(codetext,"<br>",chr(13),1,-1,1)
codetext=replace(codetext," ",chr(32),1,-1,1)
randomize
rid="temp"&int(100000 * rnd)
ctext=replace(ctext,"{html}"&text,"代码片断如下:<textarea id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext,1,1,1)
ctext=replace(ctext,"代码片断如下:<textarea id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext&"{/html}","代码片断如下:<textarea id="&rid&" rows=15 style='width:100%' class='bk'>"&codetext&"</textarea><input onclick=runex('"&rid&"') type=button value=运行此段代码 name=button1 class='tips_bo'> <input onclick=jm_cc('"&rid&"') type=button value=复制到我的剪贴板 name=button2 class='tips_bo'>",1,1,1)
case "img"
ctext=replace(ctext,"[img]"&text,"<a href="&chr(34)&"about:<img src="&codetext&" border=0>"&chr(34)&" target=_blank><img src="&codetext,1,1,1)
ctext=replace(ctext,"[/img]"," vspace=2 hspace=2 border=0 alt=::点击图片在新窗口中打开::></a>",1,1,1)
case "code"
ctext=replace(ctext,"[code]"&text,"以下内容为程序代码<hr noshade>"&codetext,1,1,1)
ctext=replace(ctext,"以下内容为程序代码<hr noshade>"&codetext&"[/code]","以下内容为程序代码<hr noshade>"&codetext&"<hr noshade>",1,1,1)
case "quote"
atext=replace(text,"[img]","",1,-1,1)
atext=replace(atext,"[/img]","",1,-1,1)
atext=replace(atext,"[swf]","",1,-1,1)
atext=replace(atext,"[/swf]","",1,-1,1)
atext=replace(atext,"{html}","",1,-1,1)
atext=replace(atext,"{/html}","",1,-1,1)
' atext=replace(atext,"{:em","{;em",1,-1,1)
atext=splitwords(atext,350)
atext=replace(atext,chr(32)," ",1,-1,1)
ctext=replace(ctext,"[quote]"&text,"<blockquote><hr noshade>"&atext,1,1,1)
ctext=replace(ctext,"<blockquote><hr noshade>"&atext&"[/quote]","<blockquote><hr noshade>"&atext&"<hr noshade></blockquote>",1,1,1)
case "swf"
ctext=replace(ctext,"[swf]"&text,"影片地址:<br>"&text&"<br><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width='500' height='500'>",1,1,1)
ctext=replace(ctext,"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width='500' height='500'>"&"[/swf]","<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='500' height='500'><param name=movie value='"&codetext&"'><param name=quality value=high><embed src='"&codetext&"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width='500' height='500'>"&"</embed></object>",1,1,1)
end select
loop
convert=ctext
end function