⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ubb.asp

📁 用ASP实现的论坛开发
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<SCRIPT LANGUAGE=javascript RUNAT=Server>
//for Microsoft(R) Windows(R) Script 5.1
//PaintBlue UBBcode 5.1
//noUBB 0 支持所有ubb 1.不支持表情代码 . 2.不支持所有ubb
////iType 帖子=0 签名=1 短信=2 公告=3 ..etc..
//2004-9-5 修订

function SetUBB(iType,i,offiFrame) //offiFrame=0 表示直接关闭掉iframe
	{
	if(iType==0){if(boardSet(i)=="1")return true;}
	else{
		if(iType==3){return true;}
		else{
			if(iType==2)
				{
				if(offiFrame==1){if (bbsSet(25)=="1")return true;}
				}
			else{
				if(iType==1)
					{
					if(offiFrame==1){if(boardSet(68)=="1")return true;}
					}
				}
			}
		}
	return false;
	}

function UbbCode(content,iUBB,iType,iReplyType,GetIDstr,replyID,UserName){
	if (content=="")
        return("");
 	if (iUBB==2)
		return(HTMLencode(content));
	if (iUBB==9)
		return(content);
	var re;
	content=ChkBadWords(content);
    content=server.htmlencode(content);
	re=/(\&amp\;)(#[0-9]{4,5}\;)/ig;
	content=content.replace(re,"&$2");

	if(SetUBB(iType,66,1)==true)
	{ 

		content=LimitReturns(content); //合并多个回车换行
		content=ConvertReturns(content); //转换回车换行为html代码
		
		//转换换行回车后最先匹配 [html]标签,替换其内部的[ ]<br><p>标记
		//5.1(.[^\[]*) 
		re=/(\[html\])(.[^\[]*)(\[\/html\])/ig;
		content=content.replace(re,function($0,$1,$2){
			$2=$2.replace(/\[/ig,"&#91;")	 //[
			$2=$2.replace(/\]/ig,"&#93;")	 //]
			$2=$2.replace(/\:/ig,"&#58;")	 //避免笑脸转换
			$2=$2.replace(/\<p>/ig,"\n\r\n") //还原文本窗换行
			$2=$2.replace(/\<br>/ig,"\n")	 //还原文本窗换行
			$2=$2.replace(/\./ig,"&#46;")
			//h104 H72 w119 w87 .46
			return "<p><span><textarea  cols=95 rows=12  WRAP=VIRTUAL  style=\"word-break:break-all;margin:1px;font-size:"+cssSet(4)+";FONT-FAMILY:'"+cssSet(3)+"','MS Shell Dlg';\">"+$2+"</textarea><br><input type=button class=btz value=运行代码 onclick=\"runCode();\"><font color="+colorSet(47)+" >&nbsp;(提示:可先修改代码后再按运行)</font></span><br>"})

		//加空格标记,为了匹配联结
		content=content.replace(/<br>/ig," <br> ");
		content=content.replace(/<p>/ig," <p> ");

		re=/(^|\s)((http|https|ftp|rtsp|mms):\/\/\S+)/ig; //不使用该句号避免匹配[html]之间的
		content=content.replace(re,"$1<img src=syspic/url.gif align=absmiddle><a href=\"$2\" target=_blank>$2<\/a>");
		re=/(^|\s)(www\.\S+)/ig;
		content=content.replace(re,"$1<img src=syspic/url.gif align=absmiddle><a href=\"http:\/\/$2\" target=_blank>$2<\/a>");

		content=content.replace(/\s<br>\s/ig,"<br>");
		content=content.replace(/\s<p>\s/ig,"<p>");
		//content=content.replace(/&#46;/ig,".");
		//删除空格标记
	}
	else
	{
		re=/(^|\s)((http|https|ftp|rtsp|mms):\/\/\S+)/ig; //不使用该句号避免匹配[html]之间的
		content=content.replace(re,"$1<img src=syspic/url.gif align=absmiddle><a href=\"$2\" target=_blank>$2<\/a>");
		re=/(^|\s)(www\.\S+)/ig;
		content=content.replace(re,"$1<img src=syspic/url.gif align=absmiddle><a href=\"http:\/\/$2\" target=_blank>$2<\/a>");
		content=LimitReturns(content); //合并多个回车换行
		content=ConvertReturns(content); //转换回车换行为html代码
	}

//===========================================================
	if(iType==0) //only post use 特殊功能帖
	{	
		var SeStr=new String(iReplyType);
		if ((boardSet(78)=="1")&&(SeStr.search(/-20-/i)>-1)){content=view_UBB(content,"reply");}
		if ((boardSet(79)=="1")&&(SeStr.search(/-21-/i)>-1)){content=view_UBB(content,"master");}
		if ((boardSet(80)=="1")&&(SeStr.search(/-22-/i)>-1)){content=view_UBB(content,"bmaster");}
		if ((boardSet(81)=="1")&&(SeStr.search(/-23-/i)>-1)){content=view_UBB(content,"suser");}
		if ((boardSet(82)=="1")&&(SeStr.search(/-24-/i)>-1)){content=view_UBB(content,"founduser");}
		if ((boardSet(83)=="1")&&(SeStr.search(/-15-/i)>-1)){content=Fazi_UBB(content,"name",UserName);}
		//if ((boardSet(84)=="1")&&(SeStr.search(/-17-/i)>-1)){content=Fazi_UBB(content,"unhide",UserName);}
		content=Fazi_UBB(content,"unhide",UserName);
		if ((boardSet(85)=="1")&&(SeStr.search(/-16-/i)>-1)){content=umoney_UBB(content,"umoney",GetIDstr,replyID,UserName);}
		if ((boardSet(86)=="1")&&(SeStr.search(/-10-/i)>=0)){content=Fazi_UBB(content,"points",myUserCP);}
		if ((boardSet(87)=="1")&&(SeStr.search(/-11-/i)>-1)){content=Fazi_UBB(content,"score",myUserEP);}
		if ((boardSet(88)=="1")&&(SeStr.search(/-12-/i)>-1)){content=Fazi_UBB(content,"iworks",myIworks);}
		if ((boardSet(89)=="1")&&(SeStr.search(/-13-/i)>-1)){content=Fazi_UBB(content,"article",myArticle);}
		if ((boardSet(90)=="1")&&(SeStr.search(/-14-/i)>-1)){content=Fazi_UBB(content,"logins",myLogins);}
	}
///////////==================================================

	if(boardSet(14)=="1") 
		{
		if (!(iUBB==1))
		{content=Smilies(content);}
		}
	if (iUBB==3)
		return(content);//没有基本UBB代码则不做一下匹配变换

	re=/(\[URL\])(http|https|ftp|rtsp|mms)(:\/\/.[^\[]*)(\[\/URL\])/ig;
	content=content.replace(re,"<a href=\"$2$3\" target=_blank>$2$3<\/a>");
	re=/(\[URL\])(\S+)(\[\/URL\])/ig;
	content=content.replace(re,"<a href=\"http:\/\/$2\" target=_blank>$2<\/a>");

	//email with descript
    re=/(\[EMAIL=)(\S+\@\S+)(\])(.[^\[]*)(\[\/EMAIL\])/ig;
    content=content.replace(re,"<a href=\"mailto:$2\">$4<\/a>");
    re=/(\[EMAIL\])(\S+\@\S+)(\[\/EMAIL\])/ig;
    content=content.replace(re,"<a href=\"mailto:$2\">$2<\/a>");
    
	re=/(\[code\])(.[^\[]*)(\[\/code\])/ig;
    content=content.replace(re,"<br><table bgcolor="+colorSet(40)+" width=\"100\%\" ><tr><td style=\"FONT-FAMILY:'"+cssSet(3)+"','MS Shell Dlg';font-size:"+cssSet(4)+";padding:2px;\" width=\"98\%\"><FieldSet style=\"padding:10px;\"><Legend>代码(code)</Legend><font face=\"Verdana, Arial, Helvetica, sans-serif\">$2</font></FieldSet></td></tr></table>");
	
	if(SetUBB(iType,63,1)==true)	
	{	//联结类型图片	
		re=/(\[URL=)(.[^\[]*)(\])(\[IMG\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/IMG\])(\[\/URL\])/ig;
		content=content.replace(re,"<a href=\"$2\" target=_blank><img src=\"$5$6\" alt=\"点击打开联结$2\" border=0 onerror=\"this.src='syspic/imgerr.gif';this.width=90;this.height=32;this.border=0;\"></a>");
		re=/(\[URL=)(.[^\[]*)(\])(\[IMG W=)(\d+)( B=)(\d+)(\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/IMG\])(\[\/URL\])/ig;
		content=content.replace(re,"<a href=\"$2\" target=_blank><img src=\"$9$10\" width=\"$5\" border=\"$7\" alt=\"点击打开联结$2\" style=\"border: $7px solid #000000;\" onerror=\"this.src='syspic/imgerr.gif';this.width=90;this.height=32;this.border=0;\"></a>");
		
		re=    /(\[IMG\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/IMG\])/ig;
		content=content.replace(re,"<a href=\"$2$3\" target=_blank><img src=\"$2$3\" border=0 alt=\"当前为原尺寸图\"  onerror=\"this.src='syspic/imgerr.gif'\"></a>");
		
		re=/(\[IMG W=)(\d+)( B=)(\d+)(\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/IMG\])/ig;
		content=content.replace(re,"<a href=\"$6$7\" target=_blank><img src=\"$6$7\" width=\"$2\" border=\"$4\" alt=\"点击打开原尺寸图\" style=\"border: $7px solid #000000;\" onerror=\"this.src='syspic/imgerr.gif';this.width=90;this.height=32;this.border=0;\"></a>");
	}
	
	if(SetUBB(iType,62,1)==true)	
	{
		re=    /(\[SOUND\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/SOUND\])/ig;
		content=content.replace(re,"<a href=\"$2$3\" target=_blank><IMG SRC=syspic/music.gif border=0 alt=\"背景音乐\"></a><bgsound src=\"$2$3\" loop=\"-1\">");
	}

	/*单对tag匹配
	re=    /(\[QUOTE\])(.[^\[]*)(\[\/QUOTE\])/ig;
    content=content.replace(re,"<BLOCKQUOTE>引用:<hr size=1>$2<hr size=1><\/BLOCKQUOTE>");
    */
	
	//单个tag匹配
	re=    /(\[QUOTE\])/ig;
    content=content.replace(re,"<BLOCKQUOTE>引用:<hr size=1 color="+colorSet(22)+">");
	re=    /(\[\/QUOTE\])/ig;
    content=content.replace(re,"<hr size=1 color="+colorSet(22)+"><\/BLOCKQUOTE>");
	
    re=/(\[c\])/ig;
    content=content.replace(re,"&copy;");
    re=/(\[hr\])/ig;
    content=content.replace(re,"<hr size=1 color="+colorSet(22)+">");
	re=/(\[hr=)(\S+)(\])/ig;
    content=content.replace(re,"<hr color=\"$2\" size=1>");

//匹配顺序 !!
//[b][i][u][font][size][color][url=]
	re=/(\[b\])(.[^\[]*)(\[\/b\])/ig;
    content=content.replace(re,"<b>$2<\/b>");
	re=/(\[i\])(.[^\[]*)(\[\/i\])/ig;
    content=content.replace(re,"<I>$2<\/I>");
    re=    /(\[u\])(.[^\[]*)(\[\/u\])/ig;
    content=content.replace(re,"<u>$2<\/u>");
	//ok
	re=/(\[font=)(.[^\[]*)(\])(.[^\[]*)(\[\/font\])/ig;
    content=content.replace(re,"<font face=\"$2\">$4<\/font>");
	re=/(\[size=)(\S+)(\])(.[^\[]*)(\[\/size])/ig;
    content=content.replace(re,"<font style=\'font-family:\"Courier New\";font-size: $2px;line-height:125%;\'>$4<\/font>");
	re=/(\[color=)(\S+)(\])(.[^\[]*)(\[\/color\])/ig;
    content=content.replace(re,"<font color=\"$2\">$4<\/font>");
 	re=/(\[bgcolor=)(\S+)(\])(.[^\[]*)(\[\/bgcolor\])/ig;
    content=content.replace(re,"<div style=\"background-color: $2;padding: 6px;\">$4<\/div>");
   
	//S+在之后
	re=/(\[URL=)(http|https|ftp|rtsp|mms)(:\/\/.[^\[]*)(\])(.[^\[]*)(\[\/URL\])/ig;
    content=content.replace(re,"<a href=\"$2$3\" target=_blank>$5<\/a>");
    re=/(\[URL=)(\S+)(\])(.[^\[]*)(\[\/URL\])/ig;
    content=content.replace(re,"<a href=\"http:\/\/$2\" target=_blank>$4<\/a>");
   
   //download    
    re=/(\[download=)(http|https|ftp)(:\/\/.[^\[]*)(\])(.[^\[]*)(\[\/download\])/ig;
    content=content.replace(re,"<a href=\"$2$3\" ><img src=syspic/download.gif border=0 align=absmiddle> $5<\/a>");
	
	
	re=    /(\[list\])(.[^\[]*)(\[\/list\])/ig;
    content=content.replace(re,"<UL TYPE=SQUARE>$2<\/UL>");
    re=/(\[list=)(A|1)(\])(.[^\[]*)(\[\/list\])/ig;
    content=content.replace(re,"<OL TYPE=$2>$4<\/OL>");
    re=/(\[\*\])/ig;
    content=content.replace(re,"<LI>");
   
// (\S+)匹配不包括空格
// (.[^\[]*) 匹配包括空格
    
	//ok
	re=    /(\[h1\])(.[^\[]*)(\[\/h1\])/ig;
    content=content.replace(re,"<h1>$2<\/h1>");
    re=/(\[h2\])(.[^\[]*)(\[\/h2\])/ig;
    content=content.replace(re,"<h2>$2<\/h2>");
    re=    /(\[h3\])(.[^\[]*)(\[\/h3\])/ig;
    content=content.replace(re,"<h3>$2<\/h3>");
    re=/(\[h4\])(.[^\[]*)(\[\/h4\])/ig;
    content=content.replace(re,"<h4>$2<\/h4>");
    re=/(\[h5\])(.[^\[]*)(\[\/h5\])/ig;
    content=content.replace(re,"<h5>$2<\/h5>");
    re=/(\[h6\])(.[^\[]*)(\[\/h6\])/ig;
    content=content.replace(re,"<h6>$2<\/h6>");

	//ok
    re=/(\[sup\])(.[^\[]*)(\[\/sup\])/ig;
    content=content.replace(re,"<sup>$2<\/sup>");
    re=    /(\[sub\])(.[^\[]*)(\[\/sub\])/ig;
    content=content.replace(re,"<sub>$2<\/sub>");

	//ok
    re=/(\[center\])(.[^\[]*)(\[\/center\])/ig;
    content=content.replace(re,"<center>$2<\/center>");
    //left
    re=/(\[left\])(.[^\[]*)(\[\/left\])/ig;
    content=content.replace(re,"<div align=left>$2<\/div>");
    //right
    re=/(\[right\])(.[^\[]*)(\[\/right\])/ig;
    content=content.replace(re,"<div align=right>$2<\/div>");
    
	//ok
	//pre
	re=/(\[pre\])(.[^\[]*)(\[\/pre\])/ig;
    content=content.replace(re,"<pre>$2<\/pre>");
    
	if(SetUBB(iType,67,0)==true)
	{
		re=/(\[w\])(http|https|ftp)(:\/\/.[^\[]*)(\[\/w\])/ig;
		content=content.replace(re,"<iframe FRAMEBORDER=1 ALIGN=CENTER width=100\% HEIGHT=400 SCROLLING=YES SRC=\"$2$3\"></iframe><br><a href=\"$2$3\" target=_blank><b><font color="+colorSet(3)+">点这儿参观页面</font></b><\/a>");
	}
	//ok
	if(SetUBB(iType,64,1)==true)	
	{
	//flash   
		re=/(\[flash\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/flash\])/ig;
		content=content.replace(re,"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codeBase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=4,0,2,0\" width=500 height=500><param name=movie value=\"$2$3\"><param name=quality value=high><embed src=\"$2$3\" 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>");
		re=/(\[flash W=)(\d+)( H=)(\d+)(\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/flash\])/ig;
		content=content.replace(re,"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codeBase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=4,0,2,0\" width=\"$2\" height=\"$4\"><param name=movie value=\"$6$7\"><param name=quality value=high><embed src=\"$6$7\" quality=high pluginspage=\"http:\/\/www.macromedia.com\/shockwave\/download\/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application\/x-shockwave-flash\" width=\"$2\" height=\"$4\"><\/embed><\/object>");
		re=/(\[flash W=)(\d+)( H=)(\d+)(\])(\S+)(\[\/flash\])/ig;
		content=content.replace(re,"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codeBase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=4,0,2,0\" width=\"$2\" height=\"$4\"><param name=movie value=\"http:\/\/$6\"><param name=quality value=high><embed src=\"http:\/\/$6\" quality=high pluginspage=\"http:\/\/www.macromedia.com\/shockwave\/download\/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application\/x-shockwave-flash\" width=\"$2\" height=\"$4\"><\/embed><\/object>");
		//shockwave
		re=/(\[shock\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/shock\])/ig;
		content=content.replace(re,"<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=500 height=500><param name=src value=\"$2$3\"><embed src=value=\"$2$3\" pluginspage=http:\/\/www.macromedia.com\/shockwave\/download\/  width=500 height=500><\/embed><\/object>");
		re=/(\[shock W=)(\d+)( H=)(\d+)(\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/shock\])/ig;
		content=content.replace(re,"<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=\"$2\" height=\"$4\"><param name=\"src\" value=\"$6$7\"><embed src=\"$6$7\" pluginspage=http:\/\/www.macromedia.com\/shockwave\/download\/ width=\"$2\" height=\"$4\"><\/embed><\/object>");
	}

	//ok
	if(SetUBB(iType,65,1)==true)	
	{
		//视频	
		re=/(\[qt W=)(\d+)( H=)(\d+)(\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/qt\])/ig;
		content=content.replace(re,"<embed src=\"$6$7\" width=$2 height=$4 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=/(\[mp W=)(\d+)( H=)(\d+)(\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/mp\])/ig;
		content=content.replace(re,"<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=$2 height=$4 ><param name=ShowStatusBar value=-1><param name=Filename value=\"$6$7\"><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=$4><\/embed><\/object>");
		re=/(\[rm W=)(\d+)( H=)(\d+)(\])(http|https|ftp|mms)(:\/\/.[^\[]*)(\[\/rm\])/ig;
		content=content.replace(re,"<OBJECT classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" class=\"OBJECT\" id=\"RAOCX\" width=\"$2\" height=\"$4\"><PARAM NAME=\"SRC\" value=\"$6$7\"><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=$2><PARAM NAME=SRC VALUE=\"$6$7\"><PARAM NAME=AUTOSTART VALUE=-1><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1><\/OBJECT>");
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -