Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/04/2009, 12:08
Avatar de hgp147
hgp147
 
Fecha de Ingreso: diciembre-2006
Ubicación: Buenos Aires, Argentina
Mensajes: 980
Antigüedad: 17 años, 4 meses
Puntos: 36
Respuesta: Reconocimiento de "http://" en un textarea

Código PHP:
function ConvertirCortarurl$matches ) {  
    
$limite 40
    
$matches[0] = (strlen($matches[0]) > $limite) ? substr($matches[0],0,15)."...".substr($matches[0],19-$limite) : $matches[0]; 
    return 
"<a href=\"".(!empty($matches[3]) ? $matches[3] : "http")."://$matches[4]$matches[5]$matches[6]\" target=\"_blank\">$matches[0]</a>";  
}  




function 
ConvertirCortaremail$matches ) { 
    
$limite 40;
    
$matches[0] = (strlen($matches[0]) > $limite) ? substr($matches[0],0,15)."...".substr($matches[0],19-$limite) : $matches[0];
    return 
"<a href=\"mailto:$matches[1]@$matches[2].$matches[3]\">$matches[0]</a>"
}




function 
ponerLinksurl$str ) {
    return 
preg_replace_callback("/((([a-zA-Z]+):\/\/)|(www\.))([\w\.]+)([\#\,\/\~\?\&\=\;\%\-\w+\.]+)/i",'ConvertirCortarurl',$str);
 

}

function 
ponerLinksemail$str ) {
    return 
preg_replace_callback("/([\w\._-]+)@([\w]+)\.([\w\._-]+)/i",'ConvertirCortaremail',$str);

}





$comentario ponerLinksemail(ponerLinksurl($comentario)); 
__________________
Spread Firefox | Download Day 2008
¡Únete en nuestra misión para alcanzar el Record Guinness al software más descargado en 24 horas! http://www.spreadfirefox.com/es-ES/worldrecord/