How to hide / encrypt CCK Email field with JS against spammer

Submitted by n8coder on Tue, 02/09/2010 - 17:58

I got headche while searching for a filter to encrypt/hide email cck field to protect email addresses from spambots. I have installed , deinstalled, activated-deactivated rearranged input filters with both invisimail and spamspan but no luck! Finally I decide to change code in email.module. It works! Go and open "sites/all/modules/email/email.module" and find the line 115 like this:


/**
* Theme function for 'default' email field formatter.
*/
function theme_email_formatter_default($element) {
return !empty($element['#item']['safe']) ? ''. $element['#item']['safe'] .'' : '';
}

replace line 118-120 with following


function theme_email_formatter_default($element) {

$str = trim( $element['#item']['safe'] );
if( !$str ) return;

for($i=strlen($str)-1; $i>-1; $i--) { $arr[] = "'".substr($str, $i, 1)."'"; }

$js_arr2str = implode(", ", $arr);

return <<

hrd;

}