Search Site:








Edit - To Do - AllRecentChanges

Recent Changes Printable View Page History Edit Page

Obfuscated email

Throughout this site, I use email addresses that appear in clear to people browsing them.

The main issue with email on webpages is that they get systematically collected by spammers using web spiders. Good thing is that these robots are not that sophisticated and are usually only able to identify well known email patterns.

I've been using a short JavaScript snippet that I use in the source of webpages to dynamically write the proper HTML mailto: URL only when executed. Additionally, even if a robot could execute it, it would need to be quite complex to actually retain the output of the script and be able to collect potentially interesting information.

This directive is simply used in pmwiki as (:email The email address string will be stored as a JavaScript variable in reverse order and dynamically reconstructed when needed.

To use this new directive, simply copy the following into a file saved under cookbook/emailobfuscator.php:

<?php if (!defined('PmWiki')) exit();
# V1.0
/* Email obfuscation directive (:email :) */

Markup('email','directives','/(:emails(.*?):)/e', "emailobfstcf('$1')");

function emailobfstcf($Email){
$Email = strrev(trim($Email));
$l= Keep("<script language='JavaScript'>
var m='>A/<"
Keep(":otliam'=FERH a<';
var n='';
for (i=m.length-1; i>=0; i--) { n += m.charAt(i); }
return $l;

Don't forget to include a reference to it in your config.php file:

# Include the email obfuscator script

That's all there is to it, (:email will simply become .

Leave your comments below
Enter your comment (no links allowed): Author:

Edit Page - Page History - Printable View - Recent Changes - WikiHelp - Search - RSS -
Page last modified on Monday 04 July 2005, at 04:28 GMT+8 - Viewed 2358 times