How to restrict access to admin interface by certain IP address

From aMember Pro Documentation
Revision as of 03:41, 9 August 2013 by Caesar (Talk | contribs)

Jump to: navigation, search

Add this code to site.php file:

<?php
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);