Difference between revisions of "How to restrict access to admin interface by certain IP address"

From aMember Pro Documentation
Jump to: navigation, search
 
Line 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
<?php
 
 
class Am_Controller_CheckIp extends Zend_Controller_Plugin_Abstract
 
class Am_Controller_CheckIp extends Zend_Controller_Plugin_Abstract
 
{
 
{

Latest revision as of 03:08, 3 November 2015

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