Hide e-mail addresses from spammers

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Hide e-mail addresses from spammers

Post 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. :)
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Hide e-mail addresses from spammers

Post 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
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Re: Hide e-mail addresses from spammers

Post 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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Hide e-mail addresses from spammers

Post 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  :)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Re: Hide e-mail addresses from spammers

Post 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.
Last edited by Hypocrite on Mon May 24, 2010 7:25 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Hide e-mail addresses from spammers

Post 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 :D ).

grtz. Rolf  :)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Hide e-mail addresses from spammers

Post 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.  ;D
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Hide e-mail addresses from spammers

Post by calguy1000 »

Did you guys actually read the smarty manual... there's a {mailto} tag.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Hide e-mail addresses from spammers

Post by Rolf »

calguy1000 wrote: Did you guys actually read the smarty manual... there's a {mailto} tag.
Yep  :D

{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  :)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Re: Hide e-mail addresses from spammers

Post 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.
Post Reply

Return to “Tips and Tricks”