开发者

Drupal Mask Email Addresses and Replace With Image

I've created my o开发者_开发知识库wn 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


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.


Use GD:

$img = imagecreate( 200, 80 );
$background = imagecolorallocate( $img, 0, 0, 255 );
$color = imagecolorallocate( $img, 255, 255, 0 );
imagestring( $img, 4, 30, 25, "myemailAddress@domain.com",  $color );

header( "Content-type: image/png" );
imagepng( $img );


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜