WebsiteBaker Support (2.8.x) > Droplets & Snippets

Snippet to protect email addresses from spam

(1/8) > >>

doc:
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

--- Code: ---  <script type="text/javascript" src=" <?php echo WB_URL; ?>/modules/nospam/nospam.js"></script>
--- End code ---
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]

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:
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.
--- Code: ---<script type="text/javascript" src=" <?php echo WB_URL; ?>/modules/nospam/nospam.js"></script>
--- End code ---

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

Panther:
slick stuff...

Only change I would recommend is in the image alignment


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

If you change it to

--- Code: ---$out = ' <a><img align="absmiddle" border="0" src="' . $url . '"' . $js . '></a> ';
--- End code ---
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,

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

Navigation

[0] Message Index

[#] Next page

Go to full version