Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ph-7/notallowed
🚫 NotAllowed 🚫 =>A lightweight library that helps you to censor words, profane words, banned IPs, banned bank accounts, etc.
https://github.com/ph-7/notallowed
ban ban-words banned blacklist censor censored-words check-words filter-words php72 profane profane-words security spam
Last synced: about 1 month ago
JSON representation
🚫 NotAllowed 🚫 =>A lightweight library that helps you to censor words, profane words, banned IPs, banned bank accounts, etc.
- Host: GitHub
- URL: https://github.com/ph-7/notallowed
- Owner: pH-7
- License: mit
- Created: 2019-07-18T14:08:42.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-14T01:16:03.000Z (over 1 year ago)
- Last Synced: 2024-10-12T12:23:09.801Z (about 1 month ago)
- Topics: ban, ban-words, banned, blacklist, censor, censored-words, check-words, filter-words, php72, profane, profane-words, security, spam
- Language: PHP
- Homepage: https://packagist.org/packages/ph-7/notallowed
- Size: 439 KB
- Stars: 7
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚫 Not Allowed 🚫
**NotAllowed** is a simple lightweight PHP 8.1 library that helps you to censor words, profane words, blacklisted IPs, forbidden user names, banned bank card numbers, etc.
You can add easily new specific keywords (such as IPs, usernames, bank accounts, words, etc) to ban in `~/src/banned-data/*` folder.
## 🛠 Server Requirement
- [PHP 8.1](https://www.php.net/releases/8.1/en.php) or higher.
## 📓 Installation (with Composer)
```bash
composer require ph-7/notallowed
```## 🎮 Usage
Simple example of what you can do with it :)
```php
use PH7\NotAllowed\Ban;if (Ban::isUsername('admin')) {
echo '"admin" is not allowed as username.';
}if (Ban::isEmail('[email protected]')) {
echo '"@spamhole.com" domain is considered as a email spam 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";
}// Validate of the userinput is 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 2 ways
1. `Ban::merge(string $scope, string | array $value)`
2. `Ban::mergeFile(string $scope, string $path)``$scope` refers to the category of data. Possible values are currently:
- usernames
- words
- ips
- emails
- bank_accountsExample
```php
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][author-url]**, a highly passionate, zen & cool software engineer 😊
[![@phenrysay][twitter-image]][twitter-url]
[![Pierre-Henry Soria](https://avatars0.githubusercontent.com/u/1325411?s=220)](https://pierrehenry.be "Pierre-Henry - Software Developer Website :-)")
## 👩🏻💻 Helpers
**[soulshined](https://github.com/soulshined)** - just a coder
## 🧐 Used By...
**[pH7Builder][ph7cms-url]**, a social dating webapp builder. Used here: [https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Security/Ban/Ban.class.php](https://github.com/pH7Software/pH7-Social-Dating-CMS/blob/master/_protected/framework/Security/Ban/Ban.class.php).
## ⚖️ License
Generously distributed under [MIT License][license-url]! 🎈
[author-url]: https://pierrehenry.be
[ph7cms-url]: https://ph7cms.com
[license-url]: https://opensource.org/licenses/MIT
[twitter-image]: https://img.shields.io/twitter/url/https/shields.io.svg?style=social
[twitter-url]: https://twitter.com/phenrysay