当前位置: 移动技术网 > IT编程>开发语言>Asp > 很不错的一个UBB代码

很不错的一个UBB代码

2017年12月12日  | 移动技术网IT编程  | 我要评论
<%
function htmlencode(byval strvalue)
 '忽略错误
 on error resume next
 '定义变量
 dim strnewvalue
 if strvalue <> "" then
  strnewvalue = replace(strvalue,"<","<")
  strnewvalue = replace(strnewvalue,">",">")
  strnewvalue = replace(strnewvalue,"'","'")
  strnewvalue = replace(strnewvalue,"""",""")
  strnewvalue = replace(strnewvalue,vbcrlf,"<br>")
  strnewvalue = replace(strnewvalue," "," ")
 end if
 htmlencode = strnewvalue
 '输出错误
 if err.number>0 then
  response.write err.description
  response.end
 end if
end function

function ubbcode(strvalue) 
dim regexp 
'strvalue=htmlencode(strvalue)
set regexp=new regexp 
regexp.ignorecase =true 
regexp.global=true 

if strvalue <> "" then
regexp.pattern="(\[img\])(.[^\[]*)(\[\/img\])" 
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank><img src=""$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>") 

regexp.pattern="(\[flash\])(.[^\[]*)(\[\/flash\])" 
strvalue=regexp.replace(strvalue,"<object codebase="",0,2,0"" classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=500 height=400 id=shockwaveflash1><param name=movie value=""$2""><param name=quality value=high><embed src=""$2"" quality=high pluginspage=""

regexp.pattern="(\[zip\])(.[^\[]*)(\[\/zip\])" 
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>") 

regexp.pattern="(\[rar\])(.[^\[]*)(\[\/rar\])" 
strvalue=regexp.replace(strvalue,"<br><a href=""$2"">点击下载该文件</a>") 

'regexp.pattern="(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])" 
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0> <a href=""$3"" target=_blank>点击查看或下载该文件</a>") 
'strvalue=regexp.replace(strvalue,"<br><img src=""$2.gif"" border=0>此主题相关图片如下:<br><a href=""$3"" target=_blank><img src=""$3"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>") 

regexp.pattern="(\[url\])(http:\/\/.[^\[]*)(\[\/url\])" 
strvalue=regexp.replace(strvalue,"<a href=""$2"" target=_blank>$2</a>") 

regexp.pattern="(\[url\])(.[^\[]*)(\[\/url\])" 
strvalue=regexp.replace(strvalue,"<a href=""") ' target="_blank" rel="nofollow">http://$2"" target= ... t;/a>") 

regexp.pattern="(\

regexp.pattern="(\[email\])(\s+\@.[^\[]*)(\[\/email\])" 
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"">$2</a>") 

regexp.pattern="(\[email=(\s+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])" 
strvalue=regexp.replace(strvalue,"<a href=""mailto:$2"" target=_blank>$3</a>") 

regexp.pattern = "^(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "(http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "[^>=""](http://[a-za-z0-9\./=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "^(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "(ftp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "[^>=""](ftp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "^(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "(rtsp://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "[^>=""](rtsp://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "^(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "(mms://[a-za-z0-9\./=\?%\-&_~`@':+!]+)$" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern = "[^>=""](mms://[a-za-z0-9\.\/=\?%\-&_~`@':+!]+)" 
strvalue=regexp.replace(strvalue,"<a target=_blank href=$1>$1</a>") 

regexp.pattern="(\[html\])(.[^\[]*)(\[\/html\])" 
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>") 

regexp.pattern="(\[code\])(.[^\[]*)(\[\/code\])" 
strvalue=regexp.replace(strvalue,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#ffffff'><td><b>以下内容为程序代码:</b><br>$2</td></table>") 

regexp.pattern="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])" 
strvalue=regexp.replace(strvalue,"<font color=$2>$3</font>") 

regexp.pattern="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])" 
strvalue=regexp.replace(strvalue,"<font face=$2>$3</font>") 

regexp.pattern="(\[align=(.[^\[]*)\])(.*)(\[\/align\])" 
strvalue=regexp.replace(strvalue,"<div align=$2>$3</div>") 

regexp.pattern="(\[quote\])(.*)(\[\/quote\])" 
strvalue=regexp.replace(strvalue,"<table cellpadding=0 cellspacing=0 border=0 width=94% bgcolor=#000000 align=center><tr><td><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#ffffff'>$2</table></table><br>") 

regexp.pattern="(\[fly\])(.*)(\[\/fly\])" 
strvalue=regexp.replace(strvalue,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>") 

regexp.pattern="(\[move\])(.*)(\[\/move\])" 
strvalue=regexp.replace(strvalue,"<marquee scrollamount=3>$2</marquee>")  

regexp.pattern="\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]" 
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>") 

regexp.pattern="\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]" 
strvalue=regexp.replace(strvalue,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>") 

regexp.pattern="(\[i\])(.[^\[]*)(\[\/i\])" 
strvalue=regexp.replace(strvalue,"<i>$2</i>") 

regexp.pattern="(\[u\])(.[^\[]*)(\[\/u\])" 
strvalue=regexp.replace(strvalue,"<u>$2</u>") 

regexp.pattern="(\[b\])(.[^\[]*)(\[\/b\])" 
strvalue=regexp.replace(strvalue,"<b>$2</b>") 

regexp.pattern="(\[fly\])(.[^\[]*)(\[\/fly\])" 
strvalue=regexp.replace(strvalue,"<marquee>$2</marquee>") 

regexp.pattern="(\[size=1\])(.[^\[]*)(\[\/size\])" 
strvalue=regexp.replace(strvalue,"<font size=1>$2</font>") 

regexp.pattern="(\[size=2\])(.[^\[]*)(\[\/size\])" 
strvalue=regexp.replace(strvalue,"<font size=2>$2</font>") 

regexp.pattern="(\[size=3\])(.[^\[]*)(\[\/size\])" 
strvalue=regexp.replace(strvalue,"<font size=3>$2</font>") 

regexp.pattern="(\[size=4\])(.[^\[]*)(\[\/size\])" 
strvalue=regexp.replace(strvalue,"<font size=4>$2</font>") 

regexp.pattern="(\[center\])(.[^\[]*)(\[\/center\])" 
strvalue=regexp.replace(strvalue,"<center>$2</center>") 
end if
set regexp=nothing 
ubbcode=strvalue 

'输出错误
if err.number>0 then
  response.write err.description
  response.end
end if
end function
%>

调用:<%=ubbcode(content)%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网