https://github.com/beastbytes/email-obfuscator
Yii3 widget to obfuscate email addresses to prevent harvesting by bots
https://github.com/beastbytes/email-obfuscator
Last synced: 2 months ago
JSON representation
Yii3 widget to obfuscate email addresses to prevent harvesting by bots
- Host: GitHub
- URL: https://github.com/beastbytes/email-obfuscator
- Owner: beastbytes
- License: other
- Created: 2023-06-28T15:42:01.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-30T14:00:08.000Z (almost 2 years ago)
- Last Synced: 2024-12-06T19:54:46.739Z (6 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# emailobfuscator
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](LICENSE.md) file.
## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist beastbytes/emailobfuscator
```or add
```json
"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")
```php
echo EmailObfuscator::widget([
'email' => '[email protected]'
]);
```### Output
#### JavaScript Disabled
```html
This e-mail address is protected to prevent harvesting by spam-bots
```#### JavaScript Enabled
```html
[email protected]
```---
To output a different message set content['obfuscated']
```php
echo EmailObfuscator::widget([
'email' => '[email protected]',
'content' => ['obfuscated' => 'Enable JavaScript to see the email address']
]);
```### Output
#### JavaScript Disabled
```html
Enable JavaScript to see the email address
```#### JavaScript Enabled
```html
[email protected]
```---
To output an obfuscated version of the email address set the obfuscators: "my dot address at example dot com"
```php
echo EmailObfuscator::widget([
'email' => '[email protected]',
'obfuscators' => [' dot ', ' at ']
]);
```### Output
#### JavaScript Disabled
```html
my dot address at example dot com
```#### JavaScript Enabled
```html
[email protected]
```---
To set the content of the mailto link, set content['clear']
```php
echo EmailObfuscator::widget([
'email' => '[email protected]',
'content' => ['clear' => 'by email']
]);
```### Output
#### JavaScript Disabled
```html
This e-mail address is protected to prevent harvesting by spam-bots
```#### JavaScript Enabled
```html
by email
```