Función del bbcode:
<?php
function BIs2cODE($texto) {
$texto = nl2br($texto);
$texto = wordwrap($texto, 150, "\n", 1);
$texto = str_replace("[b]", "<b>", $texto);
$texto = str_replace("[/b]", "</b>", $texto);
$texto = str_replace("[i]", "<i>", $texto);
$texto = str_replace("[/i]", "</i>", $texto);
$texto = str_replace("[poem]", "<center><i>", $texto);
$texto = str_replace("[/poem]", "</center></i>", $texto);
$texto = str_replace("[u]", "<u>", $texto);
$texto = str_replace("[/u]", "</u>", $texto);
$texto = str_replace("[br]","<br>",$texto);
$texto = str_replace("[strong]","<strong>",$texto);
$texto = str_replace("[/strong]","</strong>",$texto);
$texto = str_replace("[center]","<center>",$texto);
$texto = str_replace("[/center]","</center>",$texto);
$texto = str_replace("[marquee]", "<marquee>", $texto);
$texto = str_replace("[/marquee]", "</marquee>", $texto);
$texto = str_replace("[blink]", "<blink>", $texto);
$texto = str_replace("[/blink]", "</blink>", $texto);
$texto = str_replace("[strike]", "<strike>", $texto);
$texto = str_replace("[/strike]", "</strike>", $texto);
$texto = str_replace("[quote]", "<blockquote><span>Citado:</span><hr color=#A3CFD8>", $texto);
$texto = str_replace("[list]","<ul type=square>",$texto);
$texto = str_replace("[/list]","</ul>",$texto);
$texto = str_replace("[list=1]","<ol type=1>",$texto);
$texto = str_replace("[list=a]","<ol type=A>",$texto);
$texto = str_replace("[list=A]","<ol type=A>",$texto);
$texto = str_replace("[/list=1]","</ol>",$texto);
$texto = str_replace("[/list=a]","</ol>",$texto);
$texto = str_replace("[/list=A]","</ol>",$texto);
$texto = str_replace("[*]","<li>",$texto);
$texto = str_replace("[•]","<li>",$texto);
$texto = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)","\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $texto);
$texto = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\\1>\\2</font>",$texto);
$texto = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\\1>\\2</font>",$texto);
$texto = eregi_replace("\\[font=([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\\1>\\2</font>",$texto);
$texto = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<p align=\\1>\\2</p>",$texto);
$padrones[] = "#\[img\]([^\[]*)\[/img\]#si";
$remplanzantes[] = '<img src="\1" border=0 />';
$padrones[] = "#\[img=([^\[]*)x([^\[]*)\]([^\[]*)\[/img\]#si";
$remplanzantes[] = '<img width="\1" height="\2" src="\3" border=0 />';
$padrones[] = "#\[flash=([0-9].*?){1}x([0-9]*?)\](.*?)\[/flash\]#si";
$remplanzantes[] = '<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://active.macromedia.com/flash2/cabs/swflash.cab#version=6,0,0,0 ID=main WIDTH=\1 HEIGHT=\2><PARAM NAME=movie VALUE=\3><PARAM NAME=loop VALUE=false><PARAM NAME=menu VALUE=false><PARAM NAME=quality VALUE=best><EMBED src=\3 loop=false menu=false quality=best WIDTH=\1 HEIGHT=\2 TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>';
$padrones[] = "#\[url\]([a-z]+?://){1}(.*?)\[/url\]#si";
$remplanzantes[] = '<a href="\1\2" target="_blank">\1\2</a>';
$padrones[] = "#\[url\](.*?)\[/url\]#si";
$remplanzantes[] = '<a href="http://\1" target="_blank">\1</a>';
$padrones[] = "#\[url=([a-z]+?://){1}(.*?)\](.*?)\[/url\]#si";
$remplanzantes[] = '<a href="\1\2" target="_blank">\3</a>';
$padrones[] = "#\[url=(.*?)\](.*?)\[/url\]#si";
$remplanzantes[] = '<a href="http://\1" target="_blank">\2</a>';
$padrones[] = "#\[email\](.*?)\[/email\]#si";
$remplanzantes[] = '<a href="mailto:\1">\1</a>';
$padrones[] = "#\[email=(.*?){1}(.*?)\](.*?)\[/email\]#si";
$remplanzantes[] = '<a href="mailto:\1\2">\3</a>';
$texto = preg_replace($padrones, $remplanzantes, $texto);
return $texto;
}
//Autor anónimo
?>
<style>
body {font-family: Verdana; font-size: 10pt; background-color: #5791fb;}
.codigo { border: #000000 1px solid; font-size: 10pt; font-family: Verdana; color: #000000; background-color: #EAECED; }
</style>
<?php
function pintar ($cod) {
$cod = htmlentities (stripslashes ($cod));
if (strstr ($cod, "[php]")) {
$php = explode ("[php]", $cod);
for ($i = 0; $i < count ($php); $i++) {
$pos = strpos ($php[$i], "[/php]");
if (strstr ($php[$i], "[/php]")) {
$codigo = substr ($php[$i], 0, $pos);
$codigo = html_entity_decode($codigo) ;
$codigo = "<div class=\"codigo\">".highlight_string ($codigo, 1)."</div>";
$n = substr ($php[$i], $pos + 6);
$php[$i] = $codigo.$n;
}
}
$cod = implode ("", $php);
}
$cod = str_replace ("
", "<br>", $cod);
return $cod;
}
//Autor -Riven-Ward-
?>
Saludos

[/quote]