ph-7/notallowed
Composer 安装命令:
composer require ph-7/notallowed
包简介
Filter profane words, usernames, spam/temporary emails, etc.
关键字:
README 文档
README
NotAllowed is a simple, lightweight PHP 8.1 library that helps you censor words, profane words, blacklisted IPs, forbidden usernames, banned bank card numbers, etc.
You can easily add new specific keywords (such as IPs, usernames, bank accounts, words, etc.) to be banned in ~/src/banned-data/* folder.
🛠 Server Requirement
- PHP 8.1 or higher.
📓 Installation (with Composer)
composer require ph-7/notallowed
🎮 Usage
Simple example of what you can do with NotAllowed 🙂
use PH7\NotAllowed\Ban; if (Ban::isUsername('admin')) { echo '"admin" is not allowed as username.'; } if (Ban::isEmail('james@spamhole.com')) { echo '"@spamhole.com" domain is considered a spam email host.'; } if (Ban::isWord('He is an asshole')) { echo 'Please watch your mouth :-)'; } if (Ban::isIp('1.170.36.229')) { echo 'This IP address is blacklisted'; } $userInput = 'admin'; if (Ban::isUsername($userInput, ['root', 'sudo', 'admin'])) { echo "$userInput is not allowed"; } // Check if $userInput contains a banned word OR a banned username if (Ban::isAny($userInput, email: false, word: true, username: true)) { echo "$userInput is not allowed"; }
Extending Banned Phrases
You can supply your own values to be merged with the out-of-box banned data in 2 ways:
Ban::merge(string $scope, string | array $value)Ban::mergeFile(string $scope, string $path)
$scope refers to the category of data. Possible values are currently:
- usernames
- words
- ips
- emails
- bank_accounts
Example
Ban::merge('usernames', ['pooter', 'hitler', '690']); Ban::merge('words', ['cuck', 'bomb']); Ban::mergeFile('emails', './my_banned_emails.txt');
Now simply validate per normal conventions.
🚀 Author
Pierre-Henry Soria, a highly passionate, zen & cool software engineer 😊
👩🏻💻 Helpers
soulshined - just a coder
🧐 Used By...
pH7Builder, a social dating webapp builder. Used here: https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Security/Ban/Ban.class.php.
⚖️ License
Generously distributed under MIT License! 🎈
ph-7/notallowed 适用场景与选型建议
ph-7/notallowed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 245 次下载、GitHub Stars 达 10, 最近一次更新时间为 2019 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「word」 「filter」 「spam」 「profane」 「ban」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ph-7/notallowed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ph-7/notallowed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ph-7/notallowed 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nova searchable filter for belongsTo relationships.
Provide a way to secure accesses to all routes of an symfony application.
Symfony DataGridBundle
It's a barebone security class written on PHP
Unofficial port of the Carbone API SDK to Saloon v3
Data provider for yii2
统计信息
- 总下载量: 245
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-18