Skip to content

Pfarrer/yii2-email-obfuscator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

yii2-email-obfuscator

Email obfuscatior plugin for Yii2.

This plugin combines some Email obfuscation technics.

  • The @ char is removed and only its index is passed on. It will be reinserted using the expression String.fromCharCode(422*4).
  • The address itself will be transmitted as a ROT13 transformed string which will be retransformed by Javascript.
  • The "mailto:" prefix is decoded as a reversed string which gets unreversed by Javascript.

The Email address "mail@example.com" will result in the following code:

<script type="text/javascript">
var action=":otliam".split("").reverse().join("");
var href="znvyrknzcyr.pbz".replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
href=href.substr(0, 4) + String.fromCharCode(4*2*2*4) + href.substr(4);
var a = "<a href=\""+action+href+"\">"+href+"</a>";
document.write(a);
</script>

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require "pfarrer/yii2-email-obfuscator" "dev-master"

or add

"pfarrer/yii2-email-obfuscator": "dev-master"

to the require section of your composer.json file.

Usage

Simply insert this in your template:

<?= \pfarrer\yii2\email\Obfuscator::widget([
	'email' => 'mail@example.com',
]) ?>

About

Yii2 extension to obfuscate eMail addresses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages