beastbytes / emailobfuscator
Widget to obfuscate email addresses
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:extension
Requires
- php: >=8.0
- yiisoft/arrays: ^3.0
- yiisoft/html: ^3.0
- yiisoft/view: ^8.0
- yiisoft/widget: ^2.0
Requires (Dev)
- consolidation/robo: ^4.0
- phpunit/phpunit: ^10.0
- roave/infection-static-analysis-plugin: ^1.0
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.0
- yiisoft/test-support: ^3.0
This package is auto-updated.
Last update: 2024-12-14 13:58:11 UTC
README
Widget to obfuscate an email address to help prevent harvesting by spam bots.
If JavaScript is disabled on the client, the widget will output either a message or an obfuscated version of the email address.
If JavaScript is enabled the output is replaced with (by default) a mailto link showing (again by default) the email address. The content of the mailto link can be customised.
For license information see the LICENSE file.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist beastbytes/emailobfuscator
or add
"beastbytes/emailobfuscator": "^1.0"
to the require section of your composer.json.
Usage
Use this extension in a view.
To output the default message ("This e-mail address is protected to prevent harvesting by spam-bots")
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com' ]);
Output
JavaScript Disabled
<span id="w0">This e-mail address is protected to prevent harvesting by spam-bots</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To output a different message set content['obfuscated']
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'content' => ['obfuscated' => 'Enable JavaScript to see the email address'] ]);
Output
JavaScript Disabled
<span id="w0">Enable JavaScript to see the email address</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To output an obfuscated version of the email address set the obfuscators: "my dot address at example dot com"
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'obfuscators' => [' dot ', ' at '] ]);
Output
JavaScript Disabled
<span id="w0">my dot address at example dot com</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To set the content of the mailto link, set content['clear']
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'content' => ['clear' => 'by email'] ]);
Output
JavaScript Disabled
<span id="w0">This e-mail address is protected to prevent harvesting by spam-bots</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">by email</a></span>