Giter Site home page Giter Site logo

ph-7 / notallowed Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 4.0 450 KB

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

Home Page: https://packagist.org/packages/ph-7/notallowed

License: MIT License

PHP 100.00%
ban ban-words filter-words check-words security spam blacklist profane-words profane banned

notallowed's Introduction

๐Ÿšซ 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

๐Ÿ““ Installation (with Composer)

composer require ph-7/notallowed

๐ŸŽฎ Usage

Simple example of what you can do with it :)

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

notallowed's People

Contributors

ph-7 avatar soulshined avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.