Hola amigos, llevo desde hace tiempo intentando mejorar un foro que he creado, bueno mas bien es un lugar donde comentar articulos etc, pero la idea es que hasta el momento, habia depurado el codigo con nl2br, pero quisiera tambien que admitiera el codigo php, por ello recurri a php.net y estube buscando y encontre la funcion str_replace, y me ha parecido que este foro tiene que usar un sistema parecido. Encontre un script que hacia algo interesante:
Código PHP:
function flt_tags($text) {
$text = ereg_replace("r", "", $text);
$text = ereg_replace("n", "[br]", $text);
$text = str_replace("<", "<", $text);
$text = str_replace(">", ">", $text);
$text = str_replace("[br", "<br", $text);
$text = str_replace("[p", "<p", $text);
$text = str_replace("[b", "<b", $text);
$text = str_replace("[/b", "</b", $text);
$text = str_replace("[i", "<i", $text);
$text = str_replace("[/i", "</i", $text);
$text = str_replace("[/u", "<u", $text);
$text = str_replace("[/u", "</u", $text);
$text = str_replace("[font color=", "<font color=", $text);
$text = str_replace("[font size=", "<font size=", $text);
$text = str_replace("[/font", "</font", $text);
$text = str_replace("[url=","<a target=_blank href=",$text);
$text = str_replace("[/url","</a",$text);
$text = str_replace("]",">",$text);
$text = stripslashes($text);
$text = trim($text);
return $text;
}
El problema es que no me funciona... ¿que hago mal? o ¿teneis alguna otra idea al respecto?
Un saludo