给你的JSP适用Ubbcode

2021-02-04 03:15| 发布者: | 查看: |


private static final String ImagePath = images/ //界定照片相对路径
private static final String emotImagePath = images/emot/

/**
* @description 变换编码,使之适用ubbcode.
* @param strContent 变换前的编码.
* @return result 变换后的內容.
*/
public static String UBBCode(String strContent) { //
strContent = dvHTMLEncode(strContent);
strContent = FilterJS(strContent);
String re;
//re.IgnoreCase =true
//re.Global=True
Pattern pattern = null; //
Matcher matcher = null;
//变换IMG
re = \\[IMG\\](http|https|ftp):\\/\\/(.[^\\[]*)\\[\\/IMG\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( a onfocus=this.blur() href=\ $1://$2\ target=_blank IMG SRC=\ $1://$2\ border=0 alt=按此在新页面访问照片 onload=\ javascript:if(this.width screen.width-333)this.width=screen.width-333\ /a
//变换UPLOAD
re = \\[UPLOAD=(gif|jpg|jpeg|bmp|png)\\](.[^\\[]*)(gif|jpg|jpeg|bmp|png)\\[\\/UPLOAD\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( br IMG SRC=\ + ImagePath + $1.gif\ border=0 此主题风格有关照片以下: br A HREF=\ $2$1\ TARGET=_blank IMG SRC=\ $2$1\ border=0 alt=按此在新页面访问照片 onload=\ javascript:if(this.width screen.width-333)this.width=screen.width-333\ /A
re = \\[UPLOAD=(.[^\\[]*)\\](.[^\\[]*)\\[\\/UPLOAD\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( br IMG SRC=\ + ImagePath +
$1.gif\ border=0 a href=\ $2\ 点一下访问该文档 /a
//变换DIR
re = \\[DIR=*([0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/DIR]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( object classid=clsid:166B1BCA-3F9C-11CF-80000 codebase=pub/shockwave/cabs/director/sw.cab#version=7,0,2,0 width=$1 height=$2 param name=src value=$3 embed src=$3 pluginspage=shockwave/download/ width=$1 height=$2 /embed /object
//变换QT
re = \\[QT=*([0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/QT]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( 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=quicktime/
//变换MP
re = \\[MP=*([0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/MP]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 > //变换RM
re = \\[RM=*([0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/RM]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA > //变换FLASH
re = (\\[FLASH\\])(.[^\\[]*)(\\[\\/FLASH\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
a href=\ $2\ TARGET=_blank IMG SRC=\ + ImagePath + swf.gif\ border=0 alt=点一下开新页面赏析该FLASH动漫! height=16 width=16 [全屏幕赏析] /a br OBJECT codeBase=pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8- width=500 height=400 PARAM NAME=movie VALUE=\ $2\ PARAM NAME=quality VALUE=high embed src=\ $2\ quality=high pluginspage='shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400 $2 /embed /OBJECT
re = (\\[FLASH=*([0-9]*),*([0-9]*)\\])(.[^\\[]*)(\\[\\/FLASH\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
a href=\ $4\ TARGET=_blank IMG SRC=\ + ImagePath + swf.gif\ border=0 alt=点一下开新页面赏析该FLASH动漫! height=16 width=16 [全屏幕赏析] /a br OBJECT codeBase=pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8- width=$2 height=$3 PARAM NAME=movie VALUE=\ $4\ PARAM NAME=quality VALUE=high embed src=\ $4\ quality=high pluginspage='shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=$2 height=$3 $4 /embed /OBJECT
//变换URL
re = (\\[URL\\])(.[^\\[]*)(\\[\\/URL\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( A HREF=\ $2\ TARGET=_blank $2 /A
re = (\\[URL=(.[^\\[]*)\\])(.[^\\[]*)(\\[\\/URL\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( A HREF=\ $2\ TARGET=_blank $3 /A
//变换EMAIL
re = (\\[EMAIL\\])(\\S+\\@.[^\\[]*)(\\[\\/EMAIL\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( img align=absmiddle src=\ +
ImagePath +
email1.gif\ A HREF=\ mailto:$2\ $2 /A
re = (\\[EMAIL=(\\S+\\@.[^\\[]*)\\])(.[^\\[]*)(\\[\\/EMAIL\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( img align=absmiddle src=\ +
ImagePath +
email1.gif\ A HREF=\ mailto:$2\ TARGET=_blank $3 /A

//全自动鉴别网站地址
re =
^((http|https|ftp|rtsp|mms):(\\/\\/|\\\\)[A-Za-z0-9\\./=\\?%\\- _~`@':+!]+)
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
img align=absmiddle src=pic/url.gif border=0 a target=_blank href=$1 $1 /a
re =
((http|https|ftp|rtsp|mms):(\\/\\/|\\\\)[A-Za-z0-9\\./=\\?%\\- _~`@':+!]+)$
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
img align=absmiddle src=pic/url.gif border=0 a target=_blank href=$1 $1 /a
re = ([^ =\ ])((http|https|ftp|rtsp|mms):(\\/\\/|\\\\)[A-Za-z0-9\\./=\\?%\\- _~`@':+!]+)
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( $1 img align=absmiddle src=pic/url.gif border=0 a target=_blank href=$2 $2 /a

//全自动鉴别www等开始的网站地址
re = ([^([\\~]*|\\[\\~]*)(\\w)+)|[.](\\w)+)*(((([?](\\w)+){1}[=]*))*((\\w)+){1}([\\ ](\\w)+[\\=](\\w)+)*)*)
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( img align=absmiddle src=pic/url.gif border=0 a target=_blank href=a

//全自动鉴别Email详细地址,如开启本作用在访问內容许多的贴子会造成网络服务器间断
re = ([^(=)])((\\w)+[@]{1}((\\w)+[.]){1,3}(\\w)+)
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( img align=absmiddle src=pic/url.gif border=0 a target=_blank href=\ mailto:$2\ $2 /a
//变换EM
re = \\[em(.[^\\[]*)\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( img src=\ + emotImagePath +
em$1.gif\ border=0 align=middle
//变换HTML
re = \\[HTML\\](.[^\\[]*)\\[\\/HTML\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( table width='100%' border='0' cellspacing='0' cellpadding='6' > //变换CODE
re = \\[code\\](.[^\\[]*)\\[\\/code\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( table width='100%' border='0' cellspacing='0' cellpadding='6' > //变换COLOR
re = \\[color=(.[^\\[]*)\\](.[^\\[]*)\\[\\/color\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( font color=$1 $2 /font
//变换FACE
re = \\[face=(.[^\\[]*)\\](.[^\\[]*)\\[\\/face\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( font face=$1 $2 /font
//变换ALIGN
re = \\[align=(center|left|right)\\](.*)\\[\\/align\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( div align=$1 $2 /div
//变换QUOTE
re = \\[QUOTE\\](.*)\\[\\/QUOTE\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( table > //变换FLY
re = \\[fly\\](.*)\\[\\/fly\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
marquee width=90% behavior=alternate scrollamount=3 $1 /marquee
//变换MOVE
re = \\[move\\](.*)\\[\\/move\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( MARQUEE scrollamount=3 $1 /marquee
//变换GLOW
re =
\\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/GLOW]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
table width=$1 > //变换SHADOW
re =
\\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\\](.[^\\[]*)\\[\\/SHADOW]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(
table width=$1 >
re = \\[i\\](.[^\\[]*)\\[\\/i\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( i $1 /i
re = \\[u\\](.[^\\[]*)(\\[\\/u\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( u $1 /u
re = \\[b\\](.[^\\[]*)(\\[\\/b\\])
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( b $1 /b
re = \\[size=([1-4])\\](.[^\\[]*)\\[\\/size\\]
pattern = pile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll( font size=$1 $2 /font
/*re = (\\s)
matcher = pattern.matcher(strContent);
strContent=matcher.replaceAll( I $1 /I */
re = null;
return strContent;
}

/**
* 过虑javascript编码.
* @param v变换前的编码.
* @return v变换后的內容.
*/

public static String FilterJS(String v) {
if (!v.equals( null ) v != null) {
String t, re;
re = (javascript)
t = re.replace(v, javascript
re = (jscript:)
t = re.replace(t, jscript:
re = (js:)
t = re.replace(t, js:
re = (value)
t = re.replace(t, value
re = (about:)
t = re.replace(t, about:
re = (file:)
t = re.replace(t, file:
re = (document.cookie)
t = re.replace(t, documents.cookie
re = (vbscript:)
t = re.replace(t, vbscript:
re = (vbs:)
t = re.replace(t, vbs:
re = (on(mouse|exit|error|click|key))
t = re.replace(t, on$2
re = ( #)
t = re.replace(t, &#
re = null;
}
return v;
}

/**
* 更换一些独特标记为html英语的语法标识.
* @param fString变换前的编码.
* @return fString变换后的內容.
*/

public static String dvHTMLEncode(String fString) {
if (!fString.equals( null ) fString != null) {
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, \ ,
fString = replace(fString, \' , '
fString = replace(fString, \r ,
fString = replace(fString, \n , BR
fString = replace(fString, \\ , \
}
return fString;
}

/**
* html英语的语法标识变换标记自身.
* @param fString变换前的编码.
* @return fString变换后的內容.
*/

public static String dvHTMLCode(String fString) {
if (!fString.equals( null ) fString != null) {
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, ,
fString = replace(fString, , \
fString = replace(fString, ' , \'
fString = replace(fString, \ , \\
fString = replace(fString, BR , \n
}
return fString;
}

public static String nohtml(String str) {
String re;
Pattern pattern = null;
Matcher matcher = null;
re = (\\ .[^\\ ]*\\ )
pattern = pile(re);
matcher = pattern.matcher(str);
str = matcher.replaceAll(
re = (\\ \\/[^\\ ]*\\ )
str = re.replace(str,
re = null;
return str;
}

/**
* 切分涵数.
* @param source原标识符串,div即将被切分的标识符串.
* @return returnStr切分后的标识符串.
*/

public static String[] split(String source, String div) {
int arynum = 0, intIdx = 0, intIdex = 0, div_length = div.length();
if (pareTo( ) != 0) {
if (source.indexOf(div) != -1) {
intIdx = source.indexOf(div);
for (int intCount = 1; ; intCount++) {
if (source.indexOf(div, intIdx + div_length) != -1) {
intIdx = source.indexOf(div, intIdx + div_length);
arynum = intCount;
} else {
arynum += 2;
break;
}
}
} else {
arynum = 1;
}
} else {
arynum = 0;

}
intIdx = 0;
intIdex = 0;
String[] returnStr = new String[arynum];

if (pareTo( ) != 0) {
if (source.indexOf(div) != -1) {
intIdx = (int) source.indexOf(div);
returnStr[0] = (String) source.substring(0, intIdx);
for (int intCount = 1; ; intCount++) {
if (source.indexOf(div, intIdx + div_length) != -1) {
intIdex = (int) source.indexOf(div, intIdx + div_length);
returnStr[intCount] = (String) source.substring(intIdx +
div_length,
intIdex);
intIdx = (int) source.indexOf(div, intIdx + div_length);
} else {
returnStr[intCount] = (String) source.substring(intIdx +
div_length,
source.length());
break;
}
}
} else {
returnStr[0] = (String) source.substring(0, source.length());
return returnStr;
}
} else {
return returnStr;
}
return returnStr;
}

/**
* 更换涵数.
* @param str更换前的标识符串,substr被更换的标识符,restr更换的标识符.
* @return 更换后而且历经除空解决的标识符串.
*/
public static String replace(String str, String substr, String restr) {
String[] tmp = split(str, substr);
String returnstr = null;
if (tmp.length != 0) {
returnstr = tmp[0];
for (int i = 0; i tmp.length - 1; i++) {
returnstr = dealNull(returnstr) + restr + tmp[i + 1];
}
}
return dealNull(returnstr);
}

/**
* 除空解决涵数.
* @param str原标识符串.
* @return 解决后的标识符串.
*/
public static String dealNull(String str) {
String returnstr = null;
if (str == null) {
returnstr =
} else {
returnstr = str;
}
return returnstr;
}

public static String tostring(Character i) {
Character c = i;
return c.toString();
}

}


|肃北建立网站 肃北县地区广阔,地分南北方,附近与一个我国、三个省(区)三个县区交界。辖5乡2镇,人口总数11000多的人,在其中蒙古族族占38.9%。是一个以蒙古族族主导体的极少数中华民族基层民主县,也是甘肃省省唯一的
|衢州网站建设 衢集县坐落于我国浙江省省中西部,位于浙江省、福建省、江西省、安徽省四省交界处,有着“四省通衢”之称,是沿海地区经济发展比较发达地域和内陆地区核心区的融合部。全省占地面积8837平方千米,人口数量24一万,所辖4县
|沂南公司建立网站 沂南县旧称阳都,是三国阶段知名政冶家、国防家诸葛亮的问世地,也是唐朝知名政冶家、书法家颜真卿的祖居地。史载:“阳都,临沂市以上游,英贤辈出,烟水之胜,轶于江南地区”。全乡
|广水网络推广 广水市坐落于湖北省省北边偏东,桐柏山峰东支南麓,大别山峰西端,地跨东经113°31′---114°07′北纬度31°23′---32°05′。地形北高南低,北边最大的大贵山主峰海拔高度907.80米,西北部最少处平
|乌兰察布互联网营销推广 乌兰察布(Ulanqab)内蒙古古基层民主区所辖市,位于我国正北方地区,内蒙古古基层民主区中间,自然地理座标为北纬度39°37′~43°28′,东经109°16′~114°49′,物品长458千米,南北方宽442千米,占地面积54,500平
|武平企业网站建设 武平县位于福建省省西北部,闽、粤、赣三省交界处处,有闽西“金三角”之称,是改革老县区、中间苏县区。武平县属亚热带气候深海性温带季风气候,气侯柔和,降雨量充足,四季明晰,夏长冬短
|三门企业网站建设 三门县,归属于于浙江省省台集县,坐落于浙江省省台集县东北地区部沿海地区。西枕浙江天台山,东濒三门湾,北接宁海县,南毗临海市。地形大西北高, 西南低。中、中西部为低山坡陵地域,东部地区为滨海县平原区
|沿滩企业网站建设 沿滩区归属于自贡市,因人民政府驻沿滩镇而出名,建区于1956年,坐落于自贡市的南京大学门,是秋收拢义总指挥长卢德铭英烈的家乡,是千年盐都——自贡市的四个地区之一,距自贡市12公里。北
|绥棱企业网站建设 绥棱(Líng)县坐落于黑龙江省省中间,绥棱县辖4个镇、七个乡:绥棱镇、上马店镇、四海店镇、双岔河镇、背靠乡、后头乡、长山乡、克音河乡、绥中乡、泥尔河乡、阁山乡。县地区有:阁山
|云阳企业网站建设 云阳县位于东经108°24′-109°14′,北纬度30°34′-31°27′。坐落于重庆市市东北地区部,湘江三峡工程项目作业区腹内心带。东与奉节县相接,西与万州区相接,南与湖北省省利川市邻近,北与开县、巫
|太康企业网站建设 太康,县名,属河南省省开封市市,总面积1761平方千米,人口数量134万。就是我国典型性的农牧业大县,就是我国关键的产品粮产业基地。
|色达企业网站建设 色达县坐落于云贵高原西南缘,甘孜藏基层民主州大西北部,北纬度31°38′-33°20′,东经98°48′-101°00′。位于两省(四川、青海省)三州(省内的阿坝州、甘孜州、青海省的果洛州)六县(阿坝的壤
强烈推荐地域 关键地网站制作、企业网站建设、网站运营服务强烈推荐,健全的售前服务售后服务服务保证顾客营销推广的合理
1、技术专业的网站制作制作精英团队给你出示7*二十四小时迅速网站设计制作业务流程,给你的网站迅速构建出示确保 2、一流的技术性工作人员,确保模版仿造编码的安全性、简约、齐整便捷顾客的迅速入门应用 3、多种多样开源系统CMS适用,给你出示dedecms模版网站建设、zblog模版网站建设、wordpress模版网站建设、discuz模版网站建设等业务流程 4、健全的售后服务,大家做的是服务,服务是沒有止境的大家期待与众多顾客达到小伙伴关联,给你出示有意义的事的协助
<
>

 
QQ在线咨询
售前咨询热线
18720358503
售后服务热线
18720358503
返回顶部