0cool-f/banbuilder

用于在PHP项目中轻松处理粗话过滤的库。

2.2.3 2015-08-26 08:21 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:46 UTC


README

Gitter Build Status Latest Stable Version Total Downloads Latest Unstable Version License

BanBuilder是一个用于粗话过滤的PHP包。PHP脚本使用正则表达式智能地寻找“leetspeak”风格的数字或符号替换。

安装

要安装BanBuilder,只需将其包含在项目的composer.json文件中。

"0cool-f/banbuilder": "master",

此包无需其他依赖即可正常工作。

用法

请参阅官方包网站以获取完整的用法详情。

总结

简而言之,此代码将一个不良词汇数组与一个常见的过滤规避策略数组进行比较。然后它执行字符串替换,将正则表达式参数插入到不良词汇数组中,然后评估输入字符串是否包含扩展后的禁止词汇列表。

因此,在你的不良词汇数组中,你可能有

 [0] => 'ass'

preg_replace函数将所有可能的字母替换为正则表达式模式(而不是将变体添加到数组末尾),因此数组中的“ass”在preg_replace检查匹配之前变为这样

 [0] => /(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α)(s|s\.|s\-|5|\$|§)(s|s\.|s\-|5|\$|§)/i

这意味着一个词可以有零个、一个或任何种类的leet替换,仍然会触发。leet过滤器的一部分包括删除字母破折号和字母点。

这意味着以下所有都评估为“bitch”

  • B1tch
  • bi7tch
  • b.i.t.c.h.
  • b-i-t-c-h
  • b.1.t.c.h.
  • ßitch
  • 等等...

Flattr this git repo

测试

要从包目录运行此包的单元测试,只需从包目录运行vendor/bin/phpunit

许可证

Copyright (C) 2013 Alison Gianotto - snipe@snipe.net

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://gnu.ac.cn/licenses/>.