Skip to content

๐Ÿšซ NotAllowed ๐Ÿšซ =>A lightweight library that helps you to censor words, profane words, banned IPs, banned bank accounts, etc.

License

Notifications You must be signed in to change notification settings

pH-7/NotAllowed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

90 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšซ Not Allowed ๐Ÿšซ

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('[email protected]')) {
    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
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 ๐Ÿ˜Š

@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! ๐ŸŽˆ