ubb代码

来自csdn的小虫
char.asp
<%
function doCode(fString, fOTag, fCTag, fROTag, fRCTag)
 fOTagPos = Instr(1, fString, fOTag, 1)
 fCTagPos = Instr(1, fString, fCTag, 1)
 while (fCTagPos > 0 and fOTagPos > 0)
  fString = replace(fString, fOTag, fROTag, 1, 1, 1)
  fString = replace(fString, fCTag, fRCTag, 1, 1, 1)
  fOTagPos = Instr(1, fString, fOTag, 1)
  fCTagPos = Instr(1, fString, fCTag, 1)
 wend
 doCode = fString
end function

function HTMLEncode(fString)

 fString = replace(fString, ">", "&gt;")
 fString = replace(fString, "<", "&lt;")

 fString = Replace(fString, CHR(13), "")
 fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
 fString = Replace(fString, CHR(10), "<BR>")
 HTMLEncode = fString
end function

function HTMLEncode2(fString)
 fString = Replace(fString, CHR(13), "")
 fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
 fString = Replace(fString, CHR(10), "<BR>")
 HTMLEncode2 = fString
end function

function UBBCode(strContent)
 on error resume next
 strContent = HTMLEncode(strContent)
 dim objRegExp
 Set objRegExp=new RegExp
 objRegExp.IgnoreCase =true
 objRegExp.Global=True

 objRegExp.Pattern="(/[URL/])(.*)(/[//URL/])"
 strContent= objRegExp.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")

 objRegExp.Pattern="(/[URL=(.*)/])(.*)(/[//URL/])"
 strContent= objRegExp.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$3</A>")

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

 
 objRegExp.Pattern="(/[FLASH/])(.*)(/[//FLASH/])"
 strContent= objRegExp.Replace(strContent,"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400><PARAM NAME=movie VALUE=""$2""><PARAM NAME=quality VALUE=high><embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400>$2</embed></OBJECT>")
 

 objRegExp.Pattern="(/[IMG/])(.*)(/[//IMG/])"
 strContent=objRegExp.Replace(strContent,"<IMG SRC=""$2"" border=0>")

        objRegExp.Pattern="(/[HTML/])(.*)(/[//HTML/])"
 strContent=objRegExp.Replace(strContent,"<SPAN><p><IMG src=pic/code.gif align=absBottom>该篇文章附带的 HTML 代码片段如下:<BR><TEXTAREA style=""WIDTH: 94%; BACKGROUND-COLOR: #f7f7f7"" name=textfield rows=10>$2</TEXTAREA><BR><INPUT οnclick=runEx() type=button value=运行此代码 name=Button> [Ctrl+A 全部选择   提示:你可先修改部分代码,再按运行]</SPAN><BR>")

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

 objRegExp.Pattern="(/[QUOTE/])(.*)(/[//QUOTE/])"
 strContent=objRegExp.Replace(strContent,"<BLOCKQUOTE><font size=1 face=""Verdana, Arial"">quote:</font><HR>$2<HR></BLOCKQUOTE>")
 objRegExp.Pattern="(/[fly/])(.*)(/[//fly/])"
 strContent=objRegExp.Replace(strContent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
 objRegExp.Pattern="(/[move/])(.*)(/[//move/])"
 strContent=objRegExp.Replace(strContent,"<MARQUEE scrollamount=3>$2</marquee>")
 objRegExp.Pattern="(/[glow=(.*),(.*),(.*)/])(.*)(/[//glow/])"
 strContent=objRegExp.Replace(strContent,"<table width=$2 style=""filter:glow(color=$3, strength=$4)"">$5</table>")
 objRegExp.Pattern="(/[SHADOW=(.*),(.*),(.*)/])(.*)(/[//SHADOW/])"
 strContent=objRegExp.Replace(strContent,"<table width=$2 style=""filter:shadow(color=$3, direction=$4)"">$5</table>")
   
 objRegExp.Pattern="(/[i/])(.*)(/[//i/])"
 strContent=objRegExp.Replace(strContent,"<i>$2</i>")
 objRegExp.Pattern="(/[u/])(.*)(/[//u/])"
 strContent=objRegExp.Replace(strContent,"<u>$2</u>")
 objRegExp.Pattern="(/[b/])(.*)(/[//b/])"
 strContent=objRegExp.Replace(strContent,"<b>$2</b>")
 objRegExp.Pattern="(/[fly/])(.*)(/[//fly/])"
 strContent=objRegExp.Replace(strContent,"<marquee>$2</marquee>")

 objRegExp.Pattern="(/[size=1/])(.*)(/[//size/])"
 strContent=objRegExp.Replace(strContent,"<font size=1>$2</font>")
 objRegExp.Pattern="(/[size=2/])(.*)(/[//size/])"
 strContent=objRegExp.Replace(strContent,"<font size=2>$2</font>")
 objRegExp.Pattern="(/[size=3/])(.*)(/[//size/])"
 strContent=objRegExp.Replace(strContent,"<font size=3>$2</font>")
 objRegExp.Pattern="(/[size=4/])(.*)(/[//size/])"
 strContent=objRegExp.Replace(strContent,"<font size=4>$2</font>")

 strContent = doCode(strContent, "[list]", "[/list]", "<ul>", "</ul>")
 strContent = doCode(strContent, "[list=1]", "[/list]", "<ol type=1>", "</ol id=1>")
 strContent = doCode(strContent, "[list=a]", "[/list]", "<ol type=a>", "</ol id=a>")
 strContent = doCode(strContent, "[*]", "[/*]", "<li>", "</li>")
 strContent = doCode(strContent, "[code]", "[/code]", "<pre id=code><font size=1 face=""Verdana, Arial"" id=code>", "</font id=code></pre id=code>")

 set objRegExp=Nothing
 UBBCode=strContent
end function

public function translate(sourceStr,fieldStr)
rem 处理逻辑表达式的转化问题
  dim  sourceList
  dim resultStr
  dim i,j
  if instr(sourceStr," ")>0 then
     dim isOperator
     isOperator = true
     sourceList=split(sourceStr)
'--------------------------------------------------------
     rem Response.Write "num:" & cstr(ubound(sourceList)) & "<br>"
     for i = 0 to ubound(sourceList)
        rem Response.Write i
 Select Case ucase(sourceList(i))
 Case "AND","&","和","与"
  resultStr=resultStr & " and "
  isOperator = true
 Case "OR","|","或"
  resultStr=resultStr & " or "
  isOperator = true
 Case "NOT","!","非","!","!"
  resultStr=resultStr & " not "
  isOperator = true
 Case "(","(","("
  resultStr=resultStr & " ( "
  isOperator = true
 Case ")",")",")"
  resultStr=resultStr & " ) "
  isOperator = true
 Case Else
  if sourceList(i)<>"" then
   if not isOperator then resultStr=resultStr & " and "
   if inStr(sourceList(i),"%") > 0 then
    resultStr=resultStr&" "&fieldStr& " like '" & replace(sourceList(i),"'","''") & "' "
   else
    resultStr=resultStr&" "&fieldStr& " like '%" & replace(sourceList(i),"'","''") & "%' "
   end if
          isOperator=false
  End if 
 End Select
        rem Response.write resultStr+"<br>"
     next
     translate=resultStr
  else '单条件
     if inStr(sourcestr,"%") > 0 then
      translate=" " & fieldStr & " like '" & replace(sourceStr,"'","''") &"' "
     else
 translate=" " & fieldStr & " like '%" & replace(sourceStr,"'","''") &"%' "
     End if
     rem 前后各加一个空格,免得连sql时忘了加,而出错。
  end if 
end function

function IsValidEmail(email)

dim names, name, i, c

'Check for valid syntax in an email address.

IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
   IsValidEmail = false
   exit function
end if
for each name in names
   if Len(name) <= 0 then
     IsValidEmail = false
     exit function
   end if
   for i = 1 to Len(name)
     c = Lcase(Mid(name, i, 1))
     if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
       IsValidEmail = false
       exit function
     end if
   next
   if Left(name, 1) = "." or Right(name, 1) = "." then
      IsValidEmail = false
      exit function
   end if
next
if InStr(names(1), ".") <= 0 then
   IsValidEmail = false
   exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsValidEmail = false
   exit function
end if
if InStr(email, "..") > 0 then
   IsValidEmail = false
end if

end function
%>
<SCRIPT LANGUAGE="JavaScript">

helpstat = false;
stprompt = true;
basic = false;
function thelp(swtch){
 if (swtch == 1){
  basic = false;
  stprompt = false;
  helpstat = true;
 } else if (swtch == 0) {
  helpstat = false;
  stprompt = false;
  basic = true;
 } else if (swtch == 2) {
  helpstat = false;
  basic = false;
  stprompt = true;
 }
}

function AddText(NewCode) {
document.myform.txtcontent.value+=NewCode
}

function email() {
 if (helpstat) {
  alert("Email 标记/n插入 Email 超级链接/n用法1: [email]cn_master@etang.com[/email]/n用法2: [email=cn_master@etang.com]个性小子[/email]");
 } else if (basic) {
  AddTxt="[email][/email]";
  AddText(AddTxt);
 } else {
  txt2=prompt("链接显示的文字./n如果为空,那么将只显示你的 Email 地址","");
  if (txt2!=null) {
   txt=prompt("Email 地址.","name@domain.com");     
   if (txt!=null) {
    if (txt2=="") {
     AddTxt="[email]"+txt+"[/email]";
    } else {
     AddTxt="[email="+txt+"]"+txt2;
     AddText(AddTxt);
     AddTxt="[/email]";
    }
    AddText(AddTxt);        
   }
  }
 }
}
function flash() {
  if (helpstat){
  alert("Flash 动画/n插入 Flash 动画./n用法: [flash]Flash 文件的地址[/flash]");
 } else if (basic) {
  AddTxt="[flash][/flash]";
  AddText(AddTxt);
 } else {                 
  txt=prompt("Flash 文件的地址","http://");
  if (txt!=null) {            
   AddTxt="[flash]"+txt;
   AddText(AddTxt);
   AddTxt="[/flash]";
   AddText(AddTxt);
  }       
 } 
}

function showsize(size) {
 if (helpstat) {
  alert("文字大小标记/n设置文字大小./n可变范围 1 - 6./n 1 为最小 6 为最大./n用法: [size="+size+"]这是 "+size+" 文字[/size]");
 } else if (basic) {
  AddTxt="[size="+size+"][/size]";
  AddText(AddTxt);
 } else {                      
  txt=prompt("大小 "+size,"文字");
  if (txt!=null) {            
   AddTxt="[size="+size+"]"+txt;
   AddText(AddTxt);
   AddTxt="[/size]";
   AddText(AddTxt);
  }       
 }
}

function bold() {
 if (helpstat) {
  alert("加粗标记/n使文本加粗./n用法: [b]这是加粗的文字[/b]");
 } else if (basic) {
  AddTxt="[b][/b]";
  AddText(AddTxt);
 } else { 
  txt=prompt("文字将被变粗.","文字");    
  if (txt!=null) {          
   AddTxt="[b]"+txt;
   AddText(AddTxt);
   AddTxt="[/b]";
   AddText(AddTxt);
  }      
 }
}

function italicize() {
 if (helpstat) {
  alert("斜体标记/n使文本字体变为斜体./n用法: [i]这是斜体字[/i]");
 } else if (basic) {
  AddTxt="[i][/i]";
  AddText(AddTxt);
 } else {  
  txt=prompt("文字将变斜体","文字");    
  if (txt!=null) {          
   AddTxt="[i]"+txt;
   AddText(AddTxt);
   AddTxt="[/i]";
   AddText(AddTxt);
  }        
 }
}

function quote() {
 if (helpstat){
  alert("引用标记/n引用一些文字./n用法: [quote]引用内容[/quote]");
 } else if (basic) {
  AddTxt="[quote][/quote]";
  AddText(AddTxt);
 } else {  
  txt=prompt("被引用的文字","文字");    
  if(txt!=null) {         
   AddTxt="[quote]"+txt;
   AddText(AddTxt);
   AddTxt="[/quote]";
   AddText(AddTxt);
  }        
 }
}

function showcolor(color) {
 if (helpstat) {
  alert("颜色标记/n设置文本颜色.  任何颜色名都可以被使用./n用法: [color="+color+"]颜色要改变为"+color+"的文字[/color]");
 } else if (basic) {
  AddTxt="[color="+color+"][/color]";
  AddText(AddTxt);
 } else { 
      txt=prompt("选择的颜色是: "+color,"文字");
  if(txt!=null) {
   AddTxt="[color="+color+"]"+txt;
   AddText(AddTxt);       
   AddTxt="[/color]";
   AddText(AddTxt);
  }
 }
}

function center() {
  if (helpstat) {
  alert("对齐标记/n使用这个标记, 可以使文本左对齐、居中、右对齐./n用法: [align=center|left|right]要对齐的文本[/align]");
 } else if (basic) {
  AddTxt="[align=center|left|right][/align]";
  AddText(AddTxt);
 } else { 
  txt2=prompt("对齐样式/n输入 'center' 表示居中, 'left' 表示左对齐, 'right' 表示右对齐.","center");              
  while ((txt2!="") && (txt2!="center") && (txt2!="left") && (txt2!="right") && (txt2!=null)) {
   txt2=prompt("错误!/n类型只能输入 'center' 、 'left' 或者 'right'.","");              
  }
  txt=prompt("要对齐的文本","文本");    
  if (txt!=null) {         
   AddTxt="/r[align="+txt2+"]"+txt;
   AddText(AddTxt);
   AddTxt="[/align]";
   AddText(AddTxt);
  }       
 }
}

function hyperlink() {
 if (helpstat) {
  alert("超级链接标记/n插入一个超级链接标记/n使用方法: [url]http://www.aspsky.net[/url]/nUSE: [url=http://www.aspsky.net]链接文字[/url]");
 } else if (basic) {
  AddTxt="[url][/url]";
  AddText(AddTxt);
 } else {
  txt2=prompt("链接文本显示./n如果不想使用, 可以为空, 将只显示超级链接地址. ","");
  if (txt2!=null) {
   txt=prompt("超级链接.","http://");     
   if (txt!=null) {
    if (txt2=="") {
     AddTxt="[url]"+txt;
     AddText(AddTxt);
     AddTxt="[/url]";
     AddText(AddTxt);
    } else {
     AddTxt="[url="+txt+"]"+txt2;
     AddText(AddTxt);
     AddTxt="[/url]";
     AddText(AddTxt);
    }        
   }
  }
 }
}

function image() {
 if (helpstat){
  alert("图片标记/n插入图片/n用法: [img]http://www.aspsky.net/logo.gif[/img]");
 } else if (basic) {
  AddTxt="[img][/img]";
  AddText(AddTxt);
 } else { 
  txt=prompt("图片的 URL","http://");   
  if(txt!=null) {           
   AddTxt="/r[img]"+txt;
   AddText(AddTxt);
   AddTxt="[/img]";
   AddText(AddTxt);
  } 
 }
}

function showcode() {
 if (helpstat) {
  alert("代码标记/n使用代码标记,可以使你的程序代码里面的 html 等标志不会被破坏./n使用方法:/n [code]这里是代码文字[/code]");
 } else if (basic) {
  AddTxt="/r[code]/r[/code]";
  AddText(AddTxt);
 } else {  
  txt=prompt("输入代码","");    
  if (txt!=null) {         
   AddTxt="/r[code]"+txt;
   AddText(AddTxt);
   AddTxt="[/code]";
   AddText(AddTxt);
  }       
 }
}

function list() {
 if (helpstat) {
  alert("列表标记/n建造一个文字或则数字列表./n/nUSE: [list] [*]项目一[/*] [*]项目二[/*] [*]项目三[/*] [/list]");
 } else if (basic) {
  AddTxt=" [list][*]  [/*][*]  [/*][*]  [/*][/list]";
  AddText(AddTxt);
 } else { 
  txt=prompt("列表类型/n输入 'A' 表示有序列表, '1' 表示无序列表, 留空表示无序列表.","");              
  while ((txt!="") && (txt!="A") && (txt!="a") && (txt!="1") && (txt!=null)) {
   txt=prompt("错误!/n类型只能输入 'A' 、 '1' 或者留空.","");              
  }
  if (txt!=null) {
   if (txt=="") {
    AddTxt="[list]";
   } else {
    AddTxt="[list="+txt+"]";
   }
   txt="1";
   while ((txt!="") && (txt!=null)) {
    txt=prompt("列表项/n空白表示结束列表","");
    if (txt!="") {            
     AddTxt+="[*]"+txt+"[/*]";
    }                  
   }
   AddTxt+="[/list] ";
   AddText(AddTxt);
  }
 }
}

function showfont(font) {
  if (helpstat){
  alert("字体标记/n给文字设置字体./n用法: [face="+font+"]改变文字字体为"+font+"[/face]");
 } else if (basic) {
  AddTxt="[face="+font+"][/face]";
  AddText(AddTxt);
 } else {                 
  txt=prompt("要设置字体的文字"+font,"文字");
  if (txt!=null) {            
   AddTxt="[face="+font+"]"+txt;
   AddText(AddTxt);
   AddTxt="[/face]";
   AddText(AddTxt);
  }       
 } 
}
function underline() {
   if (helpstat) {
  alert("下划线标记/n给文字加下划线./n用法: [u]要加下划线的文字[/u]");
 } else if (basic) {
  AddTxt="[u][/u]";
  AddText(AddTxt);
 } else { 
  txt=prompt("下划线文字.","文字");    
  if (txt!=null) {          
   AddTxt="[u]"+txt;
   AddText(AddTxt);
   AddTxt="[/u]";
   AddText(AddTxt);
  }        
 }
}
function setfly() {
  if (helpstat){
  alert("飞翔标记/n使文字飞行./n用法: [fly]文字为这样文字[/fly]");
 } else if (basic) {
  AddTxt="[fly][/fly]";
  AddText(AddTxt);
 } else {                 
  txt=prompt("飞翔文字","文字");
  if (txt!=null) {            
   AddTxt="[fly]"+txt;
   AddText(AddTxt);
   AddTxt="[/fly]";
   AddText(AddTxt);
  }       
 } 
}

function move() {
 if (helpstat) {
  alert("移动标记/n使文字产生移动效果./n用法: [move]要产生移动效果的文字[/move]");
 } else if (basic) {
  AddTxt="[move][/move]";
  AddText(AddTxt);
 } else { 
  txt=prompt("要产生移动效果的文字","文字");    
  if (txt!=null) {          
   AddTxt="[move]"+txt;
   AddText(AddTxt);
   AddTxt="[/move]";
   AddText(AddTxt);
  }      
 }
}

function shadow() {
 if (helpstat) {
               alert("阴影标记/n使文字产生阴影效果./n用法: [SHADOW=宽度, 颜色, 边界]要产生阴影效果的文字[/SHADOW]");
 } else if (basic) {
  AddTxt="[SHADOW=255,blue,1][/SHADOW]";
  AddText(AddTxt);
 } else {
  txt2=prompt("文字的长度、颜色和边界大小","255,blue,1");
  if (txt2!=null) {
   txt=prompt("要产生阴影效果的文字","文字");
   if (txt!=null) {
    if (txt2=="") {
     AddTxt="[SHADOW=255, blue, 1]"+txt;
     AddText(AddTxt);
     AddTxt="[/SHADOW]";
     AddText(AddTxt);
    } else {
     AddTxt="[SHADOW="+txt2+"]"+txt;
     AddText(AddTxt);
     AddTxt="[/SHADOW]";
     AddText(AddTxt);
    }        
   }
  }
 }
}

function glow() {
 if (helpstat) {
  alert("光晕标记/n使文字产生光晕效果./n用法: [GLOW=宽度, 颜色, 边界]要产生光晕效果的文字[/GLOW]");
 } else if (basic) {
  AddTxt="[glow=255,red,2][/glow]";
  AddText(AddTxt);
 } else {
  txt2=prompt("文字的长度、颜色和边界大小","255,red,2");
  if (txt2!=null) {
   txt=prompt("要产生光晕效果的文字.","文字");     
   if (txt!=null) {
    if (txt2=="") {
     AddTxt="[glow=255,red,2]"+txt;
     AddText(AddTxt);
     AddTxt="[/glow]";
     AddText(AddTxt);
    } else {
     AddTxt="[glow="+txt2+"]"+txt;
     AddText(AddTxt);
     AddTxt="[/glow]";
     AddText(AddTxt);
    }        
   }
  }
 }
}
function openscriphtml()
{
if (navigator.appName!="Microsoft Internet Explorer")
   alert("此功能 Netscape 用户不能使用!")
else
   {newwin=window.open('htmledit/editor.html','','width=544,height=294');
    newwin.focus();
   }
}
function runEx(){
//alert('请注意,按下确定将生成页面,按下后请稍后....');
var winEx = window.open("", "winEx", "width=600,height=400,status=yes,menubar=yes,scrollbars=yes,resizable=yes"); winEx.document.open("text/html", "replace");
winEx.document.write(unescape(event.srcElement.parentElement.children[2].value));
winEx.document.close();
}
function openScript(url, width, height) {
        var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );
}
</SCRIPT>
<script language="Javascript">
<!-- hide

function insertsmilie(smilieface){

 document.frmAnnounce.body.value+=smilieface;
}
// -->
</script>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值