Email Link Obfuscator
Email Link Obfuscator 1.0.2
Plug-in to automatically obfuscate email links with Javascript.
No guarantees as to the spambot-proofness of the actual obfuscation, and please note that it does NOT obfuscate email addresses that are written outside a mailto: link.
Here's a page that uses the obfuscation:
http://athleticmindedtraveler.com/about_us/contact_us.php
If you want to see what the generated code looks like, do a "View Source."
2. Under System Events, check the OnWebPagePrerender event.
3. Save and enjoy.
Email Obfuscator 1.0.2
Description
When activated, this plug-in scours the document for mailto: email links and obfuscates them using Javascript before sending the result to the browser.No guarantees as to the spambot-proofness of the actual obfuscation, and please note that it does NOT obfuscate email addresses that are written outside a mailto: link.
Here's a page that uses the obfuscation:
http://athleticmindedtraveler.com/about_us/contact_us.php
If you want to see what the generated code looks like, do a "View Source."
Instructions
1. Create a new Plugin named whatever you want (i.e. Email Obfuscator). Paste in the code. Save.2. Under System Events, check the OnWebPagePrerender event.
3. Save and enjoy.
Email Obfuscator 1.0.2
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) {
$strNewAddress = replaceEntities($matches[1]);
$strText = replaceEntities($matches[2]);
$arrEmail = explode("@",$strNewAddress);
$strTag = "<script language='Javascript' type='text/javascript'>" . "r";
$strTag = $strTag . "<!--" . "r";
$strTag = $strTag . "document.write('<a href="mai');" . "r";
$strTag = $strTag . "document.write('lto');" . "r";
$strTag = $strTag . "document.write(':" . $arrEmail[0] . "');" . "r";
$strTag = $strTag . "document.write('@');" . "r";
$strTag = $strTag . "document.write('" . $arrEmail[1] . "">');" . "r";
$strTag = $strTag . "document.write('" . $strText . "</a>');" . "r";
$strTag = $strTag . "// -->" . "r";
$strTag = $strTag . "</script><noscript>" . $arrEmail[0] . " at " . "r";
$strTag = $strTag . str_replace("."," dot ",$arrEmail[1]) . "</noscript>";
return $strTag;
}
$modx->documentOutput=preg_replace_callback("#<a[^>]*mailto:([^'" ]*)['" ]>([^<]*)</a>#i","emailaddress",$modx->documentOutput);Previous Releases
Extras
No results found.