Working with the IP Blacklist Programmatically

The IP Blacklist is a powerful tool built into concrete5 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:

Was this information useful?
Thank you for your feedback.

Could this page use improvement? Edit it!

Edit Page