zhangy Posted December 5, 2008 Share Posted December 5, 2008 Hi, I want to protect email addresses from harvesters. but the emails arent static. they are always new ones being entered into database and then displayed on webpage from there so its not like i can dump an email or two into a scrambler. I get dozens of new emails all the time and i want to protect them when they are selected and echoed to a webpage from database. understand? Does anyone know a way to protect these emails from spam harvesting bots? Thanks! Quote Link to comment Share on other sites More sharing options...
gevans Posted December 5, 2008 Share Posted December 5, 2008 I'm sure people will give you a few different options, personally I use this code; <?php /*################################ *Writes string as image *$s=string;(text)$fs=font size;(pt)$fc=font color;(hex)$bc=background color(hex) *Created: 6 October 2008 *Updated: 7 October 2008 *Copyright Purple Coffee Interactive *Written by Gareth Evans */################################ class emailImageDisplay{ //var $font = 'fonts/monofont.ttf'; var $font = 'fonts/lsu.ttf'; function emailImageDisplay($s,$fs,$fc,$bc){ $pixelfs = $fs; do{ $fs--; $txtbox = imagettfbbox($fs, 0, $this->font, $s); } while(abs($txtbox[5]-2)>$pixelfs); $w = ($txtbox[2]+3); $h = abs($txtbox[5]-4); $img = @imagecreate($w,$h); $brgb = $this->hexToRGB($bc); $bgcolor = imagecolorallocate($img, $brgb[0], $brgb[1], $brgb[2]); $frgb = $this->hexToRGB($fc); $fontcolor = imagecolorallocate($img, $frgb[0], $frgb[1], $frgb[2]); $x = 1; $y = abs($txtbox[5]); imagettftext($img, $fs, 0, $x, $y, $fontcolor, $this->font , $s) or die(); header('Content-Type: image/jpeg'); imagegif($img); imagedestroy($img); } function hexToRGB($hexc){ $c_array[] = hexdec(substr($hexc,0,2)); $c_array[] = hexdec(substr($hexc,2,2)); $c_array[] = hexdec(substr($hexc,4,2)); return $c_array; } } $s = (isset($_REQUEST['s']))? $_REQUEST['s'] : ''; $fs = (isset($_REQUEST['fs']) && is_numeric($_REQUEST['fs']))? $_REQUEST['fs'] : 12; $fc = (isset($_REQUEST['fc']))? $_REQUEST['fc'] : '555555'; $bc = (isset($_REQUEST['bc']))? $_REQUEST['bc'] : 'ffffff'; $email_image = new emailImageDisplay($s,$fs,$fc,$bc); ?> put that in a file /include/sec_img.php <?php <div style="float: left;"> <img style="padding-top: 3px;" src="include/sec_img.php?s=gareth@purplecoffee.co.uk&fs=12&fc=555555&bc=ffffff" alt="" /> </div> <span style="font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;color: #555555;font-size: 12px;">gareth@purplecoffee.co.uk</span> ?> put that in a file called index.php (next to the include folder) the rest should be self explanitory Quote Link to comment Share on other sites More sharing options...
burnside Posted December 5, 2008 Share Posted December 5, 2008 not the best way but i used this once worked: // selcet date etc ... $e_array = ('@'); $c_array = ('(at)'); $row['emai'l] = str_replace($e_array, $c_array, $row['email']); A;; that will do is replace @ with (at) so email will look like myemail(at)myemail.com there will be a ton of better ways to do it but i used that and didnt give me any problems. Quote Link to comment Share on other sites More sharing options...
gevans Posted December 5, 2008 Share Posted December 5, 2008 Sorry, you also need fonts, make a folder called fonts inside include and add the fonts you want to use (.ttf) set in the emailImageDisplay class Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 5, 2008 Share Posted December 5, 2008 You could display them using JavaScript, for example: <script> onload=function(){ // Scramble up the email a bit var e1 = 'il.c'; var e2 = 'ema'; var e3 = 'om'; var e4 = 'il@'; var e5 = 'ema'; // Display the email document.getElementById('disE').innerHTML = e2+e4+e5+e1+e3; } </script> <span id="disE"></span> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.