tags:

views:

65

answers:

4

Hi All,

I've created my own business directory using CCK but I now need to mask the email addresses so they are unreadable by email spam bots. I also need to hide displaying the address by replacing it with an image.

Are there any modules out there that can do this? Or can anybody provide some code or examples or suggest any ideas.

Any help much appreciated.

Shane

+1  A: 

Use GD:

$img = imagecreate( 200, 80 );
$background = imagecolorallocate( $img, 0, 0, 255 );
$color = imagecolorallocate( $img, 255, 255, 0 );
imagestring( $img, 4, 30, 25, "[email protected]",  $color );

header( "Content-type: image/png" );
imagepng( $img );
Byron Whitlock
Cool, thanks for the answer. But how do I build this into Drupal's views and nodes?
Shane
Throw the code in a function, write the image to a file and check existence every time. If it doesn't exist, call the function otherwise use the already generated image.=
Byron Whitlock
A: 

If you do that (adresses in pictures), please use a not-so-common font, alot of scrapers use OCR (text recognition) and look for email adresses in pictures.

Another way of blocking the scrapers is using 2 images, overlaid one over another, first having the 1st, 3rd, 5th .. of the characters and the second one having the rest. That way you don't have one image with the full adress.

vlad b.
+4  A: 

If it does not have to be images you can use the SpamSpan module, it creates an address like example [at] example [dot] com, which is replaced by the real address by javascript.

Images are annoying, as you have to type the address yourself and can't just click on it. The javascript obfuscation is theoretically beatable, but most likely the bots don't bother.

Fabian
+1  A: 

Thanks everybody for your input..

I decided to go with Fabian - avenue of the Spamspan but did some alterations so I could replace with an image as well (this was just as a user interface reason).

So I installed the Drupal module SpamSpan - I then added this piece of code to my node.tpl.php

<?php        
     if ( $node->type == 'directory' ) {
        // Has this page got a main image?
        $emailAdd = $node->field_email[0]['value'];

        if (strlen($emailAdd) > 0)
        {
            $arrEmail = explode("@", $emailAdd);

            $emailAdd = '<span class="spamspan">
            <span class="u">'.$arrEmail[0].'</span>
            [at]
            <span class="d">' . str_replace(".","[dot]",$arrEmail[1] ) . '</span></span>';

            print $emailAdd;
        }
      }
?>

Then within spamspan.compressed.js I added in the functionaility of displaying an image by replacing the .html function with .html('<img src="' + Drupal.settings.basePath + 'themes/zen/zen-internals/images/btnContactBus.gif">')

Hope this helps somebody else - and thanks again for you guys helping me.

Shane

Shane