📄 dv_ubbcode.asp
字号:
<%
'最后修改2006.6.11
Dim UserPointInfo(4)
'UBB代码勘套循环的最多次数,避免死循环加入此变量
Const MaxLoopcount=100
'部分服务器vbscript可能不支持SubMatches集合,请设置 Issupport=0
Const Issupport=1
'签名最大字体值
Const Maxsize=4
Rem 是否让管理员看到是贴子是否符合XHTML格式
Const showisxhtml=1
Const ubb_version="2006-6-20"
Rem can_Post_Style是不限制style使用的用户组别列表,你可以根据自己需要修改
Const can_Post_Style="1,2,3,35"
Dim Mtinfo
Mtinfo="<fieldset style=""border : 1px dotted #ccc;text-align : left;line-height:22px;text-indent:10px""><legend><b>媒体文件信息</b></legend><div>文件来源:$4</div>"&_
"<div>您可以点击控件上的播放按钮在线播放。注意,播放此媒体文件存在一些风险。</div>"&_
"<div>附加说明:动网论坛系统禁止了该文件的自动播放功能。</div>"&_
"<div>由于该用户没有发表自动播放多媒体文件的权限或者该版面被设置成不支持多媒体播放。</div></fieldset>"
Const DV_UBB_TITLE=" title=""dvubb"" "
Const UBB_TITLE="dvubb"
%>
<script language=vbscript runat=server>
Dim Ubblists
'[/img]编号:1.[/upload]编号:2.[/dir]编号:3.[/qt]编号:4.[/mp]编号:5.
'[/rm]编号:6.[/sound]编号:7.[/flash]编号:8.[/money]编号:9.[/point]编号:10.
'[/usercp]编号:11.[/power]编号:12.[/post]编号:13.[/replyview]编号:14.[/usemoney]编号:15.
'[/url]编号:16.[/email]编号:17.http编号:18.https编号:19.ftp编号:20.rtsp编号:21.
'mms编号:22.[/html]编号:23.[/code]编号:24.[/color]编号:25.[/face]编号:26.[/align]编号:27.
'[/quote]编号:28.[/fly]编号:29.[/move]编号:30.[/shadow]编号:31.[/glow]编号:32.[/size]编号:33.
'[/i]编号:34.[/b]编号:35.[/u]编号:36.[em编号:37.www.编号:38.[/payto]编号:40.[/username]编号:41.[/center]编号:42.
Class Dvbbs_UbbCode
Public Re,reed,isgetreed,Board_Setting,WapPushUrl,xml,isxhtml
Function xmlencode(Str)
Dim s,i
s=Str
S=replace(S,"&","&")
For i=0 to 31
S=Replace(S,Chr(i),"&#"&i&";")
Next
For i=95 to 96
S=Replace(S,Chr(i),"&#"&i&";")
Next
xmlencode=S
End Function
Function Rexmlencode(Str)
Dim i
Str=replace(Str,"&","&")
For i=0 to 31
Str=Replace(Str,"&#"&i&";",Chr(i))
Next
For i=95 to 96
Str=Replace(Str,"&#"&i&";",Chr(i))
Next
Rexmlencode=Str
End Function
Public Property Let PostType(ByVal vNewvalue)
If PostType=2 Then
Board_Setting=Split("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1",",")
Board_Setting(6)=1
Board_Setting(5)=0:Board_Setting(7)=1
Board_Setting(8)=1:Board_Setting(9)=1
Board_Setting(10)=0:Board_Setting(11)=0
Board_Setting(12)=0:Board_Setting(13)=0
Board_Setting(14)=0:Board_Setting(15)=0
Board_Setting(23)=0:Board_Setting(44)=0
Else
If Dvbbs.BoardID >0 Then
Board_Setting=Dvbbs.Board_Setting
Else
Board_Setting=Split("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1",",")
Board_Setting(6)=1
Board_Setting(5)=0:Board_Setting(7)=1
Board_Setting(8)=1:Board_Setting(9)=1
Board_Setting(10)=0:Board_Setting(11)=0
Board_Setting(12)=0:Board_Setting(13)=0
Board_Setting(14)=0:Board_Setting(15)=0
Board_Setting(23)=0:Board_Setting(44)=0
End If
End If
End Property
Private Sub Class_Initialize()
Set re=new RegExp
re.IgnoreCase =true
re.Global=true
Set xml=Server.Createobject("msxml2.DOMDocument"& MsxmlVersion)
If Dvbbs.UserID=0 Then
UserPointInfo(0)=0:UserPointInfo(1)=0:UserPointInfo(2)=0:UserPointInfo(3)=0:UserPointInfo(4)=0
Else
UserPointInfo(0)=CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text)
UserPointInfo(1)=CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userep").text)
UserPointInfo(2)=CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text)
UserPointInfo(3)=CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text)
UserPointInfo(4)=CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text)
End If
End Sub
Private Sub class_terminate()
Set xml=Nothing
Set Re=Nothing
End Sub
Function istext(Str)
Dim text,text1
text=Str
text1=Str
If text1=Dvbbs.Replacehtml(text) Then
istext=True
End If
End Function
Function TextFormt(Str)
Dim tmp,i
Str=replace(Str,Chr(13)& Chr(10),Chr(13))
'Str=replace(Str," ",Chr(13))
Str=replace(Str,Chr(10),Chr(13))
Str = re.Replace(Str,"$1"& Chr(13) &"$3")
TMP=Split(Str,Chr(13))
Str=""
For i=0 to UBound(tmp)
If i=UBound(tmp) Then
Str=Str & tmp(i)
Else
Str=Str & tmp(i) &"<br />"
End If
Next
're.Pattern="\[((.|\n^\]^\[)*?)<br />((.|\n^\]^\[)*?)\]"
'Str = re.Replace(Str,"[$1 $3]")
TextFormt=Str
End Function
Rem处理老DHTML贴子
Public Function Dv_UbbCode_DHTML(s,PostUserGroup,PostType,sType)
Dim matches,match,CodeStr
If InStr(Ubblists,",39,")>0 And (InStr(Ubblists,",table,")>0 Or InStr(Ubblists,",td,")>0 Or InStr(Ubblists,",th,")>0 Or InStr(Ubblists,",tr,")>0 ) Then
s = server.htmlencode(s)
s="<form name=""scode"&replyid&""" method=""post"" action=""""><table class=""tableborder2"" cellspacing=""1"" cellpadding=""3"" width=""100%"" align=""center"" border=""0""><tr><th height=""22"">以下内容含错误标记</th></tr><tr><td class=""tablebody1"" align=""middle"" width=""98%""><textarea id=""CodeText"" style=""BORDER-RIGHT: 1px dotted; BORDER-TOP: 1px dotted; OVERFLOW-Y: visible; OVERFLOW: visible; BORDER-LEFT: 1px dotted; WIDth: 98%; COLOR: #000000; BORDER-BOTTOM: 1px dotted"" rows=""20"" cols=""120"">"&s&"</textarea></td></tr><tr><td class=""tablebody2"" align=""middle"" width=""98%""></td></tr></table></form>"
Dv_UbbCode_DHTML=s
Exit Function
Else
If Board_Setting(5)="0" Then
re.Pattern ="<(\/?(i|b|p))>"
s=re.Replace(s,Chr(1)&"$1"&Chr(2))
re.Pattern="(>)("&vbNewLine&"){1,2}(<)"
s=re.Replace(s,"$1$3")
re.Pattern="(<div class=""quote"">)((.|\n)*?)(<\/div>)"
Do While re.Test(s)
s=re.Replace(s,"[quote]$2[/quote]")
Loop
re.Pattern = "(<\/tr>)"
s = re.Replace(s,"[br]")
re.Pattern = "(<br/>)"
s = re.Replace(s,"[br]")
re.Pattern = "(<br>)"
s = re.Replace(s,"[br]")
re.Pattern = "<(\/?s(ub|up|trike))>"
s = re.Replace(s,"[$1]")
re.Pattern = "(<)(\/?font[^>]*)(>)"
s = re.Replace(s,CHR(1)&"$2"&CHR(2))
re.Pattern="<([^<>]*?)>"
Do while re.Test(s)
s=re.Replace(s,"")
Loop
re.Pattern = "(\x01)(\/?font[^\x02]*)(\x02)"
s = re.Replace(s,"<$2>")
re.Pattern = "\[(\/?s(ub|up|trike))\]"
s = re.Replace(s,"<$1>")
re.Pattern="(\[quote\])((.|\n)*?)(\[\/quote\])"
Do While re.Test(s)
s=re.Replace(s,"<div class=""quote"">$2</div>")
Loop
re.Pattern="\x01(\/?(i|b|p))\x02"
s=re.Replace(s,"<$1>")
re.Pattern = "(\[br\])"
s = re.Replace(s,"<br/>")
End If
re.Pattern="<((asp|\!|%))"
s=re.Replace(s,"<$1")
End If
If InStr(s,"<TABLE") =0 Then s="<pre>" & TextFormt(S) &"</pre>"
Dv_UbbCode_DHTML=s
End Function
'论坛内容部分UBBCODE,入口:内容、用户组ID、模式(1=帖子/2=公告、短信等)、模式2(0=新版/1=老版)
Public Function Dv_UbbCode(s,PostUserGroup,PostType,sType)
Dim mt,i,tmp
isxhtml=false
mt=canusemt(PostUserGroup)
Dim textonly
textonly=istext(s)
If textonly Then
re.Pattern="<"
s= re.Replace(s,"<")
s=TextFormt(s)
End If
s=Rexmlencode(s)
re.Pattern = "(\[br\])"
s = re.Replace(s,"<br />")
If xml.loadxml("<div>" & xmlencode(s) &"</div>") Then
isxhtml=True
's=checkXHTML(mt,PostUserGroup)
Else
Rem处理老DHTML贴子
isxhtml=false
s=Dv_UbbCode_DHTML(s,PostUserGroup,PostType,sType)
End If
'Ubb转换
If InStr(Ubblists,",1,")>0 Or sType=1 Then
s=Dv_UbbCode_iS2(s,"img",_
"<a href=""$1"" target=""_blank"" ><img "& DV_UBB_TITLE &" src=""$1"" border=""0"" /></a>",_
"<img "& DV_UBB_TITLE &" src=""skins/default/filetype/gif.gif"" border=""0"" alt="" /><a href=""$1"" target=""_blank"" >$1</a>",_
PostUserGroup,Cint(Board_Setting(7)),_
"")
End If
'upload code
If InStr(Ubblists,",2,")>0 Or sType=1 Then
s=Dv_UbbCode_U(s,PostUserGroup,Cint(Board_Setting(7)))
End If
'media code
If InStr(Ubblists,",3,")>0 Or sType=1 Then
s=Dv_UbbCode_iS2(s,"DIR",_
"<object "& DV_UBB_TITLE &" classid=""clsid:166B1BCA-3F9C-11CF-8075-444553540000"" "&_
"codebase=""http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,2,0"" "&_
"width=""$1"" height=""$2""><param name=""src"" value=""$3"" /><embed "& DV_UBB_TITLE &" src=""$3"""&_
" pluginspage=""http://www.macromedia.com/shockwave/download/"" width=""$1"" height=""$2""></embed></object>",_
"<a href=""$3"" target=""_blank"">$3</a>",_
PostUserGroup,Cint(Board_Setting(9) * mt),_
"=*([0-9]*),*([0-9]*)")
End If
'qt
If InStr(Ubblists,",4,")>0 Or sType=1 Then
s=Dv_UbbCode_iS2(s,"QT",_
"<embed "& DV_UBB_TITLE &" src=""$3"" width=""$1"" height=""$2"" autoplay=""true"" loop=""false"" controller=""true"" playeveryframe=""false"" cache=""false"" scale=""TOFIT"" bgcolor=""#000000"" kioskmode=""false"" targetcache=""false"" pluginspage=""http://www.apple.com/quicktime/"" />",_
"<embed "& DV_UBB_TITLE &" src=""$3"" width=""$1"" height=""$2"" autoplay=""false"" loop=""false"" controller=""true"" playeveryframe=""false"" cache=""false"" scale=""TOFIT"" bgcolor=""#000000"" kioskmode=""false"" targetcache=""false"" pluginspage=""http://www.apple.com/quicktime/"" />"&_
replace(Mtinfo,"$4","$3"),_
PostUserGroup,Cint(Board_Setting(9) * mt),_
"=*([0-9]*),*([0-9]*)")
End If
'mp
If InStr(Ubblists,",5,")>0 Or sType=1 Then
s=Dv_UbbCode_iS2(s,"mp",_
"<object "& DV_UBB_TITLE &" align=""middle"" classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" class=""object"" id=""MediaPlayer"" width=""$1"" height=""$2"" >"&_
"<param name=""ShowStatusBar"" value=""-1"" /><param name=""Filename"" value=""$3"" />"&_
"<embed "& DV_UBB_TITLE &" type=""application/x-oleobject"" "&_
"codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"" flename=""mp"" src=""$3"" width=""$1"" height=""$2""></embed></object>",_
"<object "& DV_UBB_TITLE &" align=""middle"" classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" class=""object"" id=""MediaPlayer"" width=""$1"" height=""$2"" >"&_
"<param name=""ShowStatusBar"" value=""-1"" /><param name=""Filename"" value=""$3"" /><param name=""AUTOSTART"" value=""false"" />"&_
"<embed "& DV_UBB_TITLE &" type=""application/x-oleobject"" "&_
"codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"" flename=""mp"" src=""$3"" width=""$1"" height=""$2""></embed></object>"&_
replace(Mtinfo,"$4","$3"),_
PostUserGroup,Cint(Board_Setting(9) * mt),"=*([0-9]*),*([0-9]*)")
'Dv7 MediaPlayer自定义播放模式;
s=Dv_UbbCode_iS2(s,"mp",_
"<object "& DV_UBB_TITLE &" align=""middle"" classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" class=""object"" id=""MediaPlayer"" width=""$1"" height=""$2"" >"&_
"<param name=""AUTOSTART"" value=""$3"" /><param name=""ShowStatusBar"" value=""-1"" /><param name=""Filename"" value=""$4"" />"&_
"<embed "& DV_UBB_TITLE &" type=""application/x-oleobject"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"" flename=""mp"" src=""$4"" width=""$1"" height=""$2""></embed></object>",_
"<object "& DV_UBB_TITLE &" align=""middle"" classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" class=""object"" id=""MediaPlayer"" width=""$1"" height=""$2"" >"&_
"<param name=""AUTOSTART"" value=""false"" /><param name=""ShowStatusBar"" value=""-1"" /><param name=""Filename"" value=""$4"" />"&_
"<embed "& DV_UBB_TITLE &" type=""application/x-oleobject"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"" flename=""mp"" src=""$4"" width=""$1"" height=""$2""></embed></object>"&_
Mtinfo,PostUserGroup,Cint(Board_Setting(9) * mt),"=*([0-9]*),*([0-9]*),*([0|1|true|false]*)")
End If
'rm
If InStr(Ubblists,",6,")>0 Or sType=1 Then
s=Dv_UbbCode_iS2(s,"rm",_
"<div><object "& DV_UBB_TITLE &" classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" class=""object"" id=""RAOCX"" width=""$1"" height=""$2"">"&_
"<param name=""src"" value=""$3"" />"&_
"<param name=""CONSOLE"" value=""Clip1"" />"&_
"<param name=""CONtrOLS"" value=""imagewindow"" />"&_
"<param name=""AUTOSTART"" value=""true"" /></object></div>"&_
"<div><object "& DV_UBB_TITLE &" classid=""CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" height=""32"" id=""video2"" width=""$1"">"&_
"<param name=""src"" value=""$3"" /><param name=""AUTOSTART"" value=""-1"" />"&_
"<param name=""CONtrOLS"" value=""controlpanel"" />"&_
"<param name=""CONSOLE"" value=""Clip1"" /></object></div>",_
"<div><object "& DV_UBB_TITLE &" classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" class=""object"" id=""RAOCX"" width=""$1"" height=""$2"">"&_
"<param name=""src"" value=""$3"" />"&_
"<param name=""CONSOLE"" value=""Clip1"" />"&_
"<param name=""CONtrOLS"" value=""imagewindow"" />"&_
"<param name=""AUTOSTART"" value=""false"" /></object></div>"&_
"<div><object "& DV_UBB_TITLE &" classid=""CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" height=""32"" id=""video2"" width=""$1"">"&_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -