asp的ubb函数(推荐)

代码如下:

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

(0)

相关推荐

  • asp的ubb函数(推荐)

    复制代码 代码如下: function unHtml(content) unHtml=content if content <> "" then unHtml=replace(unHtml,"&","&") unHtml=replace(unHtml,"<","<") unHtml=replace(unHtml,">",">&

  • ASP.NET常用函数(推荐)

    Abs(number) 取得数值的绝对值.  Asc(String) 取得字符串表达式的第一个字符ASCII 码.  Atn(number) 取得一个角度的反正切值.  CallByName (object, procname, usecalltype,[args()]) 执行一个对象的方法.设定或传回对象的属性.  CBool(expression) 转换表达式为Boolean 型态.  CByte(expression) 转换表达式为Byte 型态.  CChar(expression) 转

  • asp 字符串截取函数

    asp 字符串截取函数'********************************************************* '函数:cutStr[str(strlen)] '参数:str,待处理的字符串,strlen,截取的长度 '作者:木木 '日期:2007/7/12 '描述:截取指定长度的字符串 '示例:<%=cutStr("欢迎光临阿里西西",5)%> '*************************************************

  • ASP 中 DateDiff 函数详解 主要实现两日期加减操作

    ASP 中 DateDiff 函数详解DateDiff 函数 描述  返回两个日期之间的时间间隔.  语法  DateDiff(interval, date1, date2 [,firstdayofweek][, firstweekofyear]])  DateDiff 函数的语法有以下参数: 参数 描述  interval 必选.字符串表达式,表示用于计算 date1 和 date2 之间的时间间隔.有关数值,请参阅"设置"部分.  date1, date2 必选.日期表达式.用于计

  • ASP 中 Split 函数的实例分析

    asp下使用split实现数组操作的方法ASP 中 Split 函数的实例 大家有碰到过要想取一字符串里的某些值而无从下手?有没有觉得看书或教材对split的写法糊里糊涂--如果有此疑问的话,请看下面我对例子的解释,相信您会对这个有一定的了解. 我先介绍一下Split函数的用法: 返回值数组 = Split("字符串","分割符") 假设变量strURL保存着URL值,如strURL = "ftp://username:password@server&qu

  • asp通用采集函数冗余版可以保存文件到本地

    <% '名称:asp通用采集函数冗余版,要精品版的有心人自己改 '作者:柳永法 '日期:2007-6-23 Function getHTTPPage(Path)     t = GetBody(Path)     getHTTPPage = BytesToBstr(t, "GB2312") End Function Function GetBody(url)     On Error Resume Next     Set xmlhttp = CreateObject("

  • ASP中DateAdd函数中日期相加或相减使用方法

    ASP中DateAdd函数用法 2006/09/22 12:29 注意vbs中和sql中写法略有不同,以下帖出的为vbs帮助. sql的可搜索sql自带帮助文档 字符串表达式,表示要添加的时间间隔.有关数值,请参阅"设置"部分. 返回已添加指定时间间隔的日期. DateAdd(interval, number, date) 参数 interval 必选项. number 必选项.数值表达式,表示要添加的时间间隔的个数.数值表达式可以是正数(得到未来的日期)或负数(得到过去的日期). d

  • asp之字符串函数示例

    asp之字符串函数示例用字符串函数对字符串进行截头去尾.大小写替换等操作. 函数语法功能LenLen(string|varname)返回字符串内字符的数目,或是存储一变量所需的字节数.TrimTrim(string)将字符串前后的空格去掉LtrimLtrim(string)将字符串前面的空格去掉RtrimRtrim(string)将字符串后面的空格去掉MidMid(string,start,length)从string字符串的start字符开始取得length长度的字符串,如果省略第三个参数表示

  • ASP常用的函数

    ASP常用的函数,希望能用的着. <% dim db db="dbms.mdb" '****************************************************************** '执行sql语句,不返回值,sql语句最好是如下: 'update 表名 set 字段名=value,字段名=value where 字段名=value 'delete from 表名 where 字段名=value 'insert into 表名 (字段名,字段名

  • asp.net ubb使用代码

    复制代码 代码如下: ////别人写的ubb代码 using System; using System.Text; using System.Text.RegularExpressions; namespace Test.Com { /// <summary> /// 功能:UBB代码 /// 作者:Rexsp /// 日期:2004-4-6 /// </summary> public class UBB { #region 构造函数 public UBB() { // // TO

随机推荐