定制 sworup/profanityfilter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sworup/profanityfilter

最新稳定版本:1.0.1

Composer 安装命令:

composer require sworup/profanityfilter

包简介

Profanity filter package would help you censor some of the bad words users put in your posts and/or comments.

README 文档

README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads

Profanity Filter takes strings as input and removes any bad curse words that the string might have. It checks the strings for specific blacklist which must match as a separate word to be considered as a curse word. If a curse word is found, then it will replace the curse word with a censor character the user chooses (default is *).

This package is intended to used with Laravel. Tested and working with laravel 5.4.

If you want to override the Package's config file, just copy it and rename it to config/profanity-filter.php, and update as per your needs.

This code is based on Fastwebmedia/Profanity-Filter. A major part of it is taken from there and I added the things that I thought it required.

Install

Via Composer

$ composer require sworup/profanityfilter

###Laravel Add 'Sworup\ProfanityFilter\ProfanityServiceProvider' to your providers array.

If you wish to use the Facade then add 'Profanity' => 'Sworup\ProfanityFilter\Profanity'

The package will automatically use the config file containing the list of banned words.

Usage

$swear_word = ['dog'];
$blacklist  = ['puppy'];
$replace    = ['a' => '(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α|Δ|Λ|λ)'];

$profanity_filter = new sworup\ProfanityFilter($swear_words, $blacklist, $replace);
echo $profanity_filter->clean('Dog, puppy badpuppy baddog!', '$');

The above code would return:

array(
    'old_string' => 'Dog, puppy badpuppy baddog!',
    'new_string' => '$$$, $$$$$ badpuppy bad$$$!',
    'clean'      => false
);

Change log

Please see CHANGELOG for more information about what has changed recently.

Testing

$ phpspec run

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email sworup.shakya@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-04