Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/01/2005, 17:55
Avatar de lado2mx
lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Ok, lo que hace ese código es quitar HTML de cualquier mensaje que se quiera colar de un formulario. Checa bien:

Código PHP:
<?
function removeEvilAttributes($tagSource)
{
       
$stripAttrib "' (style|class)=\"(.*?)\"'i";
       
$tagSource stripslashes($tagSource);
       
$tagSource preg_replace($stripAttrib''$tagSource);
       return 
$tagSource;
}

function 
removeEvilTags($source)
{
   
$allowedTags='<a><br><b><h1><h2><h3><h4><i>' .
             
'<img><li><ol><p><strong><table>' .
             
'<tr><td><th><u><ul>';
   
$source strip_tags($source$allowedTags);
   return 
preg_replace('/<(.*?)>/ie'"'<'.removeEvilAttributes('\\1').'>'"$source);
}

mysql_select_db($database_cx$cx);
$query_Recordset1 "SELECT * FROM noticias";
$Recordset1 mysql_query($query_Recordset1$cx) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1); 

$texto=removeEvilTags($totalRows_Recordset1[1]);

 
?>
Eso si $totalRows_Recordset1[1] xámbialo por el texto que quieras quitar de HTML. Ojo con eso.