Yii Framework Forum: [EXTENSION] Obfuscator - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] Obfuscator Extension to hide email addresses from spambots, but not users

#1 User is offline   M Wotton 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 01-November 09

Posted 02 February 2010 - 08:10 PM

Link to extension
Obfuscates email addresses in the source, but presents a valid address to user.
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).



Yii 1.0.11 or above


  • Extract the release file under `protected/extensions`
  • Add the class as a component in your application's main.php config file:

    'class' =>'application.extensions.obfuscator.Obfuscator',


The class has a single public function: disguise(). This function takes 2 parameters:
  • $email (string): The email address to be obfuscated
  • $link (bool): Whether the email address should be displayed to the user as a mailto link - default is 'true'

Wherever you want an email address displayed, call the disguise function according to the following examples:

With a mailto link:
echo Yii::app()->obfuscator->disguise('user@example.com',true);

Without a link:
echo Yii::app()->obfuscator->disguise('user@example.com',false);

Micha Wotton
Posted Image

#2 User is offline   Catalin Teodorescu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 15-May 14

Posted 12 September 2014 - 11:40 PM

Hi, I know there's been at least 2y since last update but I'd very much like if you would fix the following bug:
If my email address has a number in it (like: dust90feather), after obfuscation, it returns "dust45feather".
Thanks in advance.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users