<?php //  ۞// text{ encoding:utf-8; bom:no; linebreaks:unix; tabs:4; }
                                 
$secure_email_img['version'] = '0.1';
/*

    simple secure email image

    displays your email address as an image, which should prevent
    harvesters from stealing it, and feeding it spam.

    To use:

        simply insert this as an image wherever you would put your email
        address, e.g..

            Send me an email, here: <img src="/path/to/this-script.php" alt="my addy" style="vertical-align:bottom;border;0"/>

    ;o) Cor

*/


// prefs..
//

$secure_email_img['address'] = 'zroc@corz.org';

// text size
// 1-5
$secure_email_img['text_size'] = 5;

// border around the text. in pixels..
//
$secure_email_img['border'] = 1;

// background color..
$secure_email_img['background'] = '#fff7d1';

// text color..
$secure_email_img['text_color'] = '000000';

//
// end prefs.


// okay, let's go..
//

// transform user preferences..
//
$secure_email_img['background'] = hex2dec($secure_email_img['background']);
$secure_email_img['text_color'] = hex2dec($secure_email_img['text_color']);

$secure_email_img['img_width'] =  (imagefontwidth($secure_email_img['text_size']) * strlen($secure_email_img['address']))
                                                                                        + (
$secure_email_img['border'] * 2);

$secure_email_img['img_height'] =  imagefontheight ($secure_email_img['text_size']) + ($secure_email_img['border'] * 2);

// open image and lay email text on it..
$secure_email_img['img'] = imagecreate($secure_email_img['img_width'], $secure_email_img['img_height'] );
$secure_email_img['bg'] = imagecolorallocate($secure_email_img['img'], $secure_email_img['background'][0], $secure_email_img['background'][1], $secure_email_img['background'][2]); // email_img['bg']
$secure_email_img['txtcol'] = imagecolorallocate($secure_email_img['img'], $secure_email_img['text_color'][0], $secure_email_img['text_color'][1], $secure_email_img['text_color'][2]); // email_img['bg']

imagestring($secure_email_img['img'], $secure_email_img['text_size'], $secure_email_img['border'],
                                
$secure_email_img['border'], $secure_email_img['address'], $secure_email_img['txtcol']);

// send the image
header("Content-type: image/jpeg");
imagejpeg($secure_email_img['img']);
imagedestroy($secure_email_img['img']);

/*
function hex2dec()
convert an HTML #hex colour to decimal colour levels..    */
function hex2dec($rgb) {
    if (
substr($rgb01) == "#") {
        
$rgb substr($rgb1);
    }
    
$r hexdec(substr($rgb02));
    
$g hexdec(substr($rgb22));
    
$b hexdec(substr($rgb42));
return array(
$r$g$b);
}
/*
end function hex2dec()    */

?>
back to the source menu
test

Welcome to corz.org!

Since switching hosts (I hope you are alright, Ed! Wherever you are …) quite a few things seems to be wonky.

Juggling two energetic boys (of very different ages) on Coronavirus lockdown, I'm unlikely to have them all fixed any time soon. Mail me! to prioritise!