PHP Classes

PHP Not Allowed: Detect and filter unwanted information

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-07-28 (-1 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 82 All time: 10,085 This week: 660Up
Version License PHP version Categories
notallowed 1.0.2Custom (specified...7.2PHP 5, Validation
Description 

Author

This package can detect and filter unwanted information.

It provides several functions that take as parameters data values that can be passed to applications by the users and determines if they contain unwanted information that if accepted by the applications could cause several types of problems.

Currently the package can detect unwanted information like words to be censored, profane words, banned IP addresses, banned bank accounts, email addresses used by spam traps, etc..

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 53 packages by
Country: United Kingdom
Age: 32
All time rank: 37116 in United Kingdom
Week rank: 22 Up3 in United Kingdom Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x

Documentation

? 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

<details> <summary>Example</summary>

Ban::merge('usernames', ['pooter', 'hitler', '690']);
Ban::merge('words', ['cuck', 'bomb']);
Ban::mergeFile('emails', './my_banned_emails.txt');

</details>

Now simply validate per normal conventions.

? Author

[Pierre-Henry Soria][author-url], a highly passionate, zen &amp; cool software engineer ?

[![@phenrysay][twitter-image]][twitter-url]

Pierre-Henry Soria")

???? Helpers

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.

?? License

Generously distributed under [MIT License][license-url]! ?

<!-- GitHub's Markdown reference links --> [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


  Files folder image Files (15)  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (15)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files (15)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file php.yml Data Auxiliary data

  Files folder image Files (15)  /  src  
File Role Description
Files folder imagebanned-data (6 files)
  Plain text file Ban.php Class Class source

  Files folder image Files (15)  /  src  /  banned-data  
File Role Description
  Accessible without login Plain text file bank_accounts.txt Doc. Documentation
  Accessible without login Plain text file BURNER-EMAIL.LICENSE Lic. License text
  Accessible without login Plain text file emails.txt Doc. Documentation
  Accessible without login Plain text file ips.txt Doc. Documentation
  Accessible without login Plain text file usernames.txt Doc. Documentation
  Accessible without login Plain text file words.txt Doc. Documentation

  Files folder image Files (15)  /  tests  
File Role Description
Files folder imagefixtures (2 files)
  Plain text file BanTest.php Class Class source

  Files folder image Files (15)  /  tests  /  fixtures  
File Role Description
  Accessible without login Plain text file extended_usernames.txt Doc. Documentation
  Accessible without login Plain text file extended_words.txt Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:82
This week:0
All time:10,085
This week:660Up