Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/09/2010, 17:17
kirst
 
Fecha de Ingreso: septiembre-2009
Mensajes: 230
Antigüedad: 14 años, 7 meses
Puntos: 2
[Ayuda] Filtrar código html

functions.php
Código PHP:
 <?php
function parse_links($str$len=25$mid='...'){
$left ceil(0.6666 $len);
$right $len $left;
preg_match_all('/(?<!=|\]|\/)((https?|ftps?|irc):\/\/|' '(www([0-9]{1,3})?|ftp)\.)([0-9a-z-]{1,25}' '[0-9a-z]{1}\.)([^\s&\[\{\}\]]+)/ims'$str$matches);
foreach(
$matches[0] as $key=>$value){
$temp $value;
if(
strlen($value) > ($len strlen($mid) + 2)){
$value substr($value0$left) . $mid substr($value,(-$right));
}
$temp = !preg_match('/:\/\//'$temp) ? (substr($temp03) === 'ftp' 'ftp://' $temp 'http://' $temp) : $temp;
$temp $temp === $matches[0][$key] && $value === $matches[0][$key] ? '' '=' $temp;
$str str_replace($matches[0][$key],'[url' $temp ']' $value '[/url]'$str);
}
$str preg_replace('/\[url=(?!http|ftp|irc)/ims''[url=http://'$str);
$str preg_replace('/\[url\](.+?)\[\/url\]/ims','<a href="$1" title="$1">$1</a>',$str);
$str preg_replace('/\[url=(.+?)\](.+?)\[\/url\]/ims''<a href="$1" title="$1">$2</a>'$str);
return 
$str;
}
?>
Lo que yo quisiera, es editar esta función para también filtrar etiquetas html, o, código html en el string. Alguna idea? Gracias de ante mano.