PHP code example of ph-7 / notallowed

1. Go to this page and download the library: Download ph-7/notallowed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ph-7 / notallowed example snippets


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";
}

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