Email Guardian Tag
Automatically Obfuscate All Email Addresses
Simply wrap any code with the email_guardian tag to find and obfuscate email addresses.
The email_guardian tag will find all plain text email addresses and mailto links, obfuscating them by using a cipher with a random key and reversing the order of characters to hide them from spambots. A JavaScript routine then decodes them for displaying normally on the page. You can wrap an entire page with the tag or use multiple tags to wrap specific content.
Parameters:
no_script_message - If Javascript is disabled, this message will be displayed instead of the expected content. The default is 'JavaScript required to see this email address.'
create_links - For free floating plaintext email addresses, the Email Guardian helpfully converts the address to a clickable mailto link. To turn off this feature and simply obfuscate text email addresses without converting them, set the parameter create_links="0".
Installing the Add-On
To use this tag, unzip and add the folder to your 'couch/addons' directory. Initiate the tag in 'couch/addons/k_functions.php'.
https://github.com/fallingsprings/couch ... l-guardian
*The zip file above is a new, more capable and more robust update to the Email Guardian tag. The original post below remains purely for historical purposes.*
I created a website for someone with very low confidence on a computer. Explaining about mailto links and email obfuscation was not an option. She needed to be able to just type email addresses anywhere without having to think about it.
So I made the email_guardian tag to scan for email addresses and automatically obfuscate them using Couch's cloak_email tag.
I know a lot of people don't think twice about posting an email address on the web, so this tag could be a useful tool for designers who want to make it easy for people but still keep them protected.
Simply wrap any portion of code in the <cms:email_guardian> tag to scan for and encrypt all email addresses.
To enable the tag, add the following code to your couch/addons/kfunctions.php file.
Automatically Obfuscate All Email Addresses
Simply wrap any code with the email_guardian tag to find and obfuscate email addresses.
- Code: Select all
<cms:email_guardian>
<cms:show my_blog_post />
</cms:email_guardian>
The email_guardian tag will find all plain text email addresses and mailto links, obfuscating them by using a cipher with a random key and reversing the order of characters to hide them from spambots. A JavaScript routine then decodes them for displaying normally on the page. You can wrap an entire page with the tag or use multiple tags to wrap specific content.
Parameters:
no_script_message - If Javascript is disabled, this message will be displayed instead of the expected content. The default is 'JavaScript required to see this email address.'
create_links - For free floating plaintext email addresses, the Email Guardian helpfully converts the address to a clickable mailto link. To turn off this feature and simply obfuscate text email addresses without converting them, set the parameter create_links="0".
Installing the Add-On
To use this tag, unzip and add the folder to your 'couch/addons' directory. Initiate the tag in 'couch/addons/k_functions.php'.
- Code: Select all
require_once( K_COUCH_DIR.'addons/email-guardian/email-guardian.php' );
https://github.com/fallingsprings/couch ... l-guardian
*The zip file above is a new, more capable and more robust update to the Email Guardian tag. The original post below remains purely for historical purposes.*
I created a website for someone with very low confidence on a computer. Explaining about mailto links and email obfuscation was not an option. She needed to be able to just type email addresses anywhere without having to think about it.
So I made the email_guardian tag to scan for email addresses and automatically obfuscate them using Couch's cloak_email tag.
I know a lot of people don't think twice about posting an email address on the web, so this tag could be a useful tool for designers who want to make it easy for people but still keep them protected.
Simply wrap any portion of code in the <cms:email_guardian> tag to scan for and encrypt all email addresses.
- Code: Select all
<cms:email_guardian>
<cms:show my_blog_post />
</cms:email_guardian>
To enable the tag, add the following code to your couch/addons/kfunctions.php file.
- Code: Select all
//This tag is deprecated. Please download the zip file instead.
class CustomTags {
static function email_guardian( $params, $node ){
global $FUNCS;
foreach( $node->children as $child ){
$html .= $child->get_HTML();
}
preg_match_all('/\b[^\s]+@[^\s]+/', strip_tags(htmlspecialchars_decode($html, ENT_QUOTES)), $emails);
foreach($emails[0] as $email){
$email = trim(strtolower($email), ".,;:?!\"\'‘’‚“”„‹›-+&#*%$@~`^()|<>[]{}/\\");
$code = $FUNCS->embed( "<cms:cloak_email email='{$email}' />", $is_code=1 );
$pos = strpos($html, $email);
if ($pos !== false) {
$html = substr_replace($html, $code, $pos, strlen($email));
}
}
return $html;
}
}
$FUNCS->register_tag( 'email_guardian', array('CustomTags', 'email_guardian') );