ok, pues si es solo al guardar lo tengo así:
function seguridad($texto){
$texto=strip_tags($texto);
$texto=htmlspecialchars($texto);
$texto=stripslashes($texto);
$texto=nl2br($texto);
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url=http://(.*?)\](.*?)\[\/url\]/is",
"/\[quote\](.*?)\[\/quote\]/is",
"/>/is",
"/</is",
"/"/is",
"/&/is",
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<a href=\"$1\" /><img style=\"max-height:350px; max-weight:350px;\" src=\"$1\" /></a>",
"<a href=\"$1\" target=\"_blank\">$2</a>",
"<blockquote>$1</blockquote>",
">",
"<",
"\"",
"&",
);
$texto=preg_replace($a, $b, $texto);
return $texto;
}