How to restrict access to admin interface by certain IP address

From aMember Pro Documentation
Jump to: navigation, search

Add this code to site.php file:

class Am_Controller_CheckIp extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        if (stripos($this->getRequest()->getControllerName(), 'admin')===0)
        {
            if ($_SERVER['REMOTE_ADDR']!='127.0.0.1') die('Access Denied');
        }
    }
}
 
Zend_Controller_Front::getInstance()->registerPlugin(new Am_Controller_CheckIp, 500);