How to restrict access to admin interface by certain IP address

From aMember Pro Documentation
Revision as of 02:05, 23 January 2013 by Caesar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create /amember/application/configs/site.php with this code:

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