ENCRYPTING E-MAIL ADDRESSES AND HYPERLINKS WITH THE SPAMBOTEMAILPROTECTOR PLUGIN - Dec 29th, 2018


OK, so I’m slow to adopt things for just the sake of doing it. You know, if it ain’t broke, don’t fix it.

Well, this time it was “broke” so I didn’t have any choice.

I had been using the “emailcode.class”email encryption scheme described later in this recipe and was really happy
with the results. Yes, it meant encoding the e-mail addresses in a special way, but once I got the hang of it, it was
pretty easy.

The problem appeared when I tried to email a web page containing an encrypted email address (using IE and the
File>Send>Page by Email feature) and the addresses in the email either didn’t work or didn’t show up at all.

Enter the Spambot Email Protector plugin from Interactive Tools.

Problem is that the latest version (2.00) of the spambotEmailProtector plugin solved an earlier problem where only the
first email address on a page was encrypted.

However, it created another problem because it broke links like PayPal Buttons that rely on an email address for
payments and such.

Until all of these issues are resolved in a new version of the plugin, Robin Brayer from Interactive Tools came up with
an interim solution that allows you to turn off the spambot protector on a particular page.

You can download his beta version of the spambot protector plugin from:

http://thecmsbcookbook.com/downloads/spambotEmailProtector.zip

If you don't want the spambot plugin to run on a particular viewer, add this line to the top of the viewer code.

Note: it need to be the top, above any includes.



$GLOBALS['SEP_DISABLED'] = 1;



There are also some changes that you might want to make in the settings at the top of the page to fix other issues that
you find:

Near the top of the spambot-email-protector.php you’ll find a list of Encoding Options, change this:




$GLOBALS['SEP_ENCODING_METHODS']['jsLocation'] = true;



To this:



$GLOBALS['SEP_ENCODING_METHODS']['jsLocation'] = false;



I also found that unless I changed this:



$GLOBALS['SEP_ENCODING_METHODS']['bdo'] = true;



To this:



$GLOBALS['SEP_ENCODING_METHODS']['bdo'] = false;



When a page was sent by the above method, the email addresses appeared backwards.

Other options may cause other strange results, and you can't break the plugin, so experiment until you find the set of
options that works for you.

That’s it. An added benefit is that any standard email format or hyperlink on the page is automatically encrypted, so
it’s easy to encrypt emails and web addresses that are pulled from the database without any special formatting.

And, the encryption works on any web page that uses PHP, whether it's part of a CMSB managed site or not.

The only requirement is that you insert this line of code at the head of your page, after the /viewer_functions.php call
if it's a CMSB viewer:




<?php include_once "/your_path_to/spambot-email-protector.php" ?>



If you need to find the path, just call the spambot-email-protector.php file from your browser and the path will be
listed.

Well worth the $39.95. You can purchase the SPAMBOT EMAIL PROTECTOR at:

http://www.interactivetools.com/order/




Even though I've opted to use the SPAMBOT EMAIL PROTECTOR, there’s another method that’s worth discussing. A big
thanks to Djulia for unearthing this and refining it for use with CMSB.

Copies of the files discussed below can all be downloaded from:

http://www.thecmsbcookbook.com/downloads/email_encryption.zip

In a multi-record CMSB database that contained the e-mail field “e-mail”, here’s the usual unencrypted code to
pull an e-mail address from a record:


<a href=”<?PHP echo $record['e_mail'] ?>”>Email</a>
_


The encryption method, the unrefined version of which is documented at:

http://aspirine.org/emailcode.php_en.html

requires the file “emailcode.class.php” exists in the location entered in the “require” statement below . ***
Djulia found a bug in the original file, so use the one that you download from

http://www.jkwebdesigns.com/email_encryption.zip

This is the code that must get inserted at the beginning of the body section of your web page:


<?PHP
require 'emailcode.class.php';
$emailcode = new ClassEmailcode();?>



On a list page insert this code where you want the encrypted e-mail address to appear (inside an appropriate foreach
loop):


<?PHP echo $emailcode->emailgetencode($record['e_mail'],'VISIBLE TEXT','Your mail subject','YOURCLASS','xhtml'); ?>



For a detail page, you’d use this code:


<?PHP echo $emailcode->emailgetencode($your_tableRecord['e_mail'],'VISIBLE TEXT','Your mail
subject','YOURCLASS','xhtml'); ?>



(To include a “subject” line in the generated e-mail message, include 'Your mail subject', as the 3rd parameter in
the statement. If you don’t want a subject line, take out the text, but leave the ‘’”.)

If you want to encode a single e-mail address on a page or one that’s not pulled from the database, insert this code
where you want the encrypted e-mail address to appear:


<?PHP echo $emailcode->emailgetencode('yourmail@yourprovider.com','VISIBLE TEXT','Your mail
subject','YOURCLASS','xhtml');
?>



IF YOU WANT TO USE AN IMAGE INSTEAD OF TEXT FOR YOUR LINK

You can use:


<?PHP echo $emailcode->emailgetencode($record['e_mail'],'<img border="0" src="images/yourimage.jpg">','Your mail
subject','YOURCLASS','xhtml'); ?>


(.jpg and .gif are OK too)

IF YOU WANT TO PULL THE IMAGE FROM YOUR DATABASE

Since you cannot put PHP tags inside a string inside a PHP call. Here's an alternate approach which was provided by
Chris from Interactive Tools:

The following code will find the first image in the e-mail_logo field and generate an <img> tag for it, or use the
string "You can click here to e-mail us" if no image is available, then pass that off to $emailcode->emailgetencode().


<?php
$visibleText = "You can click here to e-mail us";
foreach (
$yourRecord['e-mail_logo'] as $upload):
if (
$upload['isImage']):
$visibleText = "<img src=".$upload['thumbUrlPath']." width=".$upload['width']." height=".$upload['height']." border='0'
alt='' />";
break;
endif;
endforeach;
echo
$emailcode->emailgetencode($common_informationRecord['contact_e_mail'],$visibleText,'','special','xhtml');
?>


They may be hard to see, but don’t forget the periods which are the concatenation operator in PHP and which joins two
string together.



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service