承接 gremo/email-obfuscator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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-obfuscator but 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 $middleware array in App\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 $routeMiddleware array in App\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

统计信息

  • 总下载量: 1.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-12