Email Link Obfuscator
Votes: 15
Tags: plugin, manager, email spam javascript
Submitted: Jun 30, 2006
Released: Jun 30, 2006
Downloads: 2178
License: Free
Package Website
Email Link Obfuscator 1.0.2
Works with the following Version(s): 0.9.1 | 0.9.2 | 0.9.2.1 | 0.9.2.2 | 0.9.5
Plug-in to automatically obfuscate email links with Javascript.
Download
- repo-606.txt (2178 downloads)
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($matches1);
$strText = replaceEntities($matches2);
$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(':" . $arrEmail0 . "');" . "r";
$strTag = $strTag . "document.write('@');" . "r";
$strTag = $strTag . "document.write('" . $arrEmail1 . "">');" . "r";
$strTag = $strTag . "document.write('" . $strText . "</a>');" . "r";
$strTag = $strTag . "// -->" . "r";
$strTag = $strTag . "</script><noscript>" . $arrEmail0 . " at " . "r";
$strTag = $strTag . str_replace("."," dot ",$arrEmail1) . "</noscript>";
return $strTag;
}
$modx->documentOutput=preg_replace_callback("#<a^>*mailto:(^'" *)'" >(^<*)</a>#i","emailaddress",$modx->documentOutput);

Please login to comment.