pjblog的ubbcodeasp文件

<%
'===========PBlog2 UBB代码转换代码==========
'      Author:PuterJam
'         Copryright PBlog2
'         Update: 2005-12-29
'===========================================
Function UBBCode(ByVal strContent,DisSM,DisUBB,DisIMG,AutoURL,AutoKEY)
 If isEmpty(strContent) Or isNull(strContent) Then
        Exit Function
 Else
  Dim re, strMatchs, strMatch, rndID,tmpStr1,tmpStr2,tmpStr3,tmpStr4
  Set re=new RegExp
  re.IgnoreCase =True
  re.Global=True
  IF AutoURL=1 Then
   re.Pattern="([^=\]][\s]*?|^)(http|https|rstp|ftp|mms|ed2k)://([A-Za-z0-9\.\/=\?%\-_~`@':+!]*)"
   Set strMatchs=re.Execute(strContent)
   For Each strMatch in strMatchs
    tmpStr1=strMatch.SubMatches(0)
    tmpStr2=strMatch.SubMatches(1)
    tmpStr3=checkURL(strMatch.SubMatches(2))
    strContent=replace(strContent,strMatch.Value,tmpStr1&"<a href="""https://www.jb51.net/&tmpStr2&"://"https://www.jb51.net/&tmpStr3&""" target=""_blank"">"https://www.jb51.net/&tmpStr2&"://"https://www.jb51.net/&tmpStr3&"</a>",1,-1,0)
   Next
   're.Pattern="(^|\s)(www\.\S+)"
   'strContent=re.Replace(strContent,"$1<a href=""https://$2"" target=""_blank"">$2</a>")
  End IF

IF Not DisUBB=1 Then
   IF Not DisIMG=1 Then
             re.Pattern="(\[img\])(.[^\]]*)\[\/img\]"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=(strMatch.SubMatches(1))
      strContent=replace(strContent,strMatch.Value,"<img src="""https://www.jb51.net/&tmpStr1&"""0"" alt=""""/>",1,-1,0)
     Next

             re.Pattern="\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=checkURL(strMatch.SubMatches(1))
      strContent=replace(strContent,strMatch.Value,"<img"https://www.jb51.net/&tmpStr1&""" src="""https://www.jb51.net/&tmpStr2&"""0"" alt=""""/>",1,-1,0)
     Next

             re.Pattern="\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=strMatch.SubMatches(1)
      tmpStr3=checkURL(strMatch.SubMatches(2))
      strContent=replace(strContent,strMatch.Value,"<img"https://www.jb51.net/&tmpStr1&""""https://www.jb51.net/&tmpStr2&""" src="""https://www.jb51.net/&tmpStr3&"""0"" alt=""""/>",1,-1,0)
     Next

             re.Pattern="\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=strMatch.SubMatches(1)
      tmpStr3=strMatch.SubMatches(2)
      tmpStr4=checkURL(strMatch.SubMatches(3))
      strContent=replace(strContent,strMatch.Value,"<img"https://www.jb51.net/&tmpStr1&""""https://www.jb51.net/&tmpStr2&""""https://www.jb51.net/&tmpStr3&""" src="""https://www.jb51.net/&tmpStr4&"""0"" alt=""""/>",1,-1,0)
     Next
    else
             re.Pattern="(\[img\])(.[^\]]*)\[\/img\]"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=checkURL(strMatch.SubMatches(1))
      strContent=replace(strContent,strMatch.Value,"<a href="""https://www.jb51.net/&tmpStr1&""" target=""_blank"" title="""https://www.jb51.net/&tmpStr1&"""><img src=""https://www.jb51.net/images/image.gif"" alt=""""margin:0px 2px -3px 0px""0""/>查看图片</a>",1,-1,0)
     Next

             re.Pattern="\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=checkURL(strMatch.SubMatches(1))
      strContent=replace(strContent,strMatch.Value,"<a href="""https://www.jb51.net/&tmpStr2&""" target=""_blank"" title="""https://www.jb51.net/&tmpStr2&"""><img src=""https://www.jb51.net/images/image.gif"" alt=""""margin:0px 2px -3px 0px""0""/>查看图片</a>",1,-1,0)
     Next

             re.Pattern="\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=strMatch.SubMatches(1)
      tmpStr3=checkURL(strMatch.SubMatches(2))
      strContent=replace(strContent,strMatch.Value,"<a href="""https://www.jb51.net/&tmpStr3&""" target=""_blank"" title="""https://www.jb51.net/&tmpStr3&"""><img src=""https://www.jb51.net/images/image.gif"" alt=""""margin:0px 2px -3px 0px""0""/>查看图片</a>",1,-1,0)
     Next

             re.Pattern="\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"
     Set strMatchs=re.Execute(strContent)
     For Each strMatch in strMatchs
      tmpStr1=strMatch.SubMatches(0)
      tmpStr2=strMatch.SubMatches(1)
      tmpStr3=strMatch.SubMatches(2)
      tmpStr4=checkURL(strMatch.SubMatches(3))
      strContent=replace(strContent,strMatch.Value,"<a href="""https://www.jb51.net/&tmpStr4&""" target=""_blank"" title="""https://www.jb51.net/&tmpStr4&"""><img src=""https://www.jb51.net/images/image.gif"" alt=""""margin:0px 2px -3px 0px""0""/>查看图片</a>",1,-1,0)
     Next    
   End IF

'-----------多媒体标签----------------
   re.Pattern="\[(swf|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(swf|wma|wmv|rm|ra|qt)\]"
      Set strMatchs=re.Execute(strContent)
      dim strType,strWidth,strHeight,strSRC,TitleText
  For Each strMatch in strMatchs
   RAndomize
     strType=strMatch.SubMatches(0)
     if strType="swf" then
      TitleText="<img src=""https://www.jb51.net/images/flash.gif"" alt=""""margin:0px 2px -3px 0px""0""/>Flash动画"
     elseif strType="wma" then
      TitleText="<img src=""https://www.jb51.net/images/music.gif"" alt=""""margin:0px 2px -3px 0px""0""/>播放音频文件"
     elseif strType="wmv" then
      TitleText="<img src=""https://www.jb51.net/images/mediaplayer.gif"" alt=""""margin:0px 2px -3px 0px""0""/>播放视频文件"  
     elseif strType="rm" then
      TitleText="<img src=""https://www.jb51.net/images/realplayer.gif"" alt=""""margin:0px 2px -3px 0px""0""/>播放real视频流文件"  
     elseif strType="ra" then
      TitleText="<img src=""https://www.jb51.net/images/realplayer.gif"" alt=""""margin:0px 2px -3px 0px""0""/>播放real音频流文件"  
     elseif strType="qt" then
      TitleText="<img src=""https://www.jb51.net/images/mediaplayer.gif"" alt=""""margin:0px 2px -3px 0px""0""/>播放mov视频文件"  
     end if
              strWidth=strMatch.SubMatches(1)
              strHeight=strMatch.SubMatches(2)
              if (len(strWidth)=0) then
                strWidth="400"
                else
               strWidth=right(strWidth,(len(strWidth)-1))
              end if
              if (len(strHeight)=0) then
               strHeight="300"
                else
              strHeight=right(strHeight,(len(strHeight)-1))
              end if
              strSRC=checkURL(strMatch.SubMatches(3))
   rndID="temp"&Int(100000 * Rnd)
   strContent= Replace(strContent,strMatch.Value,"<divUBBPanel""><divUBBTitle"">"&TitleText&"</div><divUBBContent""><a"+rndID+"_href"" href=""javascript:MediaShow('"+strType+"','"+rndID+"','"+strSRC+"','"+strWidth+"','"+strHeight+"')""><img"+rndID+"_img"" src=""https://www.jb51.net/images/mm_snd.gif""margin:0px 3px -2px 0px""0"" alt=""""/><span"+rndID+"_text"">在线播放</span></a><div"+rndID+"""></div></div></div>")
  Next
  Set strMatchs=nothing
  re.Pattern="(\[mid\])(.[^\]]*)\[\/mid\]"
  strContent= re.Replace(strContent,"<embed src=""https://www.jb51.net/article/$2""45""314"" autostart=""0""></embed>") 
'-----------常规标签----------------
   re.Pattern = "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"
   Set strMatchs=re.Execute(strContent)
   For Each strMatch in strMatchs
    tmpStr1=checkURL(strMatch.SubMatches(0))
    tmpStr2=strMatch.SubMatches(1)
    strContent=replace(strContent,strMatch.Value,"<a target=""_blank"" href="""https://www.jb51.net/&tmpStr1&""">"https://www.jb51.net/&tmpStr2&"</a>",1,-1,0)
   Next

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzzgs.html