禁止的IP在CodeIgniter之前检查其他任何内容

I have a table with IP/DNS data for banned visitors. I want this check to be done before anything else, but after the model for banned IPs is loaded.

What is the best place to add this code and make it run every time a page is accessed, taking into account that it should load a view for the 403 error to be displayed for banned visitors?

The banned visitors model is loaded globally (specified in autoload.php). Now, I only need to make the function that verifies if the visitor is banned global. Can this be done using hooks? What do you recommend?

create in the application/core folder a controller named MY_Controller.

The Controller should look like

class MY_Controller extends CI_Controller
{
    public function __construct()
    {
        $this->bannedIpAdresses();
    }

    private function bannedIpAdresses()
    {
        $this->load->model("BannedIps_Model");

        if ($this->BannedIps_Model->isIpBanned())
        {
            $this->load->view("restricted");
            die();
        }

    }
}

and every other Controller like the welcome Controller should look like

class Welcome extends MY_Controller {

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->load->view('welcome_message');
    }
}