ubbcode简单实用

<%
function ChkBadWords(fString)
    if not(isnull(BadWords) or isnull(fString)) then
    bwords = split(BadWords, "|")
    for i = 0 to ubound(bwords)
        fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"))
    next
    ChkBadWords = fString
    end if
end function

function HTMLEncode(fString)
if not isnull(fString) then
    'fString = Replace(fString, CHR(38), "&")
    'fString = replace(fString, ">", ">")
    'fString = replace(fString, "<", "<")
    'fString = Replace(fString, CHR(39), "'")
    'fString = Replace(fString, CHR(32), " ")
    'fString = Replace(fString, CHR(34), """)
    'fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "<br/>")
    HTMLEncode = fString
end if
end function

function HTMLcode(fString)
if not isnull(fString) then
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "<br/>")
    HTMLcode = fString
end if
end function
function HTMLDecode(fString)
if not isnull(fString) then
    'fString = Replace(fString, CHR(38), "&")
    'fString = replace(fString, ">", ">")
    'fString = replace(fString, "<", "<")
    'fString = Replace(fString, CHR(32), " ")
    'fString = Replace(fString,"",CHR(13))
    fString = Replace(fString,"<br/>",CHR(10))
    HTMLDecode = fString
end if
end function

function UBBCode(strContent)
    if strAllowHTML <> 1 then
        strContent = HTMLEncode(strContent)
    else
 strContent = HTMLcode(strContent)
    end if
    dim re
    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True

re.Pattern="\[IMG\](.[^\[]*)\[\/IMG\]"
    strContent=re.Replace(strContent,"<img src=""$1"" border=""0""></img>")
    re.Pattern="\[IMG=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/IMG\]"
    strContent=re.Replace(strContent,"<a href=""$3"" title=点击看全图 target=_blank><img src=""$3"" width=""$1"" height=""$2"" border=""0""></img></a>")

'图文混排
    re.Pattern="\[PIC\](.[^\[]*)\[\/PIC\]"
    strContent=re.Replace(strContent,"<img src=""$1"" border=""0"" align=""left""></img>")
    re.Pattern="\[PIC=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/PIC\]"
    strContent=re.Replace(strContent,"<a href=""$3"" title=点击看全图 target=_blank><img src=""$3"" width=""$1"" height=""$2"" border=""0"" align=""left""></img></a>")

re.Pattern="\[FLASH=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/FLASH\]"
    strContent= re.Replace(strContent,"<EMBED SRC=""$3"" width=""$1"" height=""$2""></EMBED>")
    re.Pattern="\[FLASH\](.[^\[]*)\[\/FLASH\]"
    strContent= re.Replace(strContent,"<EMBED SRC=""$1""></EMBED>")

re.Pattern="(\[URL\])(http:\/\/.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=""_blank"">$2</A>")
    re.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""http://$2"" TARGET=""_blank"">$2</A>")

re.Pattern="(\[EMAIL\])(mailto:\/\/.[^\[]*)(\[\/EMAIL\])"
    strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=""_blank"">$2</A>")
    re.Pattern="(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"
    strContent= re.Replace(strContent,"<A HREF=""MAILTO:$2"" TARGET=""_blank"">$2</A>")

re.Pattern="(\[URL=(http:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=""_blank"">$3</A>")
    re.Pattern="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
    strContent= re.Replace(strContent,"<A HREF=""http://$2"" TARGET=""_blank"">$3</A>")

re.Pattern = "^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "[^>=""](http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "^(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "[^>=""](ftp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "[^>=""](rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "^(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")
 re.Pattern = "[^>=""](mms://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
 strContent = re.Replace(strContent,"<img align=absmiddle src=http://www.ceocio.net/images/url.gif><a target=_blank href=$1>$1</a>")

re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
 strContent=re.Replace(strContent,"<object 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 src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed></object>")
 re.Pattern="\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
 strContent=re.Replace(strContent,"<embed 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/>")
 re.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
 strContent=re.Replace(strContent,"<object 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 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>")
 re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
 strContent=re.Replace(strContent,"<OBJECT 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><br><OBJECT 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>")

re.Pattern="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
    strContent=re.Replace(strContent,"<font color=""$2"">$3</font>")
    re.Pattern="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
    strContent=re.Replace(strContent,"<font face=""$2"">$3</font>")
    re.Pattern="(\[align=(.[^\[]*)\])(.*)(\[\/align\])"
    strContent=re.Replace(strContent,"<div align=""$2"">$3</div>")

re.Pattern="(\[QUOTE\])(.*)(\[\/QUOTE\])"
    strContent=re.Replace(strContent,"<table cellpadding=""0"" cellspacing=""0"" border=""0"" WIDTH=""94%"" bgcolor=""#D7F0FF"" align=""center""><tr><td><table width=""100%"" cellpadding=""5"" cellspacing=""1"" border=""0""><TR><TD BGCOLOR='"&abgcolor&"'>$2</table></table><br>")
    re.Pattern="(\[fly\])(.*)(\[\/fly\])"
    strContent=re.Replace(strContent,"<marquee width=""90%"" behavior=""alternate"" scrollamount=""3"">$2</marquee>")
    re.Pattern="(\[move\])(.*)(\[\/move\])"
    strContent=re.Replace(strContent,"<MARQUEE scrollamount=""3"">$2</marquee>") 
    re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"
    strContent=re.Replace(strContent,"<table width=""$1"" style=""filter:glow(color=$2, strength=$3)"">$4</table>")
    re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
 strContent=re.Replace(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")

re.Pattern="(\[i\])(.[^\[]*)(\[\/i\])"
    strContent=re.Replace(strContent,"<i>$2</i>")
    re.Pattern="(\[u\])(.[^\[]*)(\[\/u\])"
    strContent=re.Replace(strContent,"<u>$2</u>")
    re.Pattern="(\[b\])(.[^\[]*)(\[\/b\])"
    strContent=re.Replace(strContent,"<b>$2</b>")
    re.Pattern="(\[fly\])(.[^\[]*)(\[\/fly\])"
    strContent=re.Replace(strContent,"<marquee>$2</marquee>")

re.Pattern="(\[size=1\])(.[^\[]*)(\[\/size\])"
    strContent=re.Replace(strContent,"<font size=""1"">$2</font>")
    re.Pattern="(\[size=2\])(.[^\[]*)(\[\/size\])"
    strContent=re.Replace(strContent,"<font size=""2"">$2</font>")
    re.Pattern="(\[size=3\])(.[^\[]*)(\[\/size\])"
    strContent=re.Replace(strContent,"<font size=""3"">$2</font>")
    re.Pattern="(\[size=4\])(.[^\[]*)(\[\/size\])"
    strContent=re.Replace(strContent,"<font size=""4"">$2</font>")
    re.Pattern="(\[center\])(.[^\[]*)(\[\/center\])"
    strContent=re.Replace(strContent,"<center>$2</center>")
    '以下扩展
    re.Pattern="(\[li\])(.[^\[]*)(\[\/li\])"
    strContent=re.Replace(strContent,"<li>$2</li>")
    '字体背景
    re.Pattern="(\[fontbg=(.[^\[]*)\])(.[^\[]*)(\[\/fontbg\])"
    strContent=re.Replace(strContent,"<span style=background-color:""$2"">$3</span>")
    '删除线
    re.Pattern="(\[strike\])(.[^\[]*)(\[\/strike\])"
    strContent=re.Replace(strContent,"<strike>$2</strike>")

re.Pattern="(\[HTML\])(.[^\[]*)(\[\/HTML\])"
 strContent=re.Replace(strContent,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='"&abgcolor&"'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
 re.Pattern="(\[code\])(.[^\[]*)(\[\/code\])"
 strContent=re.Replace(strContent,"<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='"&abgcolor&"'><td><b>以下内容为程序代码:</b><br>$2</td></table>")

strContent=ChkBadWords(strContent)

set re=Nothing
    UBBCode=strContent
end function
%>

(0)

相关推荐

  • ubbcode简单实用

    <%function ChkBadWords(fString)    if not(isnull(BadWords) or isnull(fString)) then    bwords = split(BadWords, "|")    for i = 0 to ubound(bwords)        fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"))     next   

  • JS获取地址栏参数的两种方法(简单实用)

    js获取地址栏参数的方法有两种:第一种,采用正则表达式获取地址栏参数,第二种,是比较传统的方法,在这小编给大家强烈推荐使用第一种方法,既方便有实用,具体实现过程请看下文详述. 方法一:采用正则表达式获取地址栏参数:( 强烈推荐,既实用又方便!) function GetQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window

  • JavaScript实现非常简单实用的下拉菜单效果

    本文实例讲述了JavaScript实现非常简单实用的下拉菜单效果.分享给大家供大家参考.具体如下: 这是一款实用的JS下拉菜单,鼠标移上菜单就显示出二级菜单,是从其它网站上整理下来的,修改花了不少时间,现在去除了一些无用代码,更简洁了,而且代码兼容性似乎也表现不错,这款两级下拉菜单,基本是由CSS和JavaScript共同实现的,真的挺简洁实用. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-css-down-show-menu-code

  • 分享几种比较简单实用的JavaScript tabel切换

    闲着没事,随便写了个简单的JavaScript tabel切换,大家有兴趣的看看,有需要的就拿去吧.废话不说了,大家看代码吧 方法一:for循环+if判断当前点击与自定义数组是否匹配 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>tab切换</title> <style type="te

  • PHP实现简单实用的验证码类

    本文实例讲述了PHP实现简单实用的验证码类.分享给大家供大家参考.具体如下: <?php /** * @version 1.0 * @author bolted snail * @date 2011-10-15 * @PHP验证码类 * 使用方法: * $image=new Captcha(); * $image->config('宽度','高度','字符个数','验证码session索引'); * $image->create();//这样就会向浏览器输出一张图片 * //所有参数都可

  • 简单实用的网站PHP缓存类实例

    缓存技术在实际使用当中应用非常广泛,可以有效减轻对服务器数据库的访问压力,提高运行速度.目前很多CMS内容管理系统中频繁使用缓存机制来提高系统运行的效率.本文以一个简单实用的缓存类为例,帮助大家参考下缓存的机制与写法. 缓存文件cache.php代码如下: <?php /* 用户需要事先定义的常量: _CachePath_ 模板缓存路径 _CacheEnable_ 自动缓存机制是否开启,未定义或为空,表示关闭自动缓存机制 _ReCacheTime_ 自动重新缓存间隔时间,单位为秒,未定义或为空,

  • ThinkPHP设置禁止百度等搜索引擎转码(简单实用)

    网站在移动端的阅读不可避免的会遇到转码问题,作为国内搜索引擎老大百度,自然要做技术的领头人了,做了百度转码,有些网站经过转码之后达到了想要的结果,但是有些网站经过百度加工后就是不忍直视,很多内容出现了错乱,Joe的网站也出现了一些错位,于是Joe用了Wordpress插件MobilePress,经过一些汉化修改,感觉比百度的转码更适合自己. 方法1.HTTP Response中显式声明,Cache-control:no-transform. 在config.php 文件中加入 'HTTP_CAC

  • 简单实用的PHP防注入类实例

    本文实例讲述了简单实用的PHP防注入类.分享给大家供大家参考.具体如下: PHP防注入注意要过滤的信息基本是get,post,然后对于sql就是我们常用的查询,插入等等sql命令了,下面我给各位整理两个简单的例子,希望这些例子能给你网站带来安全. PHP防注入类代码如下: 复制代码 代码如下: <?php /**  * 参数处理类  * @author JasonWei  */ class Params {     public $get = array();       public $pos

  • JavaScript正则表达式简单实用实例

     1.replace var user='xia&&min**'; user=user.replace(/[^A-Za-z\d_-]+/,''); //需要再次赋值 console.log(user); //xiamin** user = user.replace(/[^A-Za-z\d_-]+/g, ''); //全局进行替换 console.log(user); //xiamin 分割邮件 var email='nettuts@tutsplus.com'; var result=ema

  • Popupwindow 的简单实用案例(显示在控件下方)

    第一步: private PopupWindow mPopupWindow; 第二步:写一个popupwindow的布局文件XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_paren

随机推荐