Working with the IP Blacklist Programmatically

The IP Blacklist is a powerful tool built into Concrete CMS and checked any time the Anti-Spam system is used. It operates regardless of whether an Anti-Spam library is installed. It's easy to work with the IP blacklist programmatically:

Checking an IP

First, retrieve the IP Service:

$ip = \Core::make('helper/validation/ip');

Next, perform a check:

if ($ip->isBanned()) {
    // The user is banned
}

That's it! The IP of the current request will be checked against the blacklist.

Banning an IP

It's simple to add the current IP to the IP blacklist:

$ip->createIPBan();