Page 1 of 1
Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 1:40 pm
by Hypocrite
I have been thinking about how to easily hide e-mail address from spammers in the website.
Here's one solution.
1. First use some email obfuscator to crypt the e-mail address. One example is:
http://www.fingerlakesbmw.org/main/flobfuscate.php. The good thing about this one is that it doesn't use JavaScript to hide the e-mail address.
2. Change TinyMCE to use numeric codes for characters in the settings: Modules -> TinyMCE -> Advanced.
3. Open the page you want to add the safe e-mail address. Go to the HTML view and paste the code you just created.
Now you can get a mailto: -link without spammers getting the e-mail address.
If someone has good ideas to how to make the process easier for average users, let me know.

Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 2:03 pm
by Rolf
Hi Hypocrite
There are several plugins in the Forge who will help you with this.
I always use:
http://dev.cmsmadesimple.org/projects/email
Just put in the content something like:
{email address="
some-name@address.com"}
or
{email address="
some-name@address.com" linkname="Mail me" class="my-style"}
Regards Rolf
Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 5:11 pm
by Hypocrite
I have checked that plugin before and in my opinion it doesn't work as intended.
If I put your {email address="
some-name@address.com"} in my page I get the following code:
Code: Select all
<__script__ type="text/javascript" language="javascript">
<!--
// eMail Obfuscator Script 2.1 by Tim Williams - freeware
{
coded = "8P0aBCwPFs@asIPC7s.qs"
cipher = "ZabcXYdeWVfUTghSiRQjklPmONnMoLpqKJrIHstGuFvEwDxCyBz1A234568790"
shift=coded.length
link=""
for (i=0; i<coded.length; i++){
if (cipher.indexOf(coded.charAt(i))==-1){
ltr=coded.charAt(i)
link+=(ltr)
}
else {
ltr = (cipher.indexOf(coded.charAt(i))-shift+cipher.length) % cipher.length
link+=(cipher.charAt(ltr))
}
}
document.write("<a href=\'mailto:"+link+"\'>email</a>")
}
//-->
</__script>
<a href="mailto:test@address.com">email</a>
The e-mail address is still visible in the source code.
The more important thing and the deal breaker to me is that usually clients want that their e-mail addresses are visible on the website because the information about the e-mail address is iimportant also, not just the mailto-link. And the plugin doesn't support that option at all.
Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 5:30 pm
by Rolf
Hypocrite wrote:
The e-mail address is still visible in the source code.
I am shure it is not
Your posted code reproduces an mail address like
xxxxmaki@vihaxxxx.fi and not
test@address.com.
Isn't it?
I can't find this in the sourcecode.
So if you find this email in your pagecode, it was there before...
grtz. Rolf

Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 7:18 pm
by Hypocrite
You are correct of course, my mistake. The e-mail address is not visible in the source code.
And I managed to fix my second problem also by modifying the function.email.php
The original script had a line like this:
Code: Select all
document.write(\"<a $class href=\'mailto:\"+link+\"\'>$linkname</a>\")
I changed it to:
Code: Select all
document.write(\"<a $class href=\'mailto:\"+link+\"\'>\"+link+\"</a>\")
Now the crypted e-mail address is also displayed but still crypted.
Source code produced:
Code: Select all
<__script__ type="text/javascript" language="javascript">
<!--
// eMail Obfuscator Script 2.1 by Tim Williams - freeware
{
coded = "8P0aBCwPFs@asIPC7s.qs"
cipher = "ZabcXYdeWVfUTghSiRQjklPmONnMoLpqKJrIHstGuFvEwDxCyBz1A234568790"
shift=coded.length
link=""
for (i=0; i<coded.length; i++){
if (cipher.indexOf(coded.charAt(i))==-1){
ltr=coded.charAt(i)
link+=(ltr)
}
else {
ltr = (cipher.indexOf(coded.charAt(i))-shift+cipher.length) % cipher.length
link+=(cipher.charAt(ltr))
}
}
document.write("<a href=\'mailto:"+link+"\'>"+link+"</a>")
}
//-->
</__script>
<noscript>
no javascript, no e-mail!<br />
</noscript>
Thanks a lot for pointing me to the right direction.
Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 7:26 pm
by Rolf
Hypocrite wrote:
But the second argument about the e-mail address being visible to human eye still stands.
Yep, using the mailto option the mail address will always be visible, in the browser or in the last place in the email itself...
If somebody really don't want his mail address known to the world, he should use a contact-form (with captcha

).
grtz. Rolf

Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 7:41 pm
by Rolf
Hypocrite wrote:
The original script had a line like this:
Code: Select all
document.write("<a $class href=\'mailto:"+link+"\'>$linkname</a>")
I changed it to:
Code: Select all
document.write("<a $class href=\'mailto:"+link+"\'>"+link+"</a>")
Now the crypted e-mail address is also displayed but still crypted.
Nice mod.

Re: Hide e-mail addresses from spammers
Posted: Mon May 24, 2010 7:44 pm
by calguy1000
Did you guys actually read the smarty manual... there's a {mailto} tag.
Re: Hide e-mail addresses from spammers
Posted: Tue May 25, 2010 9:29 am
by Rolf
calguy1000 wrote:
Did you guys actually read the smarty manual... there's a {mailto} tag.
Yep
{mailto address="
bill.gates@microsoft.com" encode="javascript"}
{mailto address="
bill.gates@microsoft.com" encode="hex"}
But I just like the {email} tag more, because you don't need to add the extra parameter.
If you need this only one time -no problem- but when you need it f.i. creating News items every time, it is just easier...
But that is just my (lazy) opinion... :P
®olf

Re: Hide e-mail addresses from spammers
Posted: Wed May 26, 2010 7:04 am
by Hypocrite
Heh, good point calguy.
Let's try another trick if it would be a better tick.
This one adds a new button to the toolbar in TinyMCE. When selecting an e-mail address from the content and pressing the button, it automatically wraps the e-mail address into the smartytag.
Steps to do this:
2. First upload a new icon to somewhere on your server, I used the uploads/images folder. The image needs to be a gif image with the dimensions of 20x20 pixels. Best way is to use a transparent image with just the icon.
1. Go to TinyMCE settings and first open the Advanced tab.
2. Paste this into the Extra configuration field:
Code: Select all
setup : function(ed) {
ed.addButton('email', {
title : 'E-mail',
image : 'http://www.domain.com/uploads/images/email.gif',
onclick : function() {
ed.focus();
ed.execCommand('mceReplaceContent',false,'{email address="{$selection}"}')
}
});
}
3. Change the path to the image file to the above code.
4. Now change to the Profile tab in TinyMCE and add the button 'email' somewhere in the toolbar.
5. You're done.