spambotEmailProtector Encoding problem on save to CSV file

By Mikey - February 12, 2017

I'm building a "save to CSV file" almost identical to the one seen here:

http://www.interactivetools.com/forum/forum-posts.php?postNum=2199282#post2199282

The problem I'm having is that when I download the CSV file and open it, the first row's email address is encoded.

<bdo dir="rtl">&#x6d;&#x6f;&#99;<span>&#46;&#x64;&#110;&#117;&#111;<!-- ynz -->&#x72;&#57;&#x40;<!-- lfu -->&#x73;&#x65;<!-- tzg --><!-- fvy -->&#110;&#111;&#x6a;&#46;&#x79;&#x63;&#110;</span>&#97;&#110;</bdo>

The other email rows are fine.

Is it possible to prevent spambotEmailProtector from encoding emails on a particular website page, so it's disabled on one page, but allow it to continue to work on the rest of the website?

I tried opening the spambotEmailProtector.php file and tried changing some of the Encoding Options to false, but this didn't decrypt the first email in the exported CSV file either.

// Encoding Options - to disable an encoding method set to false;
$GLOBALS['SEP_ENCODING_METHODS']['decEntity']   = true;
$GLOBALS['SEP_ENCODING_METHODS']['hexEntity']   = true;
$GLOBALS['SEP_ENCODING_METHODS']['urlEncoding'] = true;
$GLOBALS['SEP_ENCODING_METHODS']['jsUnicode']   = true;
$GLOBALS['SEP_ENCODING_METHODS']['bdo']         = false;
$GLOBALS['SEP_ENCODING_METHODS']['comments']    = false;
$GLOBALS['SEP_ENCODING_METHODS']['tags']        = false;
$GLOBALS['SEP_ENCODING_METHODS']['jsLocation']  = true;

Below is the save to CSV file code 

<?php 
require_once "C:/wamp/www/cmsbuilder_1_34_build1/cmsAdmin/lib/viewer_functions.php"; 

// load records 
list($saveCSVRecords,) = getRecords(array( 
'tableName' => 'directory', 
//'where' => "paid = '1'" 
)); 

// if the user has supplied "as_csv" in query string
if (@$_REQUEST['as_csv']) {

// specify fields to output 
$fields = array('first_name', 'last_name', 'title', 'address', 'address_2', 'city', 'state', 'zip', 'phone', 'mobile_phone', 'fax', 'toll_free', 'email', 'website_address');

$filename = "directory_".date("Y-m-d_H-i",time()); 
header("Content-type: application/vnd.ms-excel"); 
header("Content-disposition: csv" . date("Y-m-d") . ".csv"); 
header( "Content-disposition: filename=".$filename.".csv"); 

// output csv header row 
print(join(',', $fields) . "\n"); 

// loop over records, outputting a row for each 
foreach ($saveCSVRecords as $recCSVrecord) { 
$row = array(); 
foreach ($fields as $field) { 
$value = $recCSVrecord[$field]; 
// if this value contains a special character, quote and escape it 
if ( preg_match('/[," \t\n]/', $value) ) { 
$value = '"' . preg_replace('/"/', '""', $value) . '"'; 

array_push($row, $value); 

echo(join(',', $row) . "\n"); 
}

// exit -- we are finished with the page
exit;
}

?>
<!DOCTYPE HTML>
<html>
<head>

<title>CSV</title>
<meta charset="utf-8" />
</head>
<body>

<h3><a href="?as_csv=1&<?php echo @$_SERVER['QUERY_STRING'] ?>">Download these results in CSV format</a></h3>

</body>
</html>

Thanks, Zicky

By Mikey - February 12, 2017

Hey Deborah,

I completely overlooked that in the readme.txt file. I feel stupid. : )

I added the line of code, but it didn't work immediately. I took a closer look and realized that I also had an older version of the "spambot Email Protector" running. So I updated the plugin, reactivated the updated plugin, and once I updated it and added the line of code to the top of my page it worked like a charm.

Thank you for your help!

All the best, Zicky

By ross - February 14, 2017

Hi Zicky

Looks like Deborah got you on the right track.

Glad that worked out :).

Keep me up to date with how you are making out.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/