Image Email script, la solution au spam!
Voici un truc très simple pour ne pas recevoir de spam dans votre boîte courriel lorsque vous affichez votre courriel sur un site web avec une haute popularité.
Créé une page email.php contenant ce code:
// Configuration des variables
$emails[1] = "info@domaine.com";
$emails[2] = "test@domaine.com";
//$emails[n] = "nimportequoi@domaine.com";
$pathToFont = "fonts/arial.ttf"; //Fichier police système
// Variables par défaut
$maxWidth = 150;
$maxHeight = 16;
$paddding = 12;
$size = 10;
$background = "ffffff";
$color = "000000";
$emailAddress = "courriel@domaine.com";
// Réception des variables
$maxWidth = (isset($_GET['width'])) ? (integer)$_GET['width']:$maxWidth;
$maxHeight = (isset($_GET['height'])) ? (integer)$_GET['height']:$maxHeight;
$paddding = (isset($_GET['padding'])) ? (integer)$_GET['padding']:$paddding;
$size = (isset($_GET['size'])) ? (integer)$_GET['size']:$size;
$background = (isset($_GET['background'])) ? ($_GET['background']):($background);
$color = (isset($_GET['color'])) ? ($_GET['color']):($color);
$emailAddress = (isset($emails[$_GET['email']])) ? ($emails[$_GET['email']]):$emailAddress;
// Fonction convertisseur
function hexToRGB($hex) {
$hex = str_replace("#", "", $hex);
$color = array();
if(strlen($hex) == 3) {
$color['r'] = hexdec(substr($hex, 0, 1) . $r);
$color['g'] = hexdec(substr($hex, 1, 1) . $g);
$color['b'] = hexdec(substr($hex, 2, 1) . $b);
}
else if(strlen($hex) == 6) {
$color['r'] = hexdec(substr($hex, 0, 2));
$color['g'] = hexdec(substr($hex, 2, 2));
$color['b'] = hexdec(substr($hex, 4, 2));
}
return $color;
}
// Création d'une image
$im = imagecreatetruecolor($maxWidth, $maxHeight);
$rgb = hexToRGB($background);
$backgroundColor = imagecolorallocate($im, $rgb["r"], $rgb["g"], $rgb["b"]);
$rgb = hexToRGB($color);
$fontColor = imagecolorallocate($im, $rgb["r"], $rgb["g"], $rgb["b"]);
// Ajoute la couleur en fond
imagefilledrectangle($im, 0, 0, $maxWidth-1, $maxHeight-1, $backgroundColor);
imagecolortransparent($im, $backgroundColor);
// Configuration de la taille
$coord = imagettfbbox ( $size ,0 , $pathToFont , "($emailAddress)" );
if($coord[2] > $maxWidth) $size = 9;
// Création de l'image email
imagettftext ( $im, $size , 0 , 0 , $paddding , $fontColor, $pathToFont , $emailAddress );
// Affiche l'image sur le navigateur
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
Ensuite, il suffit d'apeller dynamiquement cette page et de lui passé les paramètre voulu pour afficher un courriel en image.
On l'utilise comme suit:
email.php?email=1&color=F0F0F0&background=000000&width=220&height=16&padding=12
Les variables sont:
email: La référence au courriel que l'on veut afficher (déclaré dans le script)
color: La couleur de la police
background: Couleur du fond
width: largeur de l'image
height: hauteur de l'image
padding: espacement à l'intérieur de l'image
Voici à quoi sa ressemble au final:
NOTE: La librarie GD2 doit être "enabled" dans votre configuration de PHP.
Catégories
Tous les articles, Commerce en ligne, Design, Gratuit, Interne, Marketing web, Mobile, Web,
Tags
quétaine, Sparko, Montréal, java, JCCM, médias sociaux, twitter, Agence de développement web, apple, Entrepreneurs, Entrepreneurship, facebook, htaccess, la presse, marketing, médias, publicité, rewriteCond, site quétaine, social media,


Commentaires
Il n'y a aucun commentaire pour le moment.
Écrire un commentaire