<? Php
Function ubbcode ($ str ){
// $ Str = str_replace ("file:", "file:", $ str );
// $ Str = str_replace ("files:", "files:", $ str );
// $ Str = str_replace ("script:", "script:", $ str );
// $ Str = str_replace ("js:", "js:", $ str );
// Image UBB
$ Str = preg_replace ("/\ [img \] (http | https | ftp ):\/\/(. [^ \ [] *) \ [\/img \]/I "," <a onfocus = \ "this. blur () \ "href = \" \$ {1}: // \$ {2} \ "target = new> 300) this. width = 300 \ "> </a>", $ str );
$ Str = preg_replace ("/\ [img = * ([0-9] *), * ([0-9] *) \] (http | https | ftp ): \/\/(. [^ \ [] *) \ [\/img \]/I "," <a onfocus = \ "this. blur () \ "href = \" \$ {3}: // \4 {4} \ "target = new> 300) this. width = 300 \ "> </a>", $ str );
$ Str = preg_replace ("/(\ [img \]) images \/face \/em (.*?) \. Gif (\ [\/img \])/I "," ", $ str );
// Link to UBB
$ Str = preg_replace ("/(\ [url \]) (. [^ \ [] *) (\ [url \])/I ", "<a href = \" \$ {2} \ "target = \" new \ ">\\ {1} </a>", $ str );
$ Str = preg_replace ("/\ [url = (. [^ \ [] *) \]/I "," <a href = \ "\$ {1} \" target = \ "new \"> ", $ str );
// Email UBB
$ Str = preg_replace ("/(\ [email \]) (. *?) (\ [\/Email \])/I ", " <a href = \" mailto: \$ {2 }\ ">\\ {2} </a>", $ str );
$ Str = preg_replace ("/\ [email = (. [^ \ [] *) \]/I ", " <a href = \" mailto: \ $ {1} \ "target = \" new \ ">", $ str );
// QQ number UBB
$ Str = preg_replace ("/\ [qq = ([0-9] *) \] ([0-9] *) \ [\/qq \]/I ", "<a target = \" new \ "href = \" tencent: // message /? Uin =\\ {2} & Site = www.52515.net & Menu = yes \ "> </a>", $ str );
// Color UBB
$ Str = preg_replace ("/\ [color = (. [^ \ [] *) \]/I "," <font color = \ "\$ {1} \"> ", $ str );
// Text font UBB
$ Str = preg_replace ("/\ [font = (. [^ \ [] *) \]/I "," <font face = \ "\$ {1} \"> ", $ str );
// Text size UBB
$ Str = preg_replace ("/\ [size = ([0-9] *) \]/I ", "<font size = \" \$ {1} \ ">", $ str );
$ Str = preg_replace ("/\ [size = ([0-9] *) pt \]/I ", "<font size = \" \$ {1} \ ">", $ str );
$ Str = preg_replace ("/\ [size = ([0-9] *) px \]/I ", "<font size = \" \$ {1} \ ">", $ str );
// Text alignment UBB
$ Str = preg_replace ("/\ [align = (center | left | right) \]/I ", "<div align = \" \$ {1} \ ">", $ str );
// Table UBB
// $ Str = preg_replace ("/\ [table = (. [^ \ [] *) \]/I ", "<table width = \" \$ {1} \ "border = \" 1 \ "style = \" border-collapse: collapse \ ">", $ str );
// Table UBB2
// $ Str = preg_replace ("/\ [td = ([0-9] *), ([0-9] *), ([0-9] *) \]/I ", "<td colspan = \" \$ {1} \ "rowspan = \" \$ {2} \ "width = \" \$ {3 }\ "> ", $ str );
// Font skew
$ Str = preg_replace ("/\ [I \] (. | \ n )*?) \ [\/I \]/I "," <I >\\ {1} </I> ", $ str );
// FLASH Animation UBB
$ Str = preg_replace ("/(\ [flash \]) (http :\/\/. [^ \ [] * (.swf) (\ [\/flash \])/I ", "<a href = \" \$ {2} \ "target = \" new \ "> [full screen playback] </a> <br> <center> <object codebase = \" inline "classid = \ "clsid: d27cdb6e-ae6d-11cf-96b8-444553540000 \ "width = \" 300 \ "height = \" 200 \ "> <param name = \" movie \ "value = \" \ $ {2} \ "> <param name = \ "quality \" value = \ "high \"> <embed src = \ "\$ {2} \" quality = \ "high \" pluginspage = \" http://www.macromedia.com/shock Wave/download/index. cgi? P1_prod_version = shockwaveflash \ "type = \" application/x-shockwave-flash \ "width = \" 300 \ "height = \" 200 \ ">\$ {2} </ embed> </object> </center> ", $ str );
$ Str = preg_replace ("/(\ [flash = * ([0-9] *), * ([0-9] *) \]) (http: \/\/. [^ \ [] * (.swf) (\ [\/flash \])/I ", "<a href = \" \$ {4} \ "target = \" new \ "> [full screen playback] </a> <br> <center> <object codebase = \" inline "classid = \ "clsid: d27cdb6e-ae6d-11cf-96b8-444553540000 \ "width = \" \ $ {2} \ "height = \" \ $ {3} \ "> <param name = \" movie \ "value = \"\ $ {4} \ "> <param name = quality value = high> <embed src = \" \$ {4} \ "quality = \" high \ "pluginspage = \" http://www.macromedia.com/shockwave /Download/index. cgi? P1_prod_version = shockwaveflash \ "type = \" application/x-shockwave-flash \ "width = \" \$ {2} \ "height = \" \$ {3 }\" >\$ {4} </embed> </object> </center> ", $ str );
// MEDIA PLAY UBB
$ Str = preg_replace ("/\ [wmv \] (. [^ \ [] *) \ [\/wmv]/I "," <object align = \ "middle \" classid = \ "clsid: 22d6f312-b0f6-11d0-94ab-0080c74c7e95 \ "class = \" object \ "id = \" mediaplayer \ "width = \" 300 \ "height = \" 200 \ "> <param name = \" showstatusbar \ "value = \"-1 \ "> <param name = \" filename \ "value = \" \1 {1} \ "> <embed type = \" application/x -oleobject \ "codebase = \" prop "flename = \" mp \ "src = \" \1 {1} \ "width = \" 300 \ "height = \" 200 \ "> </embed> </object> ", $ str );
$ Str = preg_replace ("/\ [wmv = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/wmv]/I "," <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 = \ "inline" flename = \ "mp \" src = \ "\$ {3} \" width = \" \ $ {1} \ "height = \" \ $ {2} \ "> </embed> </object> ", $ str );
// REALPLAY UBB
$ Str = preg_replace ("/\ [rm \] (. [^ \ [] *) \ [\/rm]/I "," <object classid = \ "clsid: cfcdaa03-8be4-11cf-b84b-0020afbbccfa \ "class = \" object \ "id = \" raocx \ "width = \" 300 \ "height = \" 200 \ "> <param name = \" src \ "value = \" \ $ {1} \ "> <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 = \" 300 \ "> <param name = \" src \ "value = \" \ $ {1} \ "> <param name = \" autostart \ "value = \"-1 \ "> <param name = \" controls \ "value = \" controlpanel \"> <param name = \ "console \" value = \ "clip1 \"> </object> ", $ str );
$ Str = preg_replace ("/\ [rm = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/rm]/I "," <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> ", $ str );
$ Str = str_replace ("\ r \ n", "<BR/>", $ str );
$ Str = preg_replace ("/\ [rm = * ([0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/rm]/I "," <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> ", $ str );
/*
Re. pattern = "\ [code \] (. | \ n )*?) \ [\/Code \]"
Set tempcodes = re. Execute ($ str)
For I = 0 To tempcodes. count-1
Re. pattern = "<BR/>"
Tempcode = Replace (tempcodes (I), "<BR/>", vbcrlf)
$ Str = replace ($ str, tempcodes (I), tempcode)
Next
*/
$ Searcharray = array ("[/url]", "[/email]", "[/color]", "[/size]", "[/font]", "[/align]", "[B]", "[/B]", "[u]", "[/u]", "[list]", "[list = 1]", "[list = a]", "[list = A]", "[*]", "[/list]", "[indent]", "[/indent]", "[DISCUZ_CODE_0]", "[quote]", "[/quote]", "[tr]", "[td]", "[/td]", "[/tr]", "[/table]");
$ Replacearray = array ("</a>", "</a>", "</font> ", "</div>", "<B>", "</B>", "<u>", "</u>", "<ul> ", "<ol type = 1>", "<ol type = a>", "<ol type = A>", "<li> ", "</ul> </ol>", "<blockquote>", "</blockquote> ", "<div> <textarea name = \" codes \ "id = \" codes \ "rows = \" 12 \ "cols = \" 65 \ "> ", "</textarea> <br/> <input type = \" button \ "value = \" run code \ "onclick = \" RunCode () \ "> <input type = \" button \ "value = \" Copy Code \ "on Click = \ "CopyCode () \"> <input type = \ "button \" value = \ "Save Code \" onclick = \ "SaveCode () \ "> <input type = \" button \ "value = \" Hop & nbsp; to \ "onclick = \" Goto (prompt ('enter the row to jump? ', '1') \ "accesskey = \" g \ "> & nbsp; prompt: you can modify some code before running </div> ", "<div style = \" background: # E2F2FF; width: 90%; height: auto; border: 1px solid #3 CAAEC; padding: 5px; \ "> ", "</div>", "<tr>", "<td>", "</td>", "</tr> ", "</table> ");
For ($ I = 0; $ I <count ($ searcharray); $ I ++ ){
$ Str = str_replace ($ searcharray [$ I], $ replacearray [$ I], $ str );
}
Return $ str;
}
/*
'Re. pattern = "\ [UPLOAD = (gif | jpg | jpeg | bmp) \] (. [^ \ [] *) (gif | jpg | jpeg | bmp) \ [\/UPLOAD \]"
'$ Str = re. replace ($ str, "<br> links to this topic are as follows: <br> <a href = \ "$2 $1 \" TARGET = _ blank> screen. width-333) this. width = screen. width-333 \ "> </A> ")
'Re. pattern = "\ [UPLOAD = (doc | xls | ppt | htm | swf | rar | zip | exe) \] (. [^ \ [] *) (doc | xls | ppt | htm | swf | rar | zip | exe) \ [\/UPLOAD \]"
'$ Str = re. replace ($ str, "<br> links to this topic are as follows: <br> <a href = \ "$2 $1 \" target = '_ blank'> click to browse this file </a> ")
'Automatically identifies the URL
'Re. Pattern = "^ (http | https | ftp | rtsp | mms) :( \/| \) [A-Za-z0-9 \./= \? % \-&_~ '@ [\] \': +!] + )"
'$ Str = re. replace ($ str, " <a target = _ blank href = $1> $1 </a> ")
'Re. Pattern = "(http | https | ftp | rtsp | mms) :( \\// |\\\) [A-Za-z0-9 \./= \? % \-&_~ '@ [\] \': +!] +) $"
'$ Str = re. replace ($ str, " <a target = _ blank href = $1> $1 </a> ")
'Re. pattern = "([^> = \"]) (http | https | ftp | rtsp | mms) :( \\// |\\\) [A-Za-z0-9 \. /= \? % \-&_~ '@ [\] \': +!] + )"
'$ Str = re. replace ($ str, "$1 <a target = _ blank href = $2> $2 </a> ")
'Automatically identifies the URLs starting with www.
'Re. pattern = "([^ (http: // | http: \)]) (www | cn) [.] (\ w) + [.] {1,} (net | com | cn | org | cc) (\/[\ ~] * | \ [\ ~] *) (\ W) +) | [.] (\ w) +) * ([?] (\ W) +) {1} [=] *) * (\ w) +) {1} ([\ &] (\ w) + [\ =] (\ w) + )*)*)"
'$ Str = re. replace ($ str, " <a target = _ blank href = http: // $2> $2 </a> ")
'Re. pattern = "\ [SHADOW = * ([0-9] *), * (# * [a-z0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/SHADOW]"
'$ Str = re. replace ($ str, "<div style = \" width: $1; filter: shadow (color = $2, strength = $3) \ "> $4 </div> ")
'Re. pattern = "\ [GLOW = * ([0-9] *), * (# * [a-z0-9] *), * ([0-9] *) \] (. [^ \ [] *) \ [\/GLOW]"
'$ Str = re. replace ($ str, "<div style = \" width: $1; filter: glow (color = $2, strength = $3) \ "> $4 </div> ")
*/
?>