Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/02/2010, 09:02
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Respuesta: Subrayar texto de imagen - GD

Asi quedo:

mailguard.php :
Código PHP:
<?php
/*
MAIL GUARD V 1.0
ULTIMA ACTUALIZACION: 15/02/2010
*/



// Validar mail
function mailvalido($mail){
if (isset(
$mail) && !empty($mail)){
$res preg_match_all"/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i",$mail,$matches);
    if (
$res) {
        
$resultado=$matches[0][0];
    }else{
        
$valido=false;
        
$resultado='';
    }
    return 
$resultado;
}
}


// CONFIGURACION
$arroba='*arroba*'// editar esto con lo que se te ocurra
$fuente "arial.ttf"// ubicacion del archivo de fuente
$anchoimagen="136"// ancho predeterminado


// recibe el mail y lo convierte
if(isset($_GET['txt']) && trim($_GET['txt']) != ''){
    
$mail=trim($_GET['txt']);
    
$mail=str_replace($arroba,'@',$mail);
    
$mail=substr($mail,0,150);
}

// valida el mail, si no es valido asigna el mail de ejemplo
if(mailvalido($mail) == ''){
    
$mail='[email protected]';
}else{
    
$mail=mailvalido($mail);
}



// datos externos de configuracion
if(isset($_GET['width']) && (intval($_GET['width']) > 0)){
    
$anchoimagen=intval($_GET['width']);
}


// Creando la imagen
$im imagecreate($anchoimagen,12); 

//Ponemos el fondo de la imagen
$fondo=imagecolorallocate($im255255255);

//Ponemos el color del texto.
$color=imagecolorallocate($im0,0,255);

//Escribimos el texto en la imagen
imagettftext($im10009$color,$fuente,$mail);

//Creamos el subrayado
imageline($im010$anchoimagen10$color); 

// Damos salida de la imagen PNG al navegador
imagepng($im);

// liberamos la memoria
imagedestroy($im);

// envio la cabecera para que los navegadores reconoscan como imagen
header("Content-type: image/png");
?>
ejemplo.html :
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mail Guardian V 1.0</title>
<script language="javascript" type="text/javascript">
function mailcontacto(){
	var inic = 'mailto:';
	var user = 'info';
	var arob = '@';
	var dominio = 'ajxchat.com';
	document.location.href=inic+user+arob+dominio;
}
</script>
</head>

<body>
<h1>Mail Guardian V 1.0</h1>
<p><a href="#" onclick="mailcontacto();"><img src="mailguard.php?txt=info*arroba*dominio.com&width=109" border="0" /></a></p>
<p>
  <textarea name="textfield" cols="50" rows="5"><a href="#" onclick="mailcontacto();"><img src="mailguard.php?txt=info*arroba*dominio.com&width=109" border="0" /></a></textarea>
</p>
</body>
</html> 

y por ultimo poner en la raiz el archivo: arial.ttf
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)