gremo/email-obfuscator
最新稳定版本:v1.0.0
Composer 安装命令:
composer require gremo/email-obfuscator
包简介
A text filter for automatic email obfuscation using Javascript or CSS fallback
README 文档
README
I'm not the author of this package. The original package was
propaganistas/email-obfuscatorbut the author decided to abandon and delete the GitHub repository, breaking all sites using it. I've just cloned and uploaded the latest version available.
A text filter for automatic email obfuscation using the well-established JavaScript and a CSS fallback:
- ROT13 ciphering for JavaScript-enabled browsers
- CSS reversed text direction for non-JavaScript browsers
Installation
Install the bundle via Composer:
composer require gremo/email-obfuscator
Then include the supplied JavaScript file (assets/email-obfuscator.min.js) somewhere in your template. CND alternative (no uptime guaranteed):
https://cdn.rawgit.com/gremo/email-obfuscator/master/assets/email-obfuscator.min.js
Platform specific steps
Standalone
Require the src/Obfuscator.php file somewhere in your project:
require_once 'PATH_TO_LIBRARY/src/Obfuscator.php';
Parse and obfuscate a string by using the obfuscateEmail($string) function.
Laravel 5
You have 3 options depending on your use case:
- If you want to obfuscate all email addresses that Laravel ever outputs, add the middleare class to the
$middlewarearray inApp\Http\Middleware\Kernel.php:
protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, // ... \Gremo\EmailObfuscator\Laravel\Middleware::class, ];
This is the reccomended method.
- If you only want to have specific controller methods return obfuscated email addresses, add the Middleware class to the
$routeMiddlewarearray inApp\Http\Middleware\Kernel.php:
protected $routeMiddleware = [ 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, // ... 'obfuscate' => \Gremo\EmailObfuscator\Laravel\Middleware::class, ];
... and apply controller middleware as usual in a controller's construct method or route definition:
public function __construct() { $this->middleware('obfuscate'); }
- If you want to apply obfuscation only on specific strings, just use the
obfuscateEmail($string)function.
Twig
Add the extension to the Twig_Environment:
$twig = new Twig_Environment(...); $twig->addExtension(new \Gremo\EmailObfuscator\Twig\Extension());
The extension exposes an obfuscateEmail Twig filter, which can be applied to any string.
{{ "Lorem Ipsum"|obfuscateEmail }}
{{ variable|obfuscateEmail }}
Credits
- Scott Yang for the JavaScript used in this method.
- Silvan Mühlemann for the inspiration of the CSS implementation.
gremo/email-obfuscator 适用场景与选型建议
gremo/email-obfuscator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.9k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「twig」 「email」 「spam」 「laravel」 「antispam」 「obfuscation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gremo/email-obfuscator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gremo/email-obfuscator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gremo/email-obfuscator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
Simple captcha generator
A Twig extension to insert css as inline styles with a tag
reCAPTCHA library
Caching and compression for Twig assets (JavaScript and CSS).
统计信息
- 总下载量: 1.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-12