This extension is designed to protect email addresses from harvesting by spambots, through obfuscation. It then uses jQuery to clarify the email address, presenting a valid email address to the user (optionally in a mailto: link).
protected/extensionsConfig code:
'components'=>array(
...
'obfuscator'=>array(
'class' =>'application.extensions.obfuscator.Obfuscator',
),
...
),
The class has a single public function: disguise(). This function takes 2 parameters:
Wherever you want an email address inserted, call the disguise function according to the following examples:
With a mailto link:
<?php echo Yii::app()->obfuscator->disguise('email@example.com',true); ?>
Without a link:
<?php echo Yii::app()->obfuscator->disguise('email@example.com',false); ?>
Total 4 comments
bugs fix for the custom str_rot function, which crash the variable $l
let use code below:
because this extension use php function str_rot13, which is not encode the numeric character, therefore, to quickly fix this bugs, your may edit the javascript rot13 function by replace: (just to remove "0-9") for replacement
to
another alternative will be creating a new str_rot function in the class, and use it to do encrpyption, sample as below:
then kindly replace in function "disguise":
to
Hey, the following e-mail (numeric, but valid) is totally corrupted: 21345@wtr.com
shows as 76890@wtr.com when obfuscated.
How come? it shouldn't change! Actually it's not obfuscated at all
That's a very useful extension Thanks!!!
Leave a comment
Please login to leave your comment.