To all those where the plug-in doesn’t work:
At my first try, it didn’t work either. Then I found that my <a>-Tag included a line break (I switched the content input field to HTML to discover that). After I removed the line break, the plug-in worked as expected.
By line break, I mean "\n" and not "
".
Cloudy greetings from Germany
Martin
Hello everyone,
the plugin didn’t work for me too at first (using 0.9.6.2) but I found out that the author startet his plugin with the
<?php which seems to be the problem. So I removed it and also did some small changes in the code. Paste the following lines into your plugin and it should work fine (don’t forget to check "OnWebPagePrerender"):
/**
* NAME: Anti-Spam Email
* DESC: Automatically encodes all email addresses in your site to unicode, it is believed that this will stop spam-bots being able to find your email address, but is not guaranteed.
* @author Ivan Vanderbyl
* @version 1.2
* Based on Email Link Obfuscator 1.0.2 by cyberk.
**/
function replaceEntities($str) {
$str=html_entity_decode($str);
for ($i = 0 ; $i < strlen($str) ; $i++) {
$strreplaced = $strreplaced . '&#' . ord($str{$i}) . ';';
}
return $strreplaced;
}
function emailaddress($matches) {
$strMailtoTag = replaceEntities("mailto:");
$strNewAddress = replaceEntities($matches[1]);
$strText = replaceEntities($matches[2]);
$arrEmail = explode('@',$strNewAddress);
$strTag= '<a href="'.$strMailtoTag.$strNewAddress.'">'.$strText.'</a>';
return $strTag;
}
$modx->documentOutput=preg_replace_callback("#<a[^>]*mailto:([^'\" ]*)['\" ]>([^<]*)</a>#i", emailaddress, $modx->documentOutput);
Forget all plugins/snippets with unicoding addresses. Most harvesters now can "decode" these addresses.
Taking out the first line of <?php worked for me.
No longer works as of version 1.02. It seems to work with 1.0.0 however.
Mostly harmless.
Hello,
the Anti-Spam Email Plugin is working for me in MODx Evo 1.0.0 - but I noticed that when there’s a German "Umlaut" in the string text, it’s not encoded correctly. I’m getting "Rückmeldung" in stead of "Rückmeldung". All other Umlauts are doing well on the site.
Any ideas for that? I tried to insert an utf8_encode to the link text string before the output was rendered but this didn’t change anything.
Thanks!
P.S.: Will upgrading to 1.0.5 make the plugin unfunctional in any way? Not sure if that was the result of the discussion above.