ph-7/notallowed

Filter profane words, usernames, spam/temporary emails, etc.

Maintainers

👁 ph-7

Package info

github.com/pH-7/NotAllowed

Homepage

pkg:composer/ph-7/notallowed

Fund package maintenance!

Ko Fi

pH-7

Statistics

Installs: 245

Dependents: 0

Suggesters: 0

Stars: 10

Open Issues: 0

2.1.0 2023-06-14 01:16 UTC

Requires

  • php: >=8.1

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 957c798eb8414e25fa1380c17a427993f9a6a13c

  • Pierre-Henry Soria <hi.woop@ph7.me>

securitywordfilterspamprofanebanemailsbannedtemporary emailnot allowedprofane wordsfilter wordsscam

This package is auto-updated.

Last update: 2026-06-29 02:11:29 UTC


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

📓 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:

  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_accounts

Now simply validate per normal conventions.

🚀 Author

Pierre-Henry Soria, a highly passionate, zen & cool software engineer 😊

👁 @phenrysay

👁 Pierre-Henry Soria

👩🏻‍💻 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! 🎈