| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1821 人关注过本帖
标题:UBB问题
只看楼主 加入收藏
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
以下是引用yms123在2005-12-23 14:46:00的发言:

说实话我也懒得写的说-_-汗,不过我倒是自己找到过UBB的代码。不是用JavaScript的,用ASP的代码来做的UBB类。

我就是想直接拿来用的那种,只要把那些UBB放在一个文件夹里面,
在调用页页用
<include file=....>
就只想用这么简单的!!!
有的话共享一下
。非常谢谢!!


中国人的财富网:http://www..cn/
2005-12-23 14:51
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
回复:(caiyakang)UBB问题
<%
Class UbbCode
Private Function unHtml(content)
On Error Resume Next
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
'Ubb代码主函数
Public Function ubb(content)
On Error Resume Next
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>", 1, -1, 1)
ubb = Replace(ubb, "
", "</b>", 1, -1, 1)
ubb = Replace(ubb, "", "<i>", 1, -1, 1)
ubb = Replace(ubb, "
", "</i>", 1, -1, 1)
ubb = Replace(ubb, "", "<u>", 1, -1, 1)
ubb = Replace(ubb, "
", "</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
'Ubb代码解析函数
Private Function Convert(ubb, CovT)
On Error Resume Next
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
End If
endubb = InStr(startubb, cText, "]", 1)
If endubb = 0 Then
Exit Do
End If
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 face='" & text & "'>", 1, 1, 1)
cText = Replace(cText, "
", "</font>", 1, 1, 1)
Case "size"
If IsNumeric(text) Then
If text > 6 Then
text = 6
End If
If text < 1 Then
text = 1
End If
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
End If
endubb = InStr(startubb, cText, "[/" & CovT & "]", 1)
If endubb = 0 Then
Exit Do
End If
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, "
\" & text, \"以下内容为程序代码<hr noshade>\" & codetext, 1, 1, 1)
cText = Replace(cText, \"以下内容为程序代码<hr noshade>\" & codetext & \"
", "以下内容为程序代码<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 = Split(atext, 350)
atext = Replace(atext, Chr(32), " ", 1, -1, 1)
cText = Replace(cText, "
" & text, "<blockquote><hr noshade>" & atext, 1, 1, 1)
cText = Replace(cText, "<blockquote><hr noshade>" & atext & "
", "<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
End Class
%>
从网上找的,本人一直用这个。用法
Dim oUbb
Set oUbb=New UbbCode
Response.Write oUbb.ubb("[url=http://bbs.bc-cn.net]编程中国[/url]")
2005-12-23 15:03
快速回复:UBB问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021114 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved