home *** CD-ROM | disk | FTP | other *** search
/ 221.214.14.186 / 221.214.14.186.tar / 221.214.14.186 / zb / Notepad-zb / ubb.asp < prev    next >
Text File  |  2005-12-26  |  12KB  |  232 lines

  1. <%
  2. function UBBCode(strContent)
  3.     
  4.     dim re,i
  5.     strContent=encodestr(strContent)
  6.  
  7.     strContent=funkillWord(strContent)
  8.     UbbCode=strContent
  9.     if (instr(strContent,"[")=0 or instr(strContent,"]")=0) and instr(strContent,"http://")=0 then
  10.         exit function
  11.     end if
  12.     
  13.     Set re=new RegExp
  14.     re.IgnoreCase =true
  15.     re.Global=True
  16.     
  17.     '╣²┬╦script╩┬╝■
  18.     if instr(1,strContent,"on",1)>0 then
  19.         re.Pattern="on(\w+)="
  20.         strContent=re.Replace(strContent,"on_$1=")
  21.     end if
  22.     strContent=Replace(strContent,"file:","file :")
  23.     strContent=Replace(strContent,"files:","files :")
  24.     strContent=Replace(strContent,"script:","script :")
  25.     strContent=Replace(strContent,"js:","js :")
  26.     
  27.     
  28.     if instr(1,strContent,"[IMG]",1)>0 then
  29.         re.Pattern="(\[IMG\])(.[^\[]*)(\[\/IMG\])"
  30.         if imgUbb then
  31.             strContent=re.Replace(strContent,"<a href=""$2"" target=_blank><IMG SRC=""$2"" border=0 alt=░┤┤╦╘┌╨┬┤░┐┌Σ»└└═╝╞¼ onload=""javascript:if(this.width>500)this.width=500""></a> ")
  32.         else
  33.             strContent=re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a href=""$2"" target=_blank>$2</a> ")
  34.         end if
  35.     end if
  36.     
  37.  
  38.     if instr( request.servervariables("url"),"show")>0 then
  39.         if instr(1,strContent,"[/dir]",1)>0 then
  40.             re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
  41.             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>")
  42.         end if
  43.         if instr(1,strContent,"[/qt]",1)>0 then
  44.             re.Pattern="\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
  45.             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/>")
  46.         end if
  47.         if instr(1,strContent,"[/mp]",1)>0 then
  48.             re.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
  49.             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>")
  50.         end if
  51.         if instr(1,strContent,"[/rm]",1)>0 then
  52.             re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
  53.             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>")
  54.         end if
  55.     else
  56.         if instr(1,strContent,"[/dir]",1)>0 then
  57.             re.Pattern="\[DIR=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/DIR]"
  58.             strContent=re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a href=$3 target=_blank>$3</a>")
  59.         end if
  60.         if instr(1,strContent,"[/qt]",1)>0 then
  61.             re.Pattern="\[QT=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/QT]"
  62.             strContent=re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a href=$3 target=_blank>$3</a>")
  63.         end if
  64.         if instr(1,strContent,"[/mp]",1)>0 then
  65.             re.Pattern="\[MP=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/MP]"
  66.             strContent=re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a href=$3 target=_blank>$3</a>")
  67.         end if
  68.         if instr(1,strContent,"[/rm]",1)>0 then
  69.             re.Pattern="\[RM=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/RM]"
  70.             strContent=re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a href=$3 target=_blank>$3</a>")
  71.         end if
  72.     end if
  73.     
  74.     if instr(1,strContent,"[flash]",1)>0 then
  75.         re.Pattern="(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"
  76.         strContent= re.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>")
  77.     end if
  78.     
  79.     if instr(1,strContent,"[/url]",1)>0 then
  80.         re.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"
  81.         strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")
  82.         re.Pattern="(\[URL=(.[^\]]*)\])(.[^\[]*)(\[\/URL\])"
  83.         strContent= re.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$3</A>")
  84.     end if
  85.     
  86.     if instr(1,strContent,"[/email]",1)>0 then
  87.         re.Pattern="(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"
  88.         strContent= re.Replace(strContent,"<img align=absmiddle src=images/email.gif><A HREF=""mailto:$2"">$2</A>")
  89.         re.Pattern="(\[EMAIL=(.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"
  90.         strContent= re.Replace(strContent,"<img align=absmiddle src=images/email.gif><A HREF=""mailto:$2"">$3</A>")
  91.     end if
  92.     
  93.     if instr(1,strContent,"http://",1)>0 then
  94.         re.Pattern = "^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
  95.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  96.         re.Pattern = "(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
  97.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  98.         
  99.         re.Pattern = "([^>=""])(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
  100.         strContent = re.Replace(strContent,"$1<img align=absmiddle src=images/url.gif><a target=_blank href=$2>$2</a>")
  101.     end if
  102.     
  103.     if instr(1,strContent,"ftp://",1)>0 then
  104.         re.Pattern = "^(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
  105.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  106.         re.Pattern = "(ftp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
  107.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  108.         re.Pattern = "([^>=""])(ftp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
  109.         strContent = re.Replace(strContent,"$1<img align=absmiddle src=images/url.gif><a target=_blank href=$2>$2</a>")
  110.     end if
  111.     
  112.     if instr(1,strContent,"rtsp://",1)>0 then
  113.         re.Pattern = "^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
  114.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  115.         re.Pattern = "(rtsp://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
  116.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  117.         re.Pattern = "([^>=""])(rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
  118.         strContent = re.Replace(strContent,"$1<img align=absmiddle src=images/url.gif><a target=_blank href=$2>$2</a>")
  119.     end if
  120.     
  121.     if instr(1,strContent,"mms://",1)>0 then
  122.         re.Pattern = "^(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)"
  123.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  124.         re.Pattern = "(mms://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$"
  125.         strContent = re.Replace(strContent,"<img align=absmiddle src=images/url.gif><a target=_blank href=$1>$1</a>")
  126.         re.Pattern = "([^>=""])(mms://[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)"
  127.         strContent = re.Replace(strContent,"$1<img align=absmiddle src=images/url.gif><a target=_blank href=$2>$2</a>")
  128.     end if
  129.     
  130.     're.Pattern="(\[HTML\])(.+?)(\[\/HTML\])"
  131.     'strContent=re.Replace(strContent,"<table width='100%' border='0' cellspacing='0' cellpadding='6' class=table002><td><b>╥╘╧┬─┌╚▌╬¬│╠╨≥┤·┬δ:</b><br>$2</td></table>")
  132.     
  133.     if instr(1,strContent,"[/color]",1)>0 then
  134.         re.Pattern="(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
  135.         strContent=re.Replace(strContent,"<font color=$2>$3</font>")
  136.     end if
  137.     if instr(1,strContent,"[/face]",1)>0 then
  138.         re.Pattern="(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
  139.         strContent=re.Replace(strContent,"<font face=$2>$3</font>")
  140.     end if
  141.     if instr(1,strContent,"[/align]",1)>0 then
  142.         re.Pattern="(\[align=(.[^\[]*)\])(.[^\[]*)(\[\/align\])"
  143.         strContent=re.Replace(strContent,"<div align=$2>$3</div>")
  144.     end if
  145.     
  146.     if instr(1,strContent,"[/quote]",1)>0 then
  147.         re.Pattern="(\[QUOTE\])(.[^\[]*)(\[\/QUOTE\])"
  148.         strContent=re.Replace(strContent,"<table cellpadding=5 cellspacing=1 border=0 WIDTH=94% class=table003 align=center><TR><TD class=table002>$2</td></tr></table><br>")
  149.     end if
  150.     if instr(1,strContent,"[/fly]",1)>0 then
  151.         re.Pattern="(\[fly\])(.[^\[]*)(\[\/fly\])"
  152.         strContent=re.Replace(strContent,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
  153.     end if
  154.     if instr(1,strContent,"[/move]",1)>0 then
  155.         re.Pattern="(\[move\])(.[^\[]*)(\[\/move\])"
  156.         strContent=re.Replace(strContent,"<MARQUEE scrollamount=3>$2</marquee>")    
  157.     end if
  158.     if instr(1,strContent,"[/glow]",1)>0 then
  159.         re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"
  160.         strContent=re.Replace(strContent,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
  161.     end if
  162.     if instr(1,strContent,"[/shadow]",1)>0 then
  163.         re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
  164.         strContent=re.Replace(strContent,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
  165.     end if
  166.     
  167.     if instr(1,strContent,"[/i]",1)>0 then
  168.         re.Pattern="(\[i\])(.[^\[]*)(\[\/i\])"
  169.         strContent=re.Replace(strContent,"<i>$2</i>")
  170.     end if
  171.     if instr(1,strContent,"[/u]",1)>0 then
  172.         re.Pattern="(\[u\])(.[^\[]*)(\[\/u\])"
  173.         strContent=re.Replace(strContent,"<u>$2</u>")
  174.     end if
  175.     if instr(1,strContent,"[/b]",1)>0 then
  176.         re.Pattern="(\[b\])(.[^\[]*)(\[\/b\])"
  177.         strContent=re.Replace(strContent,"<b>$2</b>")
  178.     end if
  179.     
  180.     if instr(1,strContent,"[/size]",1)>0 then
  181.         re.Pattern="(\[size=1\])(.[^\[]*)(\[\/size\])"
  182.         strContent=re.Replace(strContent,"<font size=1>$2</font>")
  183.         re.Pattern="(\[size=2\])(.[^\[]*)(\[\/size\])"
  184.         strContent=re.Replace(strContent,"<font size=2>$2</font>")
  185.         re.Pattern="(\[size=3\])(.[^\[]*)(\[\/size\])"
  186.         strContent=re.Replace(strContent,"<font size=3>$2</font>")
  187.         re.Pattern="(\[size=4\])(.[^\[]*)(\[\/size\])"
  188.         strContent=re.Replace(strContent,"<font size=4>$2</font>")
  189.     end if
  190.     
  191.     if instr(1,strContent,"[/center]",1)>0 then
  192.         re.Pattern="(\[center\])(.[^\[]*)(\[\/center\])"
  193.         strContent=re.Replace(strContent,"<center>$2</center>")
  194.     end if
  195.  
  196.     if instr(1,strContent,"[/list]",1)>0 then
  197.         strContent = doCode(strContent, "[list]", "[/list]", "<ul>", "</ul>")
  198.         strContent = doCode(strContent, "[list=1]", "[/list]", "<ol type=1>", "</ol id=1>")
  199.         strContent = doCode(strContent, "[list=a]", "[/list]", "<ol type=a>", "</ol id=a>")
  200.     end if
  201.     if instr(1,strContent,"[/*]",1)>0 then
  202.         strContent = doCode(strContent, "[*]", "[/*]", "<li>", "</li>")
  203.     end if
  204.     if instr(1,strContent,"[/code]",1)>0 then
  205.         strContent = doCode(strContent, "[code]", "[/code]", "<pre id=code><font size=1 face=""Verdana, Arial"" id=code>", "</font id=code></pre id=code>")
  206.     end if
  207.     
  208.     set re=Nothing
  209.     UBBCode=strContent
  210. end function
  211.  
  212.  
  213. function doCode(fString, fOTag, fCTag, fROTag, fRCTag)
  214.     dim fOTagPos, fCTagPos
  215.     fOTagPos = Instr(1, fString, fOTag, 1)
  216.     fCTagPos = Instr(1, fString, fCTag, 1)
  217.     while (fCTagPos > 0 and fOTagPos > 0)
  218.         fString = replace(fString, fOTag, fROTag, 1, 1, 1)
  219.         fString = replace(fString, fCTag, fRCTag, 1,1, 1)
  220.         fOTagPos = Instr(1, fString, fOTag, 1)
  221.         fCTagPos = Instr(1, fString, fCTag, 1)
  222.     wend
  223.     doCode = fString
  224. end function
  225.  
  226. function funKillword(str)
  227.     for i=0 to ubound(killword)
  228.         str=replace(str,killword(i),"***")
  229.     next
  230.     funKillword=str
  231. end function
  232. %>