Image Email script, the spam solution!
Heres a useful trick if you dont want to receive spam in your email inbox when you display your email on a highly popular website.
Create an email.php page containing this script:
// Variables configuration
$emails[1] = "info@domain.com";
$emails[2] = "test@domain.com";
//$emails[n] = "anything@domain.com";
$pathToFont = "fonts/arial.ttf"; //System Font File
// Default variables
$maxWidth = 150;
$maxHeight = 16;
$paddding = 12;
$size = 10;
$background = "ffffff";
$color = "000000";
$emailAddress = "email@domain.com";
// Get 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;
// Color converter function
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;
}
// Create the 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"]);
// Add the background color
imagefilledrectangle($im, 0, 0, $maxWidth-1, $maxHeight-1, $backgroundColor);
imagecolortransparent($im, $backgroundColor);
// Size configuration
$coord = imagettfbbox ( $size ,0 , $pathToFont , "($emailAddress)" );
if($coord[2] > $maxWidth) $size = 9;
// Image Email creation
imagettftext ( $im, $size , 0 , 0 , $paddding , $fontColor, $pathToFont , $emailAddress );
// Display the image in the browser
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
We use it like this:
email.php?email=1&color=F0F0F0&background=000000&width=220&height=16&padding=12
The variables are:
email: The email we want to display (declared in the script)
color: Font color
background: Background color
width: Image width
height: Image height
padding: Padding inside the image
Here's the final result of what it looks like:
NOTE: The GD2 library must be "enabled" in your PHP config.
Categories
All articles, Design, E-Commerce, Free stuff, Internal, Mobile, Web Marketing,
Tags
htaccess, la presse, marketing, Montréal, rewriteCond, affaires, amazon, apache, apple, archambault, autoVer, back-up, backup, canada, commerce en ligne, Compétition, ebay, email, entreprises, fichiers,


Comments
No comments at this time
Write a comment