Вот мой код:
function bb_decode($sourse, $mod) {<br />
if (!preg_match("#\[php\](.*)\[/php\]|\[code\](.*)\[/code\]#si", $sourse)) {<br />
$bb[] = "#\[img\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#i";<br />
$html[] = "<img src=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\">";<br />
$bb[] = "#\[img=([a-zA-Z]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\2\" align=\"\\1\" border=\"0\" alt=\"\\2\" title=\"\\2\">";<br />
$bb[] = "#\[img\ alt=([a-zA-Zа-яА-Я0-9\_\-\. ]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\2\" align=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\">";<br />
$bb[] = "#\[img=([a-zA-Z]+) alt=([a-zA-Zа-яА-Я0-9\_\-\. ]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\3\" align=\"\\1\" border=\"0\" alt=\"\\2\" title=\"\\2\">";<br />
$bb[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";<br />
$html[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\">\\1</a>";<br />
$bb[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";<br />
$html[] = "<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\">\\1</a>";<br />
$bb[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";<br />
$html[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\">\\2</a>";<br />
$bb[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";<br />
$html[] = "<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\">\\3</a>";<br />
$bb[] = "#\[mail\](\S+?)\[/mail\]#i";<br />
$html[] = "<a href=\"mailto:\\1\">\\1</a>";<br />
$bb[] = "#\[mail\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/mail\]#i";<br />
$html[] = "<a href=\"mailto:\\1\">\\2</a>";<br />
$bb[] = "#\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*?)\[/color\]#si";<br />
$html[] = "<span style=\"color: \\1\">\\2</span>";<br />
$bb[] = "#\[family=([A-Za-z ]+)\](.*?)\[/family\]#si";<br />
$html[] = "<span style=\"font-family: \\1\">\\2</span>";<br />
$bb[] = "#\[size=([0-9]{1,2}+)\](.*?)\[/size\]#si";<br />
$html[] = "<span style=\"font-size: \\1\">\\2</span>";<br />
$bb[] = "#\[(left|right|center|justify)\](.*?)\[/\\1\]#is";<br />
$html[] = "<div align=\"\\1\">\\2</div>";<br />
$bb[] = "#\[b\](.*?)\[/b\]#si";<br />
$html[] = "<b>\\1</b>";<br />
$bb[] = "#\[i\](.*?)\[/i\]#si";<br />
$html[] = "<i>\\1</i>";<br />
$bb[] = "#\[u\](.*?)\[/u\]#si";<br />
$html[] = "<u>\\1</u>";<br />
$bb[] = "#\[s\](.*?)\[/s\]#si";<br />
$html[] = "<s>\\1</s>";<br />
$bb[] = "#\[li\]#si";<br />
$html[] = "<li>";<br />
$bb[] = "#\[hr\]#si";<br />
$html[] = "<hr>";<br />
$bb[] = "#\*(\d{2})#";<br />
$html[] = "<img src=\"images/smilies/\\1.gif\" border=\"0\">";<br />
<br />
$bb[] = "#Java Script#si";<br />
$html[] = "Java Script";<br />
$bb[] = "#About#si";<br />
$html[] = "About";<br />
$bb[] = "#VB Script#si";<br />
$html[] = "VB Script";<br />
<br />
$sourse = preg_replace($bb, $html, $sourse);<br />
if (preg_match("#\[quote\](.*?)\[/quote\]#si", $sourse)) $sourse = encode_quote($sourse);<br />
if (preg_match("#\[hide\](.*?)\[/hide\]#si", $sourse)) $sourse = encode_hide($sourse);<br />
if (preg_match("#\[attach=(.*?)\]#si", $sourse)) $sourse = encode_attach($sourse, strtolower($mod));<br />
} else {<br />
if (preg_match("#(.*)\[php\](.*)\[/php\](.*)#si", $sourse, $matches)) {<br />
$sourse = bb_decode($matches[1], $mod).encode_php($matches[2]).bb_decode($matches[3], $mod);<br />
} elseif (preg_match("#(.*)\[code\](.*)\[/code\](.*)#si", $sourse, $matches)) {<br />
$sourse = bb_decode($matches[1], $mod).encode_code($matches[2]).bb_decode($matches[3], $mod);<br />
}<br />
}<br />
return $sourse; <br />
}
А вот код какой прописывается при установки мода:
function bb_decode($sourse, $mod) {<br />
$bb[] = "#\[img\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#i";<br />
$html[] = "<img src=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\">";<br />
$bb[] = "#\[img=([a-zA-Z]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\2\" align=\"\\1\" border=\"0\" alt=\"\\2\" title=\"\\2\">";<br />
$bb[] = "#\[img\ alt=([a-zA-Zа-яА-Я0-9\_\-\. ]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\2\" align=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\">";<br />
$bb[] = "#\[img=([a-zA-Z]+) alt=([a-zA-Zа-яА-Я0-9\_\-\. ]+)\]([^?](?:[^\[]+|\[(?!url))*?)\[/img\]#is";<br />
$html[] = "<img src=\"\\3\" align=\"\\1\" border=\"0\" alt=\"\\2\" title=\"\\2\">";<br />
$bb[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";<br />
$html[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\">\\1</a>";<br />
$bb[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";<br />
$html[] = "<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\">\\1</a>";<br />
$bb[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";<br />
$html[] = "<a href=\"\\1\" target=\"_blank\" title=\"\\1\">\\2</a>";<br />
$bb[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is";<br />
$html[] = "<a href=\"http://\\1\" target=\"_blank\" title=\"\\1\">\\3</a>";<br />
$bb[] = "#\[mail\](\S+?)\[/mail\]#i";<br />
$html[] = "<a href=\"mailto:\\1\">\\1</a>";<br />
$bb[] = "#\[mail\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/mail\]#i";<br />
$html[] = "<a href=\"mailto:\\1\">\\2</a>";<br />
$bb[] = "#\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*?)\[/color\]#si";<br />
$html[] = "<span style=\"color: \\1\">\\2</span>";<br />
$bb[] = "#\[family=([A-Za-z ]+)\](.*?)\[/family\]#si";<br />
$html[] = "<span style=\"font-family: \\1\">\\2</span>";<br />
$bb[] = "#\[size=([0-9]{1,2}+)\](.*?)\[/size\]#si";<br />
$html[] = "<span style=\"font-size: \\1\">\\2</span>";<br />
$bb[] = "#\[(left|right|center|justify)\](.*?)\[/\\1\]#is";<br />
$html[] = "<div align=\"\\1\">\\2</div>";<br />
$bb[] = "#\[b\](.*?)\[/b\]#si";<br />
$html[] = "<b>\\1</b>";<br />
<br />
$bb[] = "#\[mp3\](.*?)\[/mp3\]#si";<br />
$html[] = "<p align=\"center\"><script type=\"text/javascript\" src=\"player/swfobject.js\"></script><br />
<p id=\"player1\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.</p><br />
<script type=\"text/javascript\"><br />
var s3 = new SWFObject(\"/plugin/mp3player.swf\", \"line\", \"240\", \"20\", \"7\");<br />
s3.addVariable(\"file\",\"\\1\");<br />
s3.addVariable(\"repeat\",\"false\");<br />
s3.addVariable(\"showdigits\",\"true\");<br />
s3.addVariable(\"showdownload\",\"false\");<br />
s3.write(\"player1\");<br />
</script></p>";<br />
<br />
$bb[] = "#\[flv\](.*?)\[/flv\]#si";<br />
$html[] = "<p align=\"center\"><object type=\"application/x-shockwave-flash\" height=\"440\" width=\"500\" data=\"http://skaportal.be/player/uflvplayer.swf\"><br />
<param value=\"#FFFFFF\" name=\"bgcolor\" /><br />
<param value=\"true\" name=\"allowFullScreen\" /><br />
<param value=\"http://skaportal.be/player/uflvplayer.swf\" name=\"movie\" /><br />
<param value=\"way=\\1&swf=http://skaportal.be/player/uflvplayer.swf&time_seconds=216&w=500&h=440&pic=http://skaportal.be/player/OpenSlaed.png&autoplay=0&tools=1&skin=http://skaportal.be/player/skin_slaed.swf&volume=70&q=&comment=\" name=\"FlashVars\" /><br />
<br />
<embed src=\"http://skaportal.be/player/uflvplayer.swf\" type=\"application/x-shockwave-flash\" param value=\"true\" name=\"allowFullScreen\" wmode=\"transparent\" flashvars=\"way=\\1&swf=http://skaportal.be/player/uflvplayer.swf&w=500&h=440&time_seconds=216&pic=http://skaportal.be/player/OpenSlaed.png&autoplay=0&tools=1&skin=http://skaportal.be/player/skin_slaed.swf&volume=70&q=&comment=\" height=\"440\" width=\"500\"></embed><br />
</object></p>\n";<br />
<br />
$bb[] = "#\[flash\](.*?)\[/flash\]#si";<br />
$html[] ="<p align=\"center\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" height=\"440\" width=\"550\"><br />
<param name=\"movie\" value=\"\\1\"><br />
<param name=\"quality\" value=\"high\"><br />
<embed src=\"\\1\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" height=\"440\" width=\"550\" ><br />
</embed><br />
</object></p>";<br />
<br />
$bb[] = "#\[img90x120]([^?](?:[^\[]+|\[(?!url))*?)\[/img90x120\]#is";<br />
$html[] = "<img height=\"90\" width=\"120\" src=\"\\1\">";<br />
<br />
<br />
$bb[] = "#\[embed](.*?)\[/embed\]#is";<br />
$html[] = "<p align=\"center\">\\1\</p>";<br />
<br />
$bb[] = "#\[video\](.*?)\[/video\]#si";<br />
$html[] = "<p align=\"center\"><br><fieldset><legend>Просмотр видео</legend><embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/\" width=\"300\" height=\"235\" src=\"\\1\" filename=\"\\1\" autostart=\"True\" showcontrols=\"True\" Volume=\"100\" id='mediaPlayer' displaysize='5' autosize='1' showstatusbar=\"True\" showdisplay=\"False\" autorewind=\"False\"><br />
</embed><br><font class=small>Для просмотра видео, оно должно изначально загрузится.</font></fieldset></p>";<br />
<br />
$bb[] = "#\[youtube\](.*?)\[/youtube\]#si";<br />
<br />
$html[] = "<br />
<p align=\"center\"><embed src=\"http://www.youtube.com/v/\\1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"425\" height=\"373\"><br />
</embed></object></p>\n";<br />
<br />
<br />
$bb[] = "#\[metacafe\](.*?)\[/metacafe\]#si";<br />
<br />
$html[] = "<br />
<p align=\"center\"><embed src= http://www.metacafe.com/fplayer/\\1.swf width=400 height=345 wmode=transparent pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash> </embed><br><font size = 1></p>\n";<br />
<br />
<br />
$bb[] = "#\[video.google.com\](.*?)\[/video.google.com\]#si";<br />
$html[] = "<br />
<p align=\"center\"><embed id=\"VideoPlayback\" style=\"width:400px;height:326px\" allowFullScreen=\"true\" src=\"http://video.google.com/googleplayer.swf?docid=\\1&hl=ru&fs=true\" type=\"application/x-shockwave-flash\"> </embed></p>\n";<br />
<br />
$bb[] = "#\[rutube\](.*?)\[/rutube\]#si";<br />
$html[] = "<p align=\"center\"><OBJECT width=\"400\" height=\"353\"><PARAM name=\"wmode\" value=\"http://video.rutube.ru/\\1\" /><br />
<PARAM name=\"wmode\" value=\"window\" /><PARAM name=\"allowFullScreen\" value=\"true\"><br />
</PARAM><EMBED src=\"http://video.rutube.ru/\\1\" type=\"application/x-shockwave-flash\" wmode=\"window\" width=\"400\" height=\"353\" allowFullScreen=\"true\" /></OBJECT></p>\n";<br />
<br />
$bb[] = "#\[smotri.com\](.*?)\[/smotri.com\]#si";<br />
<br />
$html[] = "<p align=\"center\"><object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=400 height=330><param name=movie value=http://pics.smotri.com/scrubber_custom8.swf?file=\\1&bufferTime=3&autoStart=false&str_lang=rus&xmlsource=http%3A%2F%2Fpics.smotri.com%2Fcskins%2Fblue%2Fskin_color_lightaqua.xml&xmldatasource=http%3A%2F%2Fpics.smotri.com%2Fskin_ng.xml /><param name=allowScriptAccess value=always /><param name=allowFullScreen value=true /><param name=bgcolor value=#ffffff /><embed src=http://pics.smotri.com/scrubber_custom8.swf?file=\\1&bufferTime=3&autoStart=false&str_lang=rus&xmlsource=http%3A%2F%2Fpics.smotri.com%2Fcskins%2Fblue%2Fskin_color_lightaqua.xml&xmldatasource=http%3A%2F%2Fpics.smotri.com%2Fskin_ng.xml quality=high allowscriptaccess=always allowfullscreen=true wmode=window width=400 height=330 type= application/x-shockwave-flash></embed></object></p>"; <br />
<br />
<br />
$bb[] = "#\[i\](.*?)\[/i\]#si";<br />
$html[] = "<i>\\1</i>";<br />
$bb[] = "#\[u\](.*?)\[/u\]#si";<br />
$html[] = "<u>\\1</u>";<br />
$bb[] = "#\[s\](.*?)\[/s\]#si";<br />
$html[] = "<s>\\1</s>";<br />
$bb[] = "#\[li\]#si";<br />
$html[] = "<li>";<br />
$bb[] = "#\[hr\]#si";<br />
$html[] = "<hr>";<br />
$bb[] = "#\*(\d{2})#";<br />
$html[] = "<img src=\"images/smilies/\\1.gif\" border=\"0\">";<br />
<br />
$bb[] = "#Java Script#si";<br />
$html[] = "Java Script";<br />
$bb[] = "#About#si";<br />
$html[] = "About";<br />
$bb[] = "#VB Script#si";<br />
$html[] = "VB Script";<br />
<br />
$sourse = preg_replace($bb, $html, $sourse);<br />
if (preg_match("#\[quote\](.*?)\[/quote\]#si", $sourse)) $sourse = encode_quote($sourse);<br />
if (preg_match("#\[hide\](.*?)\[/hide\]#si", $sourse)) $sourse = encode_hide($sourse);<br />
if (preg_match("#\[code\](.*?)\[/code\]#si", $sourse)) $sourse = encode_code($sourse);<br />
if (preg_match("#\[php\](.*?)\[/php\]#si", $sourse)) $sourse = encode_php($sourse);<br />
if (preg_match("#\[attach=(.*?)\]#si", $sourse)) $sourse = encode_attach($sourse, strtolower($mod));<br />
return $sourse; <br />
}