How to hide / encrypt CCK Email field with JS against spammer
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']) ? '<a href="mailto:'. $element['#item']['email'] .'">'. $element['#item']['safe'] .'</a>' : '';
}
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
<script language="javascript" type="text/javascript">
var em_real = [$js_arr2str], em_safe_str = "";
for(i=em_real.length-1; i>-1; i--){ em_safe_str += em_real[i]; }
document.write('<a hr'+'ef="mai'+'lto:'+em_safe_str+'">'+em_safe_str+'</a>');
</script>
hrd;
}
Similar entries
- Hide your email address + mailto link with javascript from spammer
- Drupal does not send Email on Hosteurope
- Google Apps Email - Updating Google servers
- My Yahoo Email Account Hacked, how can I get it back?
- Yahoo Mail Plus + Pop and Mozilla Thunderbird emptied my Inbox, need restore
- Check password safety with JavaScript while typing
- PHP get page title function
- E-Mail validation with Java and regular expressions (regex)
- CCK Text Field in Node-Teaser?
- Sleep Function for JavaScript like PHP
- Between operator in PHP
- Common HTML / Web colors
- Simple Hello World Module for Drupal 6
- Web2 style secure & flexible free php contact form with easy setup
- Language_List and default language as selected option on Drupal 6x
- Get top 100 words / keywords from a text with PHP
- Preload images with JavaScript or CSS
- How to use custom function aliases in PHP
- Web2 Style CSS Dynamic Menu with Arrows and Background-Images

Comments
With multiple email
With multiple email addresses, would be a problem? I mean multiple declaration of "em_real".
Post new comment