Snippet to protect email addresses from spam

doc

Hello,

this is one of the options planned (or the use of GIF with transparent background).
You can define the background color (RGB values) via the the array $bgcolor in the file create_img.php.

Regards Christian

spawnferkel

Hey thank you Christian it is easy to handle and it works very fine, but is it possible to make the background of the png transparancy? Then it were much more integrated in my design. Btw I use your function in the guestbook module.

You did a great job ;-)

doc

@DGEC
Relax a little.

Per default spam protection will be switched off. Javascript encryption is an additional option which can be enabled. However, even with Javascript disabled, users will see the email address in human readable format. The only drawback, mailto links are not clickable when Javascript is switched off.

No AJAX frameworks/routines are used at all. All coding (except mailto decryption when clicking on a mailto: link) is done via PHP. The entire spam protection routine is done via adding one single function to the WB core.

As I have offered to send the code to everyone interested in, I was wondering why you do so much interpretation on how things may work instead of simply testing it and give some feedback.

Regards Christian


DGEC

#8
Quote from: doc on May 09, 2007, 05:35:46 AM
Just to mention. I have modified some core files to integrate this feature by default with one of the next WB versions. The update protects all emails displayed at the WB frontend without any additional coding. All embedded mails yourname@yourdomain.com or mailto:yourname@yourdomain.de will be protected that way. The protection works the same way like the one implemented in Typo3.
Regards Christian

Christian, I HOPE you are making this optional? 

Not everybody likes or has have javascript on/working-correctly, despite the popularity of AJAX.  I saw something not long ago that said all of the major AJAX toolkits have a huge security flaw.

There really should be an option to turn it off, at least in the site settings, if not in individual member profile configuration. 

Hmm... nicest method might be to have an email obscuration module function - you could set it to NONE, JS, IMAGE, etc, as methods are implemented.  Especially if there are member only areas, you really don't need that feature.

For example, on my Palm Blazer, JS doesn't always work with logins - I can't log into my router for example, which I'd really like to be able to do from my Palm, and the Admin back-end of WB isn't much fun with it either.

And I've seen claims that at least some of the harvesters can read JS. I had done several things to some of my addresses and went to a testing site - it read it all easily.  I gave up.

What I'd like to do is be able to use a form instead. I.e. use a drop-down or a radio-button to pick who you want to email, and send any comment to the selected person.  Now of course, only one email is possible.

tomhung


<script type="text/javascript">
function fixemail(id, username){
a = '@';
$(id).href='mail' + 'to:' + username + a + 'northwind-inc' + '.' + 'com';
}

</script>

<a href="#" id="contactus1" onclick="fixemail(this.id,'contactus')">



thats what i use.  it requires prototype.js

marathoner

I'd be interested in seeing these modifications to the core files...sounds like a wonderful addition.

P.S. I know you hate to set expectations too high...but do you know when WB 2.7 might be released? Is it a matter of weeks, months, or a year away?

doc

Hello,

thanks for your feedback.

Have added a function to the WB core, which protects email addresses displayed on all frontend (WYSIWYG) pages without adding any code. The function scans for valid email addresses (incl. mailto: links) and modifies them like (yourmail@domain.com => yourdomain(at)domain(dot).com). It is possible to define replacements for @ and . (dot) in the top level domain part. Images are possible too. Mailto links are encrypted via Javascript and clickable if JS is enabled.

If you are interested, I can send you the core file adaptions. It´s planned to add this function to WB2.7.

Regards Christian

Panther

slick stuff...

Only change I would recommend is in the image alignment

$out = ' <a><img align="middle" border="0" src="' . $url . '"' . $js . '></a> ';
In Firefox this aligns the middle of the image with the bottom of the surround text.

If you change it to
$out = ' <a><img align="absmiddle" border="0" src="' . $url . '"' . $js . '></a> ';
Firefox will align the center of text with the center of the image.

IE treats both the same I believe.

This is handy so you can use echo in the code section you call this function to place text around the image tag.

example here: http://baker.mnpages.com/pages/snippets/no-spam.php

doc

Hello,

you need to use mlink("yourname@yourdomain.com"); in code pages.
In addition you need to add the following line into the <head> section of the index.php file of your template to get things working.<script type="text/javascript" src=" <?php echo WB_URL?>/modules/nospam/nospam.js"></script>

Just to mention. I have modified some core files to integrate this feature by default with one of the next WB versions. The update protects all emails displayed at the WB frontend without any additional coding. All embedded mails yourname@yourdomain.com or mailto:yourname@yourdomain.de will be protected that way. The protection works the same way like the one implemented in Typo3.

Regards Christian

jensl1972

Hi all!

I can't seem to get this working.

Do I use:
mlink("yourname@yourdomain.com");

in code view or do I use

<?php mlink("yourname@yourdomain.com"); ?>

in code view?

Any help would be greatly appreciated.

doc

#1
Hello,

found some threads dealing with email obfuscation or email protection here in the forum.

As I had similar problems with spam caused by unprotected mail addresses I wrote a small code snippet which creates clickable images of email addresses. In case the users has Javascript enabled, an clickable mailto: link is generated in addtion to the image.

Installation and usage:
a) download the attached code snippet and install it via the WB backend
b) add the following code line into the index.php file of your template
  <script type="text/javascript" src=" <?php echo WB_URL?>/modules/nospam/nospam.js"></script>
c) create a code page and enter mlink("yourname@yourdomain.com");
d) view the page in the WB frontend

Customisation:
If you have long email addresses to protect (>48 characters), set the variable $maxlen in include.php to a higher value. If you want to change foreground and background color, padding or text size of the mail image to be created, have a look into the file create_img.php.

Limitations:
The function can only be invoked from a code page or from the index.php file of your template.
Images are not cached yet, so a huge amout of images may slow down your side.
Remind the ; after mlink("yourmail@yourdomain.com");

Best regards
Christian

[gelöscht durch Administrator]