I was wondering what you guys think is the best way to implement an IP filter, and also how I should go about executing a function on every page.
I have a model and controller that allows my end users admins to enter IP’s that they want to block from having access to the site, they want to redirect these blocked IP’s to an error page. I’ve written the controller function to check the IP of the visitor and redirect but am unsure how to have the function execute on every page without having to code it in all controllers.
You could also use a filter. There is already CAccessControlFilter which has functionality for blocking IP-addresses.
If you want custom functionality you could create a class that extends from this or CFilter and then define it in the filters()-method of your parent controller.